Apache kafka 《卡夫卡内部话题》__“消费者补偿”;使用错误的代理ID重新分配,现在已损坏

Apache kafka 《卡夫卡内部话题》__“消费者补偿”;使用错误的代理ID重新分配,现在已损坏,apache-kafka,apache-zookeeper,Apache Kafka,Apache Zookeeper,大家好, 早些时候,在生产中,我们有一个broker.id=0的KAFKA(和Zookeeper)实例,服务器是PRD-1。一切都很好,直到我们将其转换为集群以实现弹性 因此,在将kafka的单个工作实例转换为具有2个节点的集群时,我们在$kafka_HOME/config/server.properties中做了如下更改 我们还在服务器1和服务器2属性的zookeeper配置中做了类似的更改 PRD-1: port=9092 broker.id=1 #Note change in bro

大家好,

早些时候,在生产中,我们有一个broker.id=0的KAFKA(和Zookeeper)实例,服务器是PRD-1。一切都很好,直到我们将其转换为集群以实现弹性

因此,在将kafka的单个工作实例转换为具有2个节点的集群时,我们在$kafka_HOME/config/server.properties中做了如下更改 我们还在服务器1和服务器2属性的zookeeper配置中做了类似的更改

PRD-1:

port=9092
broker.id=1    #Note change in broker id here. This was a mistake.
advertised.host.name=PRD-1.KPT.COM
zookeeper.connect=PRD-1.KPT.COM:2181,PRD-2.KPT.COM:2181
  port=9092
  broker.id=2
  advertised.host.name=PRD-2.KPT.COM
  zookeeper.connect=PRD-1.KPT.COM:2181,PRD-2.KPT.COM:2181
PRD-2:

port=9092
broker.id=1    #Note change in broker id here. This was a mistake.
advertised.host.name=PRD-1.KPT.COM
zookeeper.connect=PRD-1.KPT.COM:2181,PRD-2.KPT.COM:2181
  port=9092
  broker.id=2
  advertised.host.name=PRD-2.KPT.COM
  zookeeper.connect=PRD-1.KPT.COM:2181,PRD-2.KPT.COM:2181
在这次更改之后,我们启动了集群,它从代理1和代理2开始。它使用来自多个生产者的消息。一切正常,群集已启动并运行

但是, 没有一个使用者能够连接到新创建的kafka群集来使用消息。当我检查存储所有使用者偏移量的内部主题(主题:_consumer_offset)时,我发现它是在将实例转换为集群之前创建的。我们发现了以下奇怪的细节:

./kafka-topics.sh --describe --zookeeper PRD-1.KPT.COM:2181,PRD-2.KPT.COM:2181 --topic __consumer_offsets
Topic:__consumer_offsets    PartitionCount:50   ReplicationFactor:1 Configs:segment.bytes=104857600,cleanup.policy=compact,compression.type=producer
    Topic: __consumer_offsets   Partition: 0    Leader: 0   Replicas: 0 Isr: 0
    Topic: __consumer_offsets   Partition: 1    Leader: 0   Replicas: 0 Isr: 0
    Topic: __consumer_offsets   Partition: 2    Leader: 0   Replicas: 0 Isr: 0
    Topic: __consumer_offsets   Partition: 3    Leader: 0   Replicas: 0 Isr: 0
    Topic: __consumer_offsets   Partition: 4    Leader: 0   Replicas: 0 Isr: 0
显然,内部主题uuu consumer u offset仍然配置为broker.id=0(如果PRD-1在没有集群的单机上运行时)

看到上面的情况,我试着用下面的命令重新分配

./kafka-topics.sh --describe --zookeeper PRD-1.KPT.COM:2181,PRD-2.KPT.COM:2181 --topic __consumer_offsets
Topic:__consumer_offsets    PartitionCount:50   ReplicationFactor:3 Configs:segment.bytes=104857600,cleanup.policy=compact,compression.type=producer
    Topic: __consumer_offsets   Partition: 0    Leader: 0   Replicas: 1,2,0 Isr: 0
    Topic: __consumer_offsets   Partition: 1    Leader: 0   Replicas: 1,2,0 Isr: 0
    Topic: __consumer_offsets   Partition: 2    Leader: 0   Replicas: 1,2,0 Isr: 0
    Topic: __consumer_offsets   Partition: 3    Leader: 0   Replicas: 1,2,0 Isr: 0
    Topic: __consumer_offsets   Partition: 4    Leader: 0   Replicas: 1,2,0 Isr: 0
但重新分配使现在的情况更加糟糕,我有3个副本(0,1,2),其中0是不存在的死代理

现在我的主题uu consumer_offset的复制因子为3,因为集群中只有2个节点(代理1和2)

主题重新分配现在失败,错误消息如下

ERROR: Assigned replicas (1,2,0) don't match the list of replicas for reassignment (1,2) for partition __consumer_offsets-22
ERROR: Assigned replicas (1,2,0) don't match the list of replicas for reassignment (1,2) for partition __consumer_offsets-30
ERROR: Assigned replicas (1,2,0) don't match the list of replicas for reassignment (1,2) for partition __consumer_offsets-8
ERROR: Assigned replicas (1,2,0) don't match the list of replicas for reassignment (1,2) for partition __consumer_offsets-21
ERROR: Assigned replicas (1,2,0) don't match the list of replicas for reassignment (1,2) for partition __consumer_offsets-4
ERROR: Assigned replicas (1,2,0) don't match the list of replicas for reassignment (1,2) for partition __consumer_offsets-27
.....
..
..
Reassignment of partition __consumer_offsets-22 failed
Reassignment of partition __consumer_offsets-30 failed
Reassignment of partition __consumer_offsets-8 failed
有人能帮忙吗,怎么做才能让主题消费者识别集群并相应地更新其详细信息?

我需要删除主题\uu消费者\u偏移并反弹卡夫卡,以便它自动创建它?

任何寻求帮助/解决方案/方法的人都将不胜感激


谢谢。

我已经解决了这个问题。我想在这里为任何寻求解决同类问题的方法的人发帖子。每当内部偏移主题损坏(或不符合--descripe中的集群设置)时,您需要通过转到Zookeeper外壳并跳出kafka/Zookeeper来删除它,这样kafka将在下次重新启动时自动创建该主题,作为其内部主题。使用--description选项检查kafka-topic.sh的主题详细信息。您应该能够看到主题是根据您的集群详细信息(领导者、ISR和副本详细信息)创建的。您好,Mehul,消费者偏移量是一个管理主题。删除将导致群集中未跟踪消息丢失的消息。有没有办法迁移主题而不实际删除?