Kafka:基本命令

📅 2026/8/3 20:23:30
Kafka:基本命令
常用kafka脚本命令#查看版本./kafka-server-start.sh--version 3.7.0#生产发消息./kafka-console-producer.sh--topic[my-topic]--bootstrap-server 127.0.0.1:9092#接收消息./kafka-console-consumer.sh--topic[my-topic]--bootstrap-server 127.0.0.1:9092--from-beginning#查看所有的topic列表./kafka_2.12-3.4.0/bin/kafka-topics.sh--list--bootstrap-server 127.0.0.1:9092#查看所有消费者组列表./kafka_2.12-3.4.0/bin/kafka-consumer-groups.sh--bootstrap-server 127.0.0.1:9092--all-topics--all-groups--list#查看某个topic详情./kafka_2.12-3.4.0/bin/kafka-topics.sh--describe--topic[my-topic]--bootstrap-server 127.0.0.1:9092#查看某个消费组详情 查看消费积压状态./kafka_2.12-3.4.0/bin/kafka-consumer-groups.sh--bootstrap-server 127.0.0.1:9092--describe--group[my-consumer-group]#查看所有消费组详情查看消费积压状态./kafka_2.12-3.4.0/bin/kafka-consumer-groups.sh--bootstrap-server 127.0.0.1:9092--all-groups--describe#删除某个topic./kafka_2.12-3.4.0/bin/kafka-topics.sh--delete--bootstrap-server 127.0.0.1:9092--topic[my-topic]#删除某个消费组./kafka_2.12-3.4.0/bin/kafka-consumer-groups.sh--bootstrap-server 127.0.0.1:9092--delete--group[my-consumer-group]#将积压在队列中的数据清空 重置offset./kafka_2.12-3.4.0/bin/kafka-consumer-groups.sh--bootstrap-server server.kafka.host:9092--group[my-consumer-group]--topic[my-topic]--reset-offsets--to-latest--execute