Kafka command: View topic & production and consumption data & view consumption information of the group

manba_ yqq 2022-01-26 19:13:28 阅读数:30

kafka command view topic production

1、 establish topic:

[[email protected] bin]# ./kafka-topics.sh --zookeeper node2:2181,node3:2181,node3:2181 --create --topic topic1 --partitions 3 --replication-factor 3
Created topic "topic1".

2、 Use a node console to be kafka The producers of :

[[email protected] bin]# ./kafka-console-producer.sh --topic topic1 --broker-list node1:9092,node2:9092,node3:9092

 Insert picture description here

3、 Use another node console to be kafka The consumer :

[[email protected] bin]# ./kafka-console-consumer.sh --bootstrap-server node1:9092,node2:9092,node3:9092 --topic topic1

 Insert picture description here
4、 see topic grouping

[[email protected] bin]# ./kafka-topics.sh --zookeeper node2:2181,node3:2181,node3:2181 --list
topic1

5、 Check out the consumer group

[[email protected] bin]# ./kafka-consumer-groups.sh --bootstrap-server node1:9092,node2:9092,node3:9092 --list
Note: This will only show information about consumers that use the Java consumer API (non-ZooKeeper-based consumers).
console-consumer-71901

6、 View production and consumption

[[email protected] bin]# ./kafka-consumer-groups.sh --bootstrap-server node1:9092,node2:9092,node3:9092 --describe --group console-consumer-71901
Note: This will only show information about consumers that use the Java consumer API (non-ZooKeeper-based consumers).
TOPIC PARTITION CURRENT-OFFSET LOG-END-OFFSET LAG CONSUMER-ID HOST CLIENT-ID
topic1 0 2 2 0 consumer-1-24253251-9c16-48f5-b0a0-8a8abf642f78 /192.168.134.102 consumer-1
topic1 1 2 2 0 consumer-1-24253251-9c16-48f5-b0a0-8a8abf642f78 /192.168.134.102 consumer-1
topic1 2 2 2 0 consumer-1-24253251-9c16-48f5-b0a0-8a8abf642f78 /192.168.134.102 consumer-1
copyright:author[manba_ yqq],Please bring the original link to reprint, thank you. https://en.javamana.com/2022/01/202201261913259578.html