前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Kafka学习笔记之kafka.common.KafkaException: Should not set log end offset on partition

Kafka学习笔记之kafka.common.KafkaException: Should not set log end offset on partition

作者头像
Jetpropelledsnake21
发布2020-12-25 10:17:19
4470
发布2020-12-25 10:17:19
举报
文章被收录于专栏:JetpropelledSnakeJetpropelledSnake

0x00 概述

kafka单台机器做集群操作是没有问题的,如果分布多台机器并且partitions或者备份的个数大于1都会报kafka.common.KafkaException: Should not set log end offset on partition 这个错误,如果使用kafka默认的日志等级,过不了几分钟错误日志就会把磁盘刷满,导致服务器down掉。

0x01 问题排查

这个问题困扰了我几天,怎么搞都不行,开始以为是版本问题,升级到最新版本问题还是存在,后来在官方FQA中找到了一段描述,原文如下:

代码语言:javascript
复制
Why do I see error "Should not set log end offset on partition" in the broker log?
Typically, you will see errors like the following.

kafka.common.KafkaException: Should not set log end offset on partition [test,22]'s local replica 4

ERROR [ReplicaFetcherThread-0-6], Error for partition [test,22] to broker 6:class kafka.common.UnknownException(kafka.server.ReplicaFetcherThread)

A common problem is that more than one broker registered the same host/port in Zookeeper. As a result, the replica fetcher is confused when fetching data from the leader. 
To verify that, you can use a Zookeeper client shell to list the registration info of each broker. 
The Zookeeper path and the format of the broker registration is described in Kafka data structures in Zookeeper. 
You want to make sure that all the registered brokers have unique host/port.

这段内容的大意思是不允许在zookeeper上注册来自同一个主机+端口的brokers,开始我以为是同一台机器上挂了二个brokers的缘故,因为机器上我同时布署了solr与kafka,都用的同一个zookeeper服务,于是我把kafka的broker改成/chroot的方式,在zookeeper上加了一级节点:(原来的brokers写法:192.168.12.206:2181,192.168.12.208:2181,改为:192.168.12.206:2181,192.168.12.208:2181/kafka) 经测试还是一样的结果,我实在是没撤了,最后我又仔细看了一下错误日志,发现一个规律,都是在分区备份的时候发生的此错误,所以我就在想是不是服务器之间数据同步有问题。

接着我打开kafka的配置文件,逐一往下看,发现了host.name属性,我心中已经有一半相信是这个参数配置的问题,因为我没有启动这个参数,于是我把它改成实际的IP地址,如host.name=192.168.12.206,另一台也如是改,最后发现错误不报了,收发消息正常,于是我知道这个参数在默认不配置的时候,绑定的是当前主机127.0.0.1,所以集群中主机之间进行相互备份的时候通过127.0.0.1找不到主机了。

有二个方面的原因导致一直查不出问题,一是网上关于此问题的说明实在是少的可怜,有也都是千篇一律,查到的结果都一样,

另一个原因是配置文件的注释让人误解,如host.name的注释:

# Hostname the broker will bind to. If not set, the server will bind to all interfaces

从字面意思理解不就是“如果不设置,服务器将绑定到所有接口”,所以我想应该不设置也不会有问题。

0x02 参考

原文

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2020-12-23 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 0x00 概述
  • 0x01 问题排查
  • 0x02 参考
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档