kafka集群下线broker节点实践方法(broker topic 迁移)

[root@es03 ~]# cd /usr/hdp/2.6.4.0-91/kafka/bin
[root@es03 kafka]# cd bi
-bash: cd: bi: No such file or directory
[root@es03 kafka]# cd bin
[root@es03 bin]# ./kafka-topics.sh --describe --zookeeper 192.168.50.101:2181 --topic XcyEntity
Topic:testXcyTopic      PartitionCount:2        ReplicationFactor:1     Configs:Topic:testXcyTopic      PartitionCount:2ReplicationFactor:1      Configs:
        Topic: testXcyTopic     Partition: 0    Leader: 1001    Replicas: 1001  Isr: 1001
        Topic: testXcyTopic     Partition: 1    Leader: 1003    Replicas: 1003  Isr: 1003
[root@es03 bin]# ./kafka-reassign-partitions.sh --zookeeper 192.168.50.101:2181 --topics-to-move-json-file /root/topics-to-move.json --broker-list "1003,1004" --generate
Current partition replica assignment

{"version":1,"partitions":[{"topic":"testXcyTopic","partition":1,"replicas":[1003]},{"topic":"testXcyTopic","partition":0,"replicas":[1001]}]}
Proposed partition reassignment configuration

{"version":1,"partitions":[{"topic":"testXcyTopic","partition":1,"replicas":[1003]},{"topic":"testXcyTopic","partition":0,"replicas":[1004]}]}
[root@es03 bin]# vi /root/reassignment-node.json 
{"version":1,"partitions":[{"topic":"testXcyTopic","partition":1,"replicas":[1003]},{"topic":"testXcyTopic","partition":0,"replicas":[1004]}]}
~



[root@es03 bin]# ./kafka-reassign-partitions.sh --zookeeper 192.168.50.101:2181 --reassignment-json-file /root/reassignment-node.json  --execute
Current partition replica assignment

{"version":1,"partitions":[{"topic":"testXcyTopic","partition":1,"replicas":[1003]},{"topic":"testXcyTopic","partition":0,"replicas":[1001]}]}

Save this to use as the --reassignment-json-file option during rollback
Successfully started reassignment of partitions.
[root@es03 bin]# ./kafka-reassign-partitions.sh --zookeeper 192.168.50.101:2181 --reassignment-json-file /root/reassignment-node.json  --verify
Status of partition reassignment: 
Reassignment of partition [testXcyTopic,1] completed successfully
Reassignment of partition [testXcyTopic,0] completed successfully
[root@es03 bin]# ./kafka-topics.sh --describe --zookeeper 192.168.50.101:2181 --topic XcyEntity
Topic:testXcyTopic      PartitionCount:2        ReplicationFactor:1     Configs:
        Topic: testXcyTopic     Partition: 0    Leader: 1004    Replicas: 1004  Isr: 1004
        Topic: testXcyTopic     Partition: 1    Leader: 1003    Replicas: 1003  Isr: 1003
[root@es03 bin]# timed out waiting for input: auto-logout

 

posted @ 2019-02-22 09:25  大漠之烟  阅读(2341)  评论(0编辑  收藏  举报