迁移前:
image.png
编辑json文件:vi topics-to-move.json
{"topics": [{"topic": "test-reassign"}],"version":1}
执行语句
bin/kafka-reassign-partitions.sh --zookeeper node1:2181,node2:2181,node3:2181 --topics-to-move-json-file topics-to-move.json --broker-list "1,2" --generate
image.png
编辑json文件: vi expand-cluster-reassignment.json
{"version":1,"partitions":[{"topic":"test-reassign","partition":1,"replicas":[2,1],"log_dirs":["any","any"]},{"topic":"test-reassign","partition":0,"replicas":[1,2],"log_dirs":["any","any"]},{"topic":"test-reassign","partition":2,"replicas":[1,2],"log_dirs":["any","any"]}]}
执行成功:
bin/kafka-reassign-partitions.sh --zookeeper node1:2181,node2:2181,node3:2181 --reassignment-json-file expand-cluster-reassignment.json --execute
image.png
bin/kafka-reassign-partitions.sh --zookeeper node1:2181,node2:2181,node3:2181 --reassignment-json-file expand-cluster-reassignment.json --verify
image.png
对比:
image.png
实际物理位置:
node1 节点没有test-reassign分区和副本 node1和node2都有
image.png
image.png
image.png
网友评论