kafka报 1 partitions have leader brokers without a matching listener

開開新新 发表于: 2020-11-19   最后更新时间: 2020-11-19  
WARN 1 [  XNIO-1 task-5] k.c.NetworkClient$DefaultMetadataUpdater : [Consumer clientId=kafdrop-consumer, groupId=null] 1 partitions have leader brokers without a matching listener, including [IIoT-0]
./kafka-topics.sh --zookeeper localhost:2181 --describe --topic IIoT
Topic: IIoT    PartitionCount: 3    ReplicationFactor: 1    Configs: 
    Topic: IIoT    Partition: 0    Leader: none    Replicas: 3    Isr: 3
    Topic: IIoT    Partition: 1    Leader: 1    Replicas: 1    Isr: 1
    Topic: IIoT    Partition: 2    Leader: 2    Replicas: 2    Isr: 2
./kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list 192.168.10.145:9092 --topic IIoT
Error: partition 0 does not have a leader. Skip getting offsets
[2020-11-19 08:50:35,271] WARN [Consumer clientId=GetOffsetShell, groupId=null] 1 partitions have leader brokers without a matching listener, including [IIoT-0] (org.apache.kafka.clients.NetworkClient)
IIoT:1:20213
IIoT:2:11589

broker集群每台主机上都没有显示错误信息,但是kfa之类的工具启动的话会报错,提示“1 partitions have leader brokers without a matching listener” ,在这之前我滚动升级过kafka集群。

我已经设置了auto.leader.rebalance.enable=true,感觉是不是数据丢了?

这种只有一个分区没有leader的情况,修复的方法 也是重新选举分区leader吗?



您需要解锁本帖隐藏内容请: 点击这里
本帖隐藏的内容




上一条: kafka拥有不同副本数量的集群,应该如何升级?
下一条: 为什么关闭kafka之后,它会自动重启?

  • 我执行了滚动升级,其他topic都没有问题。

    你做了什么操作?leader都不选举了。

    • ./kafka-leader-election.sh --election-type preferred --path-to-json-file replica-election.json --bootstrap-server 192.168.10.145:9092
      Exception in thread "main" kafka.admin.AdminOperationException: Replica election data is empty
      at kafka.admin.LeaderElectionCommand$.parseReplicaElectionData(LeaderElectionCommand.scala:115)
      at kafka.admin.LeaderElectionCommand$.$anonfun$run$1(LeaderElectionCommand.scala:56)
      at kafka.admin.LeaderElectionCommand$.run(LeaderElectionCommand.scala:55)
      at kafka.admin.LeaderElectionCommand$.main(LeaderElectionCommand.scala:41)
      at kafka.admin.LeaderElectionCommand.main(LeaderElectionCommand.scala)
      

      重分区也没行。 有没有办法删除这个分区?

        • 今天我找了个工具一看所有topic的信息都缺胳膊少腿(都是少了某个分区),我将broker编号从1,2,3 恢复到0,1,2,然后从kafkatool看到每个topic的分区数显示是正常了。 有没什么方法查看当前kafka集群topic和broker的健康状态?topic健康的话只能一个个查看分区信息?

            • [2020-11-20T11:35:17,800][INFO ][org.apache.kafka.clients.consumer.internals.AbstractCoordinator] [Consumer clientId=kafka-nginx-access-dev01-0, groupId=kafka-nginx-access-dev] Group coordinator 192.168.10.145:9092 (id: 2147483646 rack: null) is unavailable or invalid, will attempt rediscovery
              [2020-11-20T11:35:17,802][INFO ][org.apache.kafka.clients.consumer.internals.AbstractCoordinator] [Consumer clientId=kafka-nginx-access-dev01-1, groupId=kafka-nginx-access-dev] Group coordinator 192.168.10.145:9092 (id: 2147483646 rack: null) is unavailable or invalid, will attempt rediscovery
              [2020-11-20T11:35:17,803][INFO ][org.apache.kafka.clients.consumer.internals.AbstractCoordinator] [Consumer clientId=kafka-nginx-error01-3, groupId=kafka-nginx-error] Group coordinator 192.168.10.145:9092 (id: 2147483646 rack: null) is unavailable or invalid, will attempt rediscovery
              [2020-11-20T11:35:17,803][INFO ][org.apache.kafka.clients.consumer.internals.AbstractCoordinator] [Consumer clientId=kafka-nginx-error01-1, groupId=kafka-nginx-error] Group coordinator 192.168.10.145:9092 (id: 2147483646 rack: null) is unavailable or invalid, will attempt rediscovery
              [2020-11-20T11:35:17,803][INFO ][org.apache.kafka.clients.consumer.internals.AbstractCoordinator] [Consumer clientId=kafka-nginx-access-dev01-3, groupId=kafka-nginx-access-dev] Group coordinator 192.168.10.145:9092 (id: 2147483646 rack: null) is unavailable or invalid, will attempt rediscovery
              

              我截一段logstash的日志

                • 我已经恢复集群了。

                  原先broker.id改了,部分topic无法显示丢失的broker分区。我将broker.id 改回去,然后重启zookeeper(因为里面保存broker信息),但是前面这个过程产生的数据都丢了。

                    • ./kafka-topics.sh --zookeeper localhost:2181 --describe --topic IIoT
                      

                      这里看到的。

                      broker.id是kafka集群识别每个节点的身份标识,如果身份是错的,那数据是错乱的(如分区交集),不可逆。