kafka常用命令

2021-08-27 00:05:33 字數 1612 閱讀 6911

kafka bin目錄:/usr/local/cellar/kafka/1.1.0/bin

1. 檢視有哪些主題:

./kafka-topics.sh –list –zookeeper ip:port

2. 檢視topic的詳細資訊

./kafka-topics -zookeeper 192.168.49.158:2181 -describe -topic test

3. 為topic增加副本

./kafka-reassign-partitions.sh -zookeeper 127.0.0.1:2181 -reassignment-json-file json/partitions-to-move.json -execute

4. 建立topic

./kafka-topics.sh –create –zookeeper localhost:2181 –replication-factor 1 –partitions 1 –topic test

5. 為topic增加partition

./bin/kafka-topics.sh –zookeeper 127.0.0.1:2181 –alter –partitions 20 –topic test

6. kafka生產者客戶端命令

./kafka-console-producer.sh –broker-list localhost:9092 –topic test

7. kafka消費者客戶端命令

./kafka-console-consumer.sh -zookeeper localhost:2181 –from-beginning –topic test

8. kafka服務啟動

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

9. 下線broker

./kafka-run-class.sh kafka.admin.shutdownbroker –zookeeper 127.0.0.1:2181 –broker #brokerid# –num.retries 3 –retry.interval.ms 60

shutdown broker

10. 刪除topic

./kafka-run-class.sh kafka.admin.deletetopiccommand –topic test –zookeeper 127.0.0.1:2181

./kafka-topics.sh –zookeeper localhost:2181 –delete –topic test

11. 檢視consumer組內消費的offset

./kafka-run-class.sh kafka.tools.consumeroffsetchecker –zookeeper localhost:2181 –group test –topic test

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 ...