Kafka常用命令行總結

2021-07-16 07:15:53 字數 1415 閱讀 6287

以下是kafka常用命令行總結:

1.檢視topic的詳細資訊

./kafka-topics.sh -zookeeper 127.0.0.1:2181 -describe -topic testkj1

檢視所有topic

./kafka-topics.sh --list --zookeeper 127.0.0.1:2181

2.為topic增加副本

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

3、建立topic

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

4、為topic增加partition.

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

5、kafka生產者客戶端命令

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

6、kafka消費者客戶端命令

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

7、kafka服務啟動

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

8、下線broker

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

9、刪除topic

./kafka-run-class.sh kafka.admin.deletetopiccommand --topic testkj1 --zookeeper 127.0.0.1:2181./kafka-topics.sh --zookeeper localhost:2181 --delete --topic testkj1

10、檢視consumer組內消費的offset./kafka-run-class.sh kafka.tools.consumeroffsetchecker --zookeeper localhost:2181 --group test --topic testkj1

轉至

Kafka常用命令行總結

以下是kafka常用命令行總結 1.檢視topic的詳細資訊 kafka topics.sh zookeeper 127.0.0.1 2181 describe topic testkj1 2 為topic增加副本 kafka reassign partitions.sh zookeeper 127...

Kafka常用命令行總結

以下是kafka常用命令行總結 1.檢視topic的詳細資訊 kafka topics.sh zookeeper127.0.0.1 2181 describe topic testkj1 2 為topic增加副本 kafka reassign partitions.sh zookeeper127.0...

Kafka 常用命令行工具

建立主題kafka topics.sh create zookeeper localhost 2181 replication factor 1 partitions 1 topic zjwblog 檢視所有主題kafka topics.sh zookeeper localhost 2181 lis...