1.kafka集群有关topic操作
1) 查看有多少条topic
[root@XX bin]# pwd
/opt/app/kafka/9092/kafka_2.11-1.0.0/bin
[root@XX bin]# ./kafka-topics.sh --list --zookeeper localhost:2181
0315postest
__consumer_offsets
elklog
tomcat2-accesslog
tomcat2-catalinalog
tomcat2log
tomcat76-catalinalog
2) 查看指定topic的具体情况
[root@XX bin]# ./kafka-topics.sh --zookeeper localhost:2181 --describe --topic tomcat76-catalinalog
Topic:tomcat76-catalinalog PartitionCount:1 ReplicationFactor:1 Configs:
Topic: tomcat76-catalinalog Partition: 0 Leader: 1 Replicas: 1 Isr: 1
3)查看指定topic是否有数据 (消费消息,若没有任何返回或没有响应,则该topic中没有数据内容;否则有。)
[root@XX bin]# ./kafka-console-consumer.sh --bootstrap-server kafkaip:6669 --topic tomcat76-catalinalog --from-beginning