外观
Kafka
约 221 字小于 1 分钟
2025-02-20
Kafka常用命令
查看所有Topic
./kafka-topics.sh --zookeeper 192.168.x.xx --list
查看所有消费者组
kafka-consumer-groups.sh --bootstrap-server xxx.xxx.xxx.xxx:9092 --list
删除某一个消费者组
kafka-consumer-groups.sh --bootstrap-server xxx.xxx.xxx.xxx:9092 --delete --group xxx
查看一个Topic里是否有数据
./kafka-console-consumer.sh --bootstrap-server x.x.x.x:9092 --topic xxxxx.xx.xxxxx.xxx --from-beginning
相关信息
若没有任何返回或没有响应,则该topic中没有数据内容;否则就是有数据
查看Kafka消费者组详情信息
kafka-consumer-groups.sh --bootstrap-server x.x.x.x:9092 --describe --group groupId
提示
LAG为堆积未处理的消息,LOG-END-OFFSET为消息总偏移量,CURRENT-OFFSET 当前偏移量
手动往kafkaTopic里插入数据
- 使用kafka-console-producer.sh插入数据
./kafka-console-producer.sh --broker-list localhost:9092 --topic TopicName
- 等待命令启动后,在箭头后面就可以输入需要发送的消息。