kafka 常用命令說明
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
##重新分配分割槽 kafka-reassign-partitions.sh
這個命令可以分割槽指定到想要的--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
{"topics":[{"topic": "test2"}],
"version":1
}##為Topic增加 partition數目
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