1查看所有topic
# bin/kafka-topics.sh --list --zookeeper localhost:2181
2查看消费者组
# ./bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --list
3查看指定topic 下面的数据
# ./bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --from-beginning --topic t_by_mq_product_order
4查询topic 信息,使用位置
# ./bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group c_by_product_order_group
demo:
GROUP TOPIC PARTITION CURRENT-OFFSET LOG-END-OFFSET LAG CONSUMER-ID HOST CLIENT-ID c_by_product_order_group t_by_mq_product_order 1 88627 88627 0 rdkafka-2a40e793-b275-46a4-b9fd-c9c63e7763c7 /39.96.7.154 rdkafka c_by_product_order_group t_by_mq_product_order 2 146339 146339 0 rdkafka-4744eb0c-9d9c-4a06-b167-acbd46431741 /39.96.7.154 rdkafka c_by_product_order_group t_by_mq_product_order 0 753993 753993 0 rdkafka-055e84f2-577d-4eab-ace5-c225d888c9f5 /39.96.7.154 rdkafka
5查看kafka特定topic的详情,使用--topic与--describe参数
./bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic t_by_mq_product_order
demo:
Topic: t_by_mq_product_order PartitionCount: 3 ReplicationFactor: 1 Configs: Topic: t_by_mq_product_order Partition: 0 Leader: 0 Replicas: 0 Isr: 0 Topic: t_by_mq_product_order Partition: 1 Leader: 0 Replicas: 0 Isr: 0 Topic: t_by_mq_product_order Partition: 2 Leader: 0 Replicas: 0 Isr: 0
6删除topic清空数据
server.properties 设置 delete.topic.enable=true
./bin/kafka-topics.sh --delete --zookeeper bin/kafka-topics.sh --list --zookeeper localhost:9092 --topic topic_by_products