kafka消费之kafka查看topic是否有数据

通过原生kafka,查看对应的topic是否有数据

./kafka-server-start.sh ../config/server.properties 1>/dev/null 2>&1 &     # kafka-server-start.sh 脚本在 kafka_2.12-2.2.0/bin路径下
  • 查看已创建的topic列表:
 ./kafka-topics.sh --list --zookeeper localhost:2181
  • 查看对应topic的描述信息: 
./kafka-topics.sh --describe --zookeeper xx.x.xxx.xxx:2181 --topic xxxxx.xx.xxxxx.xxx     # --zookeeper为zookeeperIP, --topic为topic名称 
  • 消费消息:
./kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic xxxxx.xx.xxxxx.xxx --from-beginning    # 若没有任何返回或没有响应,则该topic中没有数据内容;否则有
 
 
 

原文地址:https://www.cnblogs.com/sunshine-blog/p/11929867.html