简体   繁体   English

在 Kafka 中,如何将 min.insync.replicas=1 设置为 __consumer_offsets_ 主题?

[英]In Kafka, How could I set min.insync.replicas=1 to __consumer_offsets_ topics?

I have one Kafka broker.我有一位卡夫卡经纪人。

My server.properties is as follows:我的 server.properties 如下:

offsets.topic.replication.factor=3
default.replication.factor=3
min.insync.replicas=3

And I created a topic just for test:我创建了一个主题只是为了测试:

sh kafka-topics.sh --bootstrap-server localhost:9092 --topic test --create replication-factor 1 --config min.insync.replicas=1

The topic is created well.主题创建得很好。 It describes as follows:它描述如下:

Topic: test PartitionCount: 8 ReplicationFactor: 1 Configs: min.insync.replicas=1, segment.bytes=10...
Topic: test Partition: 0 Leader: 1 Replicas: 1 Isr: 1
....

When my console consumer starts working, the following error occurs:当我的控制台使用者开始工作时,出现以下错误:

org.apache.kafka.common.errors.NotEnoughReplicasException: The size of the current ISR Set(1) is insufficient to satisfy the min.isr requirement of 3 for partition __ consumer_offsets-1

As I understand, I set the min.insync.replicas to 1, but it affects only data topics, not _ consumer_offsets topics.据我所知,我设置了min.insync.replicas 1,但它仅影响数据的话题,不是_ consumer_offsets主题。 So _ consumer_offsets still needs 3 replicas as my server.properties has min.insync.replicase=3 setting.所以 _ consumer_offsets仍然需要 3 个副本,因为我的 server.properties 有 min.insync.replicase=3 设置。

Is my understanding correct??我的理解对吗?? if so, is there a way to set __consumer_offsets topics' min.insync.replicas in command line topic creation?如果是这样,有没有办法在命令行主题创建中设置 __consumer_offsets 主题的 min.insync.replicas ?

"Is my understanding correct??" “我的理解对吗??”

Yes, your understanding is correct.是的,你的理解是正确的。 The configuration min.insync.replicas can be set when creating a topic.创建主题时可以设置配置min.insync.replicas If you do not specify this configuration it will be set based on the broker-wide configuration min.insync.replicas that is provided in the server.properties .如果您不指定此配置,它将根据server.properties提供的代理范围配置min.insync.replicas进行设置。

"if so, is there a way to set __consumer_offsets topics' min.insync.replicas in command line topic creation?" “如果是这样,有没有办法在命令行主题创建中设置 __consumer_offsets 主题的 min.insync.replicas?”

As the topic __consumer_offsets is an internal topic and it will be created automatically, the broker-wide defaults are being used.由于主题__consumer_offsets是一个内部主题,它将自动创建,因此正在使用代理范围的默认值。 In your case you would need to change the configuration in your server.properties file:在您的情况下,您需要更改server.properties文件中的配置:

min.insync.replicas=1

As I understand, you only have one broker in your cluster.据我了解,您的集群中只有一个代理。 So having default setting of 3 for the configurations offsets.topic.replication.factor , default.replication.factor , and min.insync.replicas will cause issues (like you have seen) for topics that rely on those broker-wide settings.因此,具有默认设置3的配置offsets.topic.replication.factordefault.replication.factormin.insync.replicas会导致一些问题(如你所看到的),对于依赖于那些代理范围的设置主题。


Please do not change these setting on a production cluster without really knowing the impacts.请没有真正知道影响改变生产群集上的这些设置。 It will have an impact on the durability of your data and your ConsumerGroups and there is a good reason why the defaults are set to 3 .它会对您的数据和 ConsumerGroups 的持久性产生影响,并且将默认值设置为3是有充分理由的。

if your min isr configuration not taking effect, here is the solution:如果您的最小 isr 配置未生效,则解决方法如下:

Note: operation below will remove all the kafka data, this solution is purely for changing the isr settings of internal topics that have already been created, you should never do it when this data cleanup operation doesn't fit into your scenario注意:下面的操作会删除所有的kafka数据,这个方案纯粹是为了改变已经创建的内部topic的isr设置,当这个数据清理操作不适合你的场景时,你千万不要这样做

every time you want to change replica factor and min isr, don't forgot to clear the internal topics first:每次要更改副本因子和最小 isr 时,不要忘记先清除内部主题:

rm -rf kafka/kafka-logs/*
rm -rf kafka/logs/*
rm -rf zookeeper/zkdata/version-2/* 
rm -rf zookeeper/logs/version-2/*

you can confirm whether your config working by describe all the topics including the internal topics:您可以通过描述包括内部主题在内的所有主题来确认您的配置是否有效:

topics=(`./kafka-topics.sh --list --zookeeper $ZK_SERVER | grep -v grep  | awk '{print $1}'`)                                                                                         
for topic in ${topics[@]}
do
./kafka-topics.sh --describe --bootstrap-server $BOOTS_STRAP_SERVER --topic $topic
done

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM