kafka常用命令

2021-08-17 10:27:27 字數 959 閱讀 8375

#啟動kafka

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

#關閉kafka

kill -9 程序號

#kafka建立topic

./bin/kafka-topics.sh --create -zookeeper 12.131.206.20:2181,12.131.206.21:2181,12.131.206.22:2181 --replication-factor 1 --partitions 3 --topic topic_audit_performance

##控制台接收訊息

./bin/kafka-console-consumer.sh --zookeeper 12.131.206.20:2181,12.131.206.21:2181,12.131.206.22:2181 --from-beginning --topic test

##控制台傳送訊息

./bin/kafka-console-producer.sh --broker-list  12.131.206.20:9092,12.131.206.20:9092 --topic test 

#檢視已經建立的topic

./bin/kafka-topics.sh --zookeeper 12.131.206.20:2181,12.131.206.20:2181,12.131.206.20:2181 --list

#檢視kafka消費情況

./kafka-run-class.sh kafka.tools.consumeroffsetchecker --broker-info --group $group --topic $topic --zookeeper $zk_host:2181 

#$group對應的是你的group  $topic對應是你的topic $zk_host:2181對應的是你的zookeeper主機位址

kafka常用命令

kafka常用操作命令 l檢視當前伺服器中的所有topic bin kafka topics.sh list zookeeper hadoop02 2181 l建立topic kafka topics.sh create zookeeper hadoop02 2181 replication fac...

kafka常用命令

啟動集群 nohup bin kafka server start.sh config server.properties 建立topic kafka topics topictt replication factor3 partitions3 create zookeeper hadoop1 21...

Kafka 常用命令

kafka console producer broker list 127.0.0.1 9092 topic mytopic kafka console consumer bootstrap server 127.0.0.1 9092 topic mytopic 建立主題,replication ...