1、查看kafka隊列中topic信息
1.1、查看所有topic
./kafka-topics.sh --zookeeper 10.128.106.52:2181 --list
1.2、查看kafka中指定topic的詳情
./kafka-topics.sh --zookeeper 10.128.106.52:2181 --topic ai_jl_analytic --describe
2、查看消費者consumer的group列表
2.1 查看所有的group
./kafka-consumer-groups.sh --bootstrap-server 10.128.106.52:9092 --list
2.2 查看指定的group
./kafka-consumer-groups.sh --bootstrap-server 10.128.106.52:9092 --group ai-trace --describe
3、創(chuàng)建、修改、刪除topic
3.1 創(chuàng)建topic
./kafka-topics.sh --create --zookeeper 10.128.106.52:2181 --topic test --partitions 8 --replication-factor 1
#創(chuàng)建topic名為test,分區(qū)數(shù)為8,副本數(shù)為1
3.2 修改topic分區(qū)數(shù)量
./kafka-topics.sh --zookeeper 10.128.106.52:2181 -alter --partitions 12 --topic test
3.3 刪除topic
./kafka-topics.sh --zookeeper 10.128.106.52:2181 --delete --topic test
執(zhí)行topic刪除命令時,出現(xiàn)提示
Topic test is marked for deletion.
Note: This will have no impact if delete.topic.enable is not set to true.
這條命令其實并不執(zhí)行刪除動作,僅僅是在zookeeper上標(biāo)記該topic要被刪除而已,同時也提醒用戶一定要提前打開delete.topic.enable開關(guān),否則刪除動作是不會執(zhí)行的。
解決辦法:
a)在server.properties中設(shè)置delete.topic.enable參數(shù)為ture
b)如下操作:
1.登錄zookee客戶端:./bin/zookeeper-client
2.找到topic所在目錄:ls /brokers/topics
3.執(zhí)行刪除命令:rmr /brokers/topics/test
4、模擬生產(chǎn)者/消費者
4.1 生產(chǎn)者生產(chǎn)消息:
./kafka-console-producer.sh --broker-list 10.128.106.52:9092 --topic test
文章來源:http://www.zghlxwxcb.cn/news/detail-425923.html
4.2 消費者消費消息:
./kafka-console-consumer.sh --bootstrap 10.128.106.52:9092 --topic server
文章來源地址http://www.zghlxwxcb.cn/news/detail-425923.html
到了這里,關(guān)于Kafka系列:查看Topic列表、消息消費情況、模擬生產(chǎn)者消費者的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!