kafka3.0常用命令


1、進入kafka的bin目錄:先啟動內置zookeeper

    執行命令:zookeeper-server-start.sh ../config/zookeeper.properties

    后台運行命令:zookeeper-server-start.sh -daemon ../config/zookeeper.properties

2、啟動kafka

    執行命令:./kafka-server-start.sh ../config/server.properties,主義前面 ./ ,不然啟動不了。

    后台啟動命令:./kafka-server-start.sh -daemon ../config/server.properties

 

生產命令:
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic frist0401

消費命令:
./kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic frist0401

 

查看當前服務器中的所有 topic

bin/kafka-topics.sh --bootstrap-server localhost:9092 --list

創建topic

bin/kafka-topics.sh --bootstrap-server localhost:9092 --create --partitions 1 --replication-factor 1 --topic first0406

 

3、查看 first 主題的詳情

bin/kafka-topics.sh --bootstrap-server localhost:9092 --describe --topic first0406

  4、修改分區數(注意:分區數只能增加,不能減少)

    bin/kafka-topics.sh --bootstrap-server localhost:9092 --alter --topic first --partitions 3

  5、再次查看 first 主題的詳情

    bin/kafka-topics.sh --bootstrap-server localhost:9092 --describe --topic first

  6、刪除 topic

    bin/kafka-topics.sh --bootstrap-server localhost:9092 --delete --topic first

https://www.cnblogs.com/liyuanhong/p/12345751.html

 


免責聲明!

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



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