美文网首页数客联盟
Kafka-client 0.10.0 API问题

Kafka-client 0.10.0 API问题

作者: Woople | 来源:发表于2017-11-22 14:06 被阅读153次

    注:本文涉及到的环境版本为kafka 0.10.0
    在使用kafka 0.10.0 API获取consumer offset的时候,遇到卡住的问题,类似KAFKA-3296-All consumer reads hang indefinately

    分析步骤


    • 打开debug日志,可以看到下面这样的日志内容
    responseBody={error_code=15,coordinator={node_id=-1,host=,port=-1}}
    
    • 运行kafka-topics.sh --describe --zookeeper localhost: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: -1    Replicas: 1003,1004,1007        Isr: 
            Topic: __consumer_offsets       Partition: 1    Leader: 1005    Replicas: 1005        Isr: 1005
            Topic: __consumer_offsets       Partition: 2    Leader: 1005    Replicas: 1005        Isr: 1005
            Topic: __consumer_offsets       Partition: 3    Leader: 1001    Replicas: 1001        Isr: 1001,1003,1002
            Topic: __consumer_offsets       Partition: 4    Leader: 1002    Replicas: 1002,1001,1003        Isr: 1001
            Topic: __consumer_offsets       Partition: 5    Leader: -1    Replicas: 1002,1007,1008        Isr: 
            Topic: __consumer_offsets       Partition: 6    Leader: -1    Replicas: 1003,1008,1009        Isr:       
    

    可以看到有很多partition已经没有leader。

    解决方法


    1. 停止kafka集群

    2. 在zk上删除/brokers/topics/__consumer_offsets

    3. 启动kafka集群

    4. 启动应用程序

    5. 在通过kafka-topics.sh --describe命令可以看到__consumer_offsets的所有leader已经正常

    相关文章

      网友评论

      • biggeng:今天也遇到相同的问题 多谢博主的经验总结:+1:

      本文标题:Kafka-client 0.10.0 API问题

      本文链接:https://www.haomeiwen.com/subject/lnbnvxtx.html