4. kafka调整分区

调整分区

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

./bin/kafka-topics.sh --partitions 3 --replication-factor 2 --alter --topic MCR_LOG_TEST --zookeeper localhost:2181

迁移数据

新建一个

$ cat topic.json

{

"topics": [

{"topic": "MCR_LOG_PROD"}

],

"version": 1

}

迁移计划

./bin/kafka-reassign-partitions.sh --zookeeper localhost:2181 --topics-to-move-json-file topic.json --broker-list "0,1,2" --generate

将Proposed partition reassignment configuration保存到文件

cat reassignment.json

{"version":1,"partitions":[{"topic":"MCR_LOG_PROD","partition":0,"replicas":[2],"log_dirs":["any"]},{"topic":"MCR_LOG_PROD","partition":2,"replicas":[1],"log_dirs":["any"]},{"topic":"MCR_LOG_PROD","partition":1,"replicas":[0],"log_dirs":["any"]}]}

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

你可能感兴趣的:(4. kafka调整分区)