2017-08-01 55 views
1

除去經紀人我有以下副本分區:卡夫卡:如何從副本集

Topic: topicname Partition: 10 Leader: 1 Replicas: 1,2,4,3 Isr: 1,2,3 

哪裏副本4是不存在的經紀人。我意外地將此經紀人添加到副本集中作爲錯字。

我想從副本集中刪除4個。但運行kafka-reassign-partitions.sh後,重新分配以刪除副本#4永遠不會結束。

kafka-reassign-partitions.sh --zookeeper myzookeeperhost:2181 --reassignment-json-file remove4.txt --execute 

凡remove4.txt看起來像

{ "partitions": [ 
    { "topic": "topicname", "partition": 2, "replicas": [1,2,3] } 
], "version": 1 } 

重新分配被套牢:

kafka-reassign-partitions.sh --zookeeper myzookeeperhost:2181 --reassignment-json-file remove4.txt --verify 
Status of partition reassignment: 
Reassignment of partition [topicname,10] is still in progress 

我檢查控制器日誌,它看起來像重配命令接走,但沒有之後發生:

[2017-08-01 06:46:07,653] DEBUG [PartitionsReassignedListener on 101 (the controller broker)]: Partitions reassigned listener fired for path /admin/reassign_partitions. Record partitions to be reassigned {"version":1,"partitions":[{"topic":"topicname","partition":10,"replicas":[1,2,3]}]} (kafka.controller.PartitionsReassignedListener) 

關於我在做什麼的任何想法都是錯誤的?如何從副本集中刪除代理#4? 更新:我正在運行kafka 10

回答

1

我能夠解決這個問題,通過添加一個與新增的代理(您的案例4)相匹配的代理id來解決這個問題。

Kafka Quickstart指南向您介紹如何創建具有特定ID的代理。一旦你有你的節點了ID 4,運行:

./bin/kafka-topics.sh --zookeeper localhost:2181 --topic badbrokertest --describe 

您應該看到所有副本都在ISR柱像這樣:

Topic:badbrokertest PartitionCount:3 ReplicationFactor:3 Configs: 
Topic: badbrokertest Partition: 0 Leader: 1 Replicas: 1,2,3 Isr: 1,2,3 
Topic: badbrokertest Partition: 1 Leader: 1 Replicas: 1,2,3 Isr: 1,2,3 
Topic: badbrokertest Partition: 2 Leader: 1 Replicas: 1,2,3,4 Isr: 1,2,3,4 

現在,您可以重新分配你的分區!

./bin/kafka-reassign-partitions.sh --reassignment-json-file badbroker2.json --zookeeper localhost:2181 

凡badbroker2.json樣子:

{ 
    "version":1, 
    "partitions":[ 
     {"topic":"badbrokertest","partition":0,"replicas":[1,2,3]}, 
     {"topic":"badbrokertest","partition":1,"replicas":[1,2,3]}, 
     {"topic":"badbrokertest","partition":2,"replicas":[1,2,3]} 
    ] 
} 

因此,在短期,一旦你通過添加缺少經紀人同步時間所有的副本,你可以刪除不需要經紀人。

如果您正在使用多臺服務器,請務必在配置中設置偵聽器字段,以使您的臨時經紀人可供其他經紀人使用。快速入門指南不考慮這種情況。

listeners=PLAINTEXT://10.9.1.42:9093 
+1

謝謝尼克! 我也用不存在的副本跟隨者旋轉實例來解決我的問題。不幸的是,我們必須這樣做,而不是Kafka能夠移除顯然不在羣集中的主機(未在zookeeper中註冊)。 – pl0u