kafka查看消费组的消费详情
[root@yqms-beta_g3 bin]# ./kafka-consumer-groups.sh --bootstrap-server 192.168.182.22:9092 --describe --group online2
Note: This will not show information about old Zookeeper-based consumers.
TOPIC PARTITION CURRENT-OFFSET LOG-END-OFFSET LAG CONSUMER-ID HOST CLIENT-ID
yqms4_online2 0 765553 765553 0 consumer-11-ee19b7fc-69b7-46d6-becb-6b0ac7437677 /192.168.185.83 consumer-11
yqms4_online 1 2349165 2349165 0 consumer-10-7a3a3c9d-cabd-4828-9e7d-1059edaf3ae4 /192.168.185.83 consumer-10
yqms4_online2 1 765554 765554 0 consumer-12-34374491-173f-4757-b0ba-194e1b205568 /192.168.185.83 consumer-12
yqms4_online 0 2349163 2349163 0 consumer-1-4510420d-f203-4d3f-8e90-137de4b3914e /192.168.185.83 consumer-1
- - - - - consumer-2-d5a5d937-23c2-4bee-b13b-bf0e1f4a76c2 /192.168.185.83 consumer-2
- - - - - consumer-18-445d7b89-f3b1-439f-ae5b-01da32ddf094 /192.168.185.83 consumer-18
- - - - - consumer-19-96e7e74f-6c93-452e-b91d-a99956e25890 /192.168.185.83 consumer-19
- - - - - consumer-4-2d8f1a73-3876-40b8-ab07-7e9555ab956a /192.168.185.83 consumer-4
- - - - - consumer-3-39ae93ad-c5fa-4c2a-b19b-02e2347aff41 /192.168.185.83 consumer-3
- - - - - consumer-6-cc39f580-d433-4248-8371-733da9703196 /192.168.185.83 consumer-6
- - - - - consumer-17-27b58eff-db84-4e79-a07a-5350ec9265ef /192.168.185.83 consumer-17
- - - - - consumer-15-6f7945f9-59c3-49bb-a1d7-c0f97d0c5097 /192.168.185.83 consumer-15
- - - - - consumer-5-161b6839-cc85-4d22-bea4-7042710c3655 /192.168.185.83 consumer-5
- - - - - consumer-7-9c44945b-181d-46fc-b3c0-57153cdc42a3 /192.168.185.83 consumer-7
- - - - - consumer-8-594d2aba-3edc-4882-9ce8-118f0e196af3 /192.168.185.83 consumer-8
- - - - - consumer-20-8b720b3a-2ee9-4cd3-bc0d-97108c67b3df /192.168.185.83 consumer-20
- - - - - consumer-16-a50e3daa-32e1-4167-85d6-3a122aa927d7 /192.168.185.83 consumer-16
- - - - - consumer-13-8ef46f20-8698-485d-8ad2-e91abb8a0e74 /192.168.185.83 consumer-13
- - - - - consumer-9-4c4ca3b9-2afc-4644-aa07-b192eee7e24f /192.168.185.83 consumer-9
- - - - - consumer-14-9913d02d-0584-476e-b58c-3566bac84b57 /192.168.185.83 consumer-14
springboot配置文件:
kafka.consumer.zookeeper.connect=192.168.182.22:2181
kafka.consumer.servers=192.168.182.22:9092
kafka.consumer.enable.auto.commit=true
kafka.consumer.session.timeout=6000
kafka.consumer.auto.commit.interval=100
kafka.consumer.auto.offset.reset=latest
kafka.consumer.topic=yqms4_online
kafka.consumer.group.id=online2
kafka.consumer.concurrency=10
如上图:每个topic只有两个partition 启动10个消费线程是没有意义的
因此配置为错误示例,kafka.consumer.concurrency 需要<=topic的PARTITION数量。
关于PARTITION:
- PARTITION越多吞吐量越高(硬件有上限)
- PARTITION越多需要打开越多的句柄(视情况调整linux配置)
创建topic
./kafka-topics.sh --create --zookeeper localhost:2181 -replication-factor 1 --partitions 1 --topic haoran
查看topic
./bin/kafka-topics.sh --list --zookeeper localhost:2181
修改topic的partition
./bin/kafka-topics.sh --alter --topic haoran --zookeeper localhost:2181 --partitions 5