zoukankan      html  css  js  c++  java
  • kafka一个broker挂掉无法写入

    Kafka日志:

    broker 133 received LeaderAndIsrRequest with correlation id 1 from controller 132 epoch 35 fro partition [__consumer_offsets,13] but cannot become follower since the new leader -1 is unavailable

     

    this server is not the leader for that topic-partition

     

    对于broker 133 received LeaderAndIsrRequest with correlation id 1 from controller 132 epoch 35 fro partition [__consumer_offsets,13] but cannot become follower since the new leader -1 is unavailable

    错误是因为

     

    因其中一个broker挂掉无法获取leaderbrokerid

    3broker中的其中一个挂掉,是可以将数据写入另外两个broker的。至于没有写入另外两个broker报错org.apache.kafka.common.errors.NotLeaderForPartition可能是因为可能我们的producer端的代码里没加 reties 参数,默认就发送一次,遇到leader选举时,找不到leader就会发送失败,造成程序停止

    解决办法

    producer端加上参数 reties=3, 重试发送三次(默认100ms重试一次 由 retry.backoff.ms控制);
    如果还需要保证消息发送的有序性,记得加上参数 max.in.flight.requests.per.connection = 1 限制客户端在单个连接上能够发送的未响应请求的个数,设置此值是1表示kafka broker在响应请求之前client不能再向同一个broker发送请求。(注意:设置此参数是为了满足必须顺序消费的场景,比如binlog数据)

  • 相关阅读:
    nginx-rtmp-module搭建流媒体服务器
    rabbitmq安装
    opencv+python (3)
    linux命令
    mysql语句概览
    BUUCTF V&N-misc内存取证
    2018 HEBTUCTF 部分misc
    2020 安恒2月月赛 misc
    2018.6.1 铁三数据赛 复现
    2020 i春秋新春战疫公益赛 misc
  • 原文地址:https://www.cnblogs.com/nshuai/p/11497503.html
Copyright © 2011-2022 走看看