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数据)

  • 相关阅读:
    MySQL行级锁、表级锁、页级锁详细介绍
    Spring REST是什么?(转)
    Spring REST(转)
    联系人项目
    三级联动(有刷新)
    Java中点击按钮返回上一页
    Java中隐藏显示效果
    理解RESTful架构(转)
    什么是REST?以及RESTful的实现(转)
    JSTL 核心标签库 使用(转)
  • 原文地址:https://www.cnblogs.com/nshuai/p/11497503.html
Copyright © 2011-2022 走看看