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