一直覺得kafka-consumer-groups.sh的輸出信息有點少,總算在2.0中得到了改善。新版本ConsumerGroupCommand增加了查看成員信息、組狀態信息,算是彌補了之前的不足。今天試用了一下,感覺還不錯,推薦大家也用一用~~
1. 查看成員信息(簡約版):
$:kafka_2.12-2.0.0 huxi$ bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092,localhost:9093,localhost:9094 --describe --group test-group --members
CONSUMER-ID HOST CLIENT-ID #PARTITIONS
consumer-1-aa3f2e15-d577-4c51-acd5-aa0d488cc131 /127.0.0.1 consumer-1 8
consumer-1-f3b11334-b9eb-4d4f-80d1-766446c77ee9 /127.0.0.1 consumer-1 8
consumer-1-658e4d7b-a561-4430-bbdf-c3ab59a18f3a /127.0.0.1 consumer-1 9
2. 查看成員信息(詳細版):
$:kafka_2.12-2.0.0 huxi$ bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092,localhost:9093,localhost:9094 --describe --group test-group --members --verbose
CONSUMER-ID HOST CLIENT-ID #PARTITIONS ASSIGNMENT
consumer-1-aa3f2e15-d577-4c51-acd5-aa0d488cc131 /127.0.0.1 consumer-1 8 test-topic(9,10,11,12,13,14,15,16)
consumer-1-f3b11334-b9eb-4d4f-80d1-766446c77ee9 /127.0.0.1 consumer-1 8 test-topic(17,18,19,20,21,22,23,24)
consumer-1-658e4d7b-a561-4430-bbdf-c3ab59a18f3a /127.0.0.1 consumer-1 9 test-topic(0,1,2,3,4,5,6,7,8)
3. 查看組狀態信息:
$:kafka_2.12-2.0.0 huxi$ bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092,localhost:9093,localhost:9094 --describe --group test-group --state
COORDINATOR (ID) ASSIGNMENT-STRATEGY STATE #MEMBERS
localhost:9092 (0) range Stable 3