基於0.8.0版本。
bin/kafka-list-topic.sh --zookeeper 192.168.197.170:2181,192.168.197.171:2181
(列出所有topic的分割槽情況)
bin/kafka-list-topic.sh --zookeeper 192.168.197.170:2181,192.168.197.171:2181 --topic test (檢視test的分割槽情況)
其實kafka-list-topic.sh裡面就一句
exec $(dirname $0)/kafka-run-class.sh kafka.admin.listtopiccommand $@實際是通過
kafka-run-class.sh指令碼執行的包kafka.admin下面的類
bin/kafka-create-topic.sh
--replica 2 --partition 8 --topic test
--zookeeper
192.168.197.170:2181,192.168.197.171:2181
建立名為test的topic, 8個分割槽分別存放資料,資料備份總共2份
bin/kafka-create-topic.sh
--replica 1 --partition 1 --topic test2
--zookeeper
192.168.197.170:2181,192.168.197.171:2181
結果 topic: test2 partition: 0 leader: 170 replicas: 170 isr: 170
這個命令可以分割槽指定到想要的--broker-list上
bin/kafka-reassign-partitions.sh --topics-to-move-json-file topics-to-move.json --broker-list "171" --zookeeper 192.168.197.170:2181,192.168.197.171:2181 --execute
cat topic-to-move.json ],
"version":1 }
bin/kafka-add-partitions.sh --topic test --partition 2 --zookeeper
192.168.197.170:2181,192.168.197.171:2181 (為topic test增加2個分割槽)
bin/kafka-console-consumer.sh --zookeeper
192.168.197.170:2181,192.168.197.171:2181 --from-beginning --topic test
bin/kafka-console-producer.sh --broker-list 192.168.197.170:9092,192.168.197.171: 9092 --topic test
bin/kafka-preferred-replica-election.sh --zookeeper
192.168.197.170:2181,192.168.197.171:2181--path-to-json-file preferred-click.json
cat preferred-click
.json,,
,,,,
,,,,,
,,,,
]}
bin/kafka-run-class.sh kafka.admin.deletetopiccommand --topic test666 --zookeeper 192.168.197.170:2181 ,192.168.197.171:2181
kafka 命令列工具常用命令行操作
2.check命令 1.1 啟動kafka服務 zookeeper.connect zookeeper連線設定ip port broker.id 啟動kafka的broker的id 1.2 建立topicbin kafka topics.sh create zookeeper host 2181 r...
Kafka常用命令行總結
以下是kafka常用命令行總結 1.檢視topic的詳細資訊 kafka topics.sh zookeeper 127.0.0.1 2181 describe topic testkj1 2 為topic增加副本 kafka reassign partitions.sh zookeeper 127...
Kafka常用命令行總結
以下是kafka常用命令行總結 1.檢視topic的詳細資訊 kafka topics.sh zookeeper 127.0.0.1 2181 describe topic testkj1 檢視所有topic kafka topics.sh list zookeeper 127.0.0.1 2181...