#获取kafka主题列表 /data01/server/kafka/bin/kafka-topics.sh --zookeeper offline-op-kafka-ali-01:2181 --list > topics.txt #通过py脚本格式化一下主题列表,生成topics.json import json obj = {} obj["version"] = 1 obj["topics"] = [] with open("topics.txt") as f: for line in f.readlines(): topic = {"topic": line.strip()} obj["topics"].append(topic) with open("topics.json", "w") as f: json.dump(obj, f, indent=2) #获取当前 partition 分配方案 kafka-reassign-partitions.sh --zookeeper offline-op-kafka-ksyun-01:2181 --topics-to-move-json-file topics.json --broker-list "1,2,3" --generate > current.json /data01/server/kafka/bin/kafka-reassign-partitions.sh --zookeeper offline-op-kafka-ali-01:2181 --topics-to-move-json-file topics.json --broker-list "1,2,3" --generate > current.json #执行 kafka-reassign-partitions.sh --zookeeper offline-op-kafka-ksyun-01:2181 --reassignment-json-file current.json --execute kafka-reassign-partitions.sh --zookeeper offline-op-kafka-ali-01:2181 --reassignment-json-file current.json --execute #验证,为空代表迁移完成! ./kafka-reassign-partitions.sh --zookeeper offline-op-kafka-ksyun-01:2181 --reassignment-json-file current.json --verify | grep -v successsfully kafka-reassign-partitions.sh --zookeeper offline-op-kafka-ali-01:2181 --reassignment-json-file current.json --verify | grep -v successsfully #查看isr ./kafka-topics.sh --describe --zookeeper offline-op-kafka-ksyun-01:2181 --topic server-practice-laravel-php-log #有哪些用户组来消费 ./kafka-consumer-groups.sh --bootstrap-server offline-op-kafka-ksyun-01:9092 --list #查看用户组消费情况 ./kafka-consumer-groups.sh --bootstrap-server offline-op-kafka-ksyun-01:9092 --describe --group opentsdb-logstash
标签:缩容,01,--,topics,kafka,json,集群,offline From: https://www.cnblogs.com/fengzi7314/p/16992031.html