Kafka Zookeeper 基本命令示例


 

Kafka

 

新建Topic

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

 

查看已存在Topic列表

bin/kafka-topics.sh --list --zookeeper localhost:2181

 

查看指定Topic狀態

bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic my-topic

 


啟動Consumer讀取消息並輸出到標准輸出

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

 


運行Producer並將Terminal輸入的消息發送到服務端

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

<< This is a messageThis is another message

 

 

性能測試

bin/kafka-producer-perf-test.sh --messages 500000 --message-size 1000 --batch-size 500 --topics test --threads 2 --broker-list localhost:9092

bin/kafka-consumer-perf-test.sh --zookeeper localhost:2181 --messages 500000 --topic test --threads 1

 

 

 

Zookeeper

啟動ZK服務

bin/zkServer.sh start

 

查看ZK服務狀態

bin/zkServer.sh status

 

停止ZK服務

bin/zkServer.sh stop

 

重啟ZK服務

bin/zkServer.sh restart

 

連接服務器

bin/zkCli.sh -server 127.0.0.1:2181

 

查看根目錄

ls /


創建 testnode節點

create /zk/testnode "test"

 

查看節點內容

get /zk/testnode


設置節點內容

set /zk/testnode test

 

刪除節點

delete /zk/testnode

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM