简体   繁体   English

代理失败后Kafka 0.10.0.1分区重新分配

[英]Kafka 0.10.0.1 partition reassignment after broker failure

I'm testing kafka's partition reassignment as a precursor to launching a production system. 我正在测试kafka的分区重新分配,作为启动生产系统的先驱。 I have several topics with 9 partitions each and a replication factor of 3. I've killed one of the brokers to simulate a failure condition and verified that some topics became under replicated (verification done via a fork of yahoo's kafka manager modified to allow adding a version 0.10.0.1 cluster). 我有几个主题,每个分区有9个分区,复制因子为3.我已经杀死了其中一个代理来模拟失败情况,并验证某些主题被复制(通过yahoo的kafka管理器修改后验证允许添加版本0.10.0.1群集)。

I then started a new broker with a different id. 然后我开始了一个具有不同身份的新经纪人。 I would now like to distribute partitions to this new broker. 我现在想将分区分发给这个新的代理。 I attempted to use kafka manager's reassign partitions functionality however that did not work (possibly due to an improperly modified fork). 我试图使用kafka管理器的重新分配功能但是这不起作用(可能是由于未正确修改的fork)。

I saw that kafka comes with a bin/kafka-reassign-partitions.sh script but the docs say that I have to manually write out the partition reassignments for each topic in json format. 我看到kafka附带了bin/kafka-reassign-partitions.sh脚本,但是文档说我必须手动为json格式的每个主题写出分区重新分配。 Is there a way to handle this without manually deciding on which brokers partitions must go? 有没有办法处理这个没有手动决定哪个经纪人分区必须去?

Hmm what a coincidence that I was doing exactly the same thing today. 嗯,今天我做同样的事情真是巧合。 I don't have an answer you're probably going to like but I achieved what I wanted in the end. 我没有你想要的答案,但我最终实现了我想要的。

Ultimately, what I did was executed the kafka-reassign-partitions command with what the same tool proposed for a reassignment. 最后,我所做的是执行kafka-reassign-partitions命令,并使用相同的工具进行重新分配。 But whatever it generated I just replaced the new broker id with the old failed broker id. 但无论它生成什么,我只是用旧的失败的经纪人ID替换了新的经纪人ID。 For some reason the generated json moved everything around. 出于某种原因,生成的json移动了一切。

This will fail (or rather never complete) because the old broker has passed on. 这将失败(或者说永远不会完成)因为旧经纪人已经过世了。 I then had to delete the reassignment operation in zookeeper (znode: admin/reassign_partitions or something). 然后我不得不删除zookeeper中的重新分配操作(znode:admin / reassign_partitions或其他东西)。

Then I restarted kafka on the new broker and it magically picked up as leader of the partition that was looking for a new replacement leader. 然后我重新启动了新经纪人的kafka,它神奇地成为了寻找新的替代领导者的分区的领导者。

I'll let you know if everything is still working tomorrow and if I still have a job ;-) 我会告诉你,如果一切都在明天仍在工作,如果我还有工作;-)

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

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