kafka常用命令

以下是kafka常用命令行總結:


1.查看topic的詳細信息

./kafka-topics.sh -zookeeper 127.0.0.1:2181 -describe -topic testKJ1


2、爲topic增加副本

./kafka-reassign-partitions.sh -zookeeper 127.0.0.1:2181 -reassignment-json-file json/partitions-to-move.json -execute


3、創建topic

./kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic testKJ1


4、爲topic增加partition

./bin/kafka-topics.sh –zookeeper 127.0.0.1:2181 –alter –partitions 20 –topic testKJ1


5、kafka生產者客戶端命令

./kafka-console-producer.sh --broker-list localhost:9092 --topic testKJ1


6、kafka消費者客戶端命令

./kafka-console-consumer.sh -zookeeper localhost:2181 --from-beginning --topic testKJ1


7、kafka服務啓動

./kafka-server-start.sh -daemon ../config/server.properties 


8、下線broker

./kafka-run-class.sh kafka.admin.ShutdownBroker --zookeeper 127.0.0.1:2181 --broker #brokerId# --num.retries 3 --retry.interval.ms 60

shutdown broker


9、刪除topic

./kafka-run-class.sh kafka.admin.DeleteTopicCommand --topic testKJ1 --zookeeper 127.0.0.1:2181


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章