创建kafka的topic:
./bin/kafka-topics.sh --create --zookeeper 192.168.70.212:2181,192.168.70.213:2181,192.168.70.214:2181 --replication-factor 3 --partitions 3 --topic test01
列举kafka的topic:
./bin/kafka-topics.sh --zookeeper 192.168.70.212:2181,192.168.70.213:2181,192.168.70.214:2181 --list
kafka 修改topic分区数据:
./bin/kafka-topics.sh --zookeeper
192.168.70.212:2181,192.168.70.213:2181,192.168.70.214:2181 -alter --partitions 3 --topic test01
数据均衡:
vi sjzn_spark_binlog_order_topic.json
生成主题分配方案:
./bin/kafka-reassign-partitions.sh --zookeeper
192.168.70.212:2181,192.168.70.213:2181,192.168.70.214:2181 --topics-to-move-json-file sjzn_spark_binlog_order_topic.json --broker-list "0,1,2" --generate Current partition replica assignment
拷贝分配方案到新的json文件中
vi expand-cluster-reassignment.json
执行分配:
./bin/kafka-reassign-partitions.sh --zookeeper
192.168.70.212:2181,192.168.70.213:2181,192.168.70.214:2181 --reassignment-json-file expand-cluster-reassignment.json --execute Current partition replica assignment
查看分区状态:
./bin/kafka-reassign-partitions.sh --zookeeper
192.168.70.212:2181,192.168.70.213:2181,192.168.70.214:2181 --reassignment-json-file expand-cluster-reassignment.json --verify
单独查看topic分区状态:
./bin/kafka-topics.sh --describe --zookeeper 192.168.70.212:2181,192.168.70.213:2181,192.168.70.214:2181 --topic dwd_all_metric