kafka异常问题汇总

1、报错:: java.util.concurrent.ExecutionException: org.apache.kafka.common.errors.NotLeaderForPartitionException: This server is not the leader for that topic-partition.

 报错原因:producer在向kafka broker写的时候,刚好发生选举,本来是向broker0上写的,选举之后broker1成为leader,所以无法写成功,就抛异常了。

 解决办法:修改producer的重试参数retries参数,默认是0,  一般设置为3, 我在生产环境配置的retries=10

 

2、java.util.concurrent.ExecutionException: org.apache.kafka.common.errors.TimeoutException: Expiring 1 record(s) for binlogCsbbroker-2 due to 30026 ms has passed since batch creation plus linger time

  报错原因:具体原因我自己还没有找到,但是网友们都说是因为kafka在批量写的时候,这一批次的数据没有在30s内还处理完,(30s为request.timeout.ms默认值),这一批次的数据就过期了,所以抛出异常

  解决办法:增大request.timeout.ms, 我在生产环境配置的是request.timeout.ms=60000  // 由原来默认的30s改成60s

 

3、java.util.concurrent.ExecutionException: org.apache.kafka.common.errors.NetworkException: The server disconnected before a response was received.

  报错原因:kafka client与broker断开连接了

  解决办法:重启服务

 

4、

你可能感兴趣的:(kafka异常问题汇总)