记一次由于__consumer_offset导致的Kafka故障

记一次Kafka故障


2018.05.30
Kafka 0.10.0.10

背景介绍

因Kafka集群中一个节点宕机,因集群高可用机制集群工作正常,但是发现部分消费者无法读取到数据

故障原因

Kafka将直连Kafka的消费信息记录到了__consumer_offset这个topic中,这个topic在我们的集群中复制因子为1,并且所有的Partition落在了宕机的节点上,导致这个topic信息丢失,消费偏移量记录在这个topic中的消费者无法获取以及记录信息。

如何避免

Kafka Broker Config中针对这个offset topic有两个相关的配置

name default
offsets.topic.replication.factor 3
offsets.topic.num.partitions 50

其中对offsets.topic.replication.factor的解释是:

The replication factor for the offsets topic (set higher to ensure availability). To ensure that the effective replication factor of the offsets topic is the configured value, the number of alive brokers has to be at least the replication factor at the time of the first request for the offsets topic. If not, either the offsets topic creation will fail or it will get a replication factor of min(alive brokers, configured replication factor)

意为记录偏移量的topic默认的复制因子是3,为了保证这个配置生效,需要确保在第一个消费者到来的时候集群中至少有与复制因子相同个数的节点数。否则,这个topic可能会创建失败,或者取存活节点数与配置复制因子的最小值

0.11.X之后的版本对这个参数的解释变成了:

The replication factor for the offsets topic (set higher to ensure availability). Internal topic creation will fail until the cluster size meets this replication factor requirement.

意为仅当集群节点个数大于等于配置的复制因子个数时,topic才能创建成功

猜你喜欢

转载自blog.csdn.net/huochen1994/article/details/80511038
今日推荐