// 问题:
Golang 通过 sarama 连接到 kafka,没有指定 group,连接的 topic 只有一个 partition,通过 2 台机器上一样的程序连上 kafka 上, 这 2 个程序都能消费这一个 partition 的数据.
那么这个 2 台机器上的应用程序是属于同一个 group 的,而且是同一个 consumer? 要知道一个 partition 只能被每个 group 的一个 consumer 消费的!!!
// kafka 版本:
root@ubuntu18:/usr/local/kafka_2.11-2.0.0/bin# ./kafka-topics.sh --version 2.0.0 (Commit:3402a8361b734732)
// topic 只有一个 partition
root@ubuntu18:/usr/local/kafka_2.11-2.0.0/bin# kafka-topics.sh --describe --zookeeper 127.0.0.1:2181 --topic topic.XXX Topic:topic.skygram PartitionCount:1 ReplicationFactor:1 Configs: Topic: topic.XXX Partition: 0 Leader: 0 Replicas: 0 Isr: 0
// 只有一个 group,看不到其他的 group 和 consumer 的消息
root@ubuntu18:/usr/local/kafka_2.11-2.0.0/bin# ./kafka-consumer-groups.sh --bootstrap-server localhost:9092 --list
KMOffsetCache-ubuntu18
// 确实是两台机器连上的
root@ubuntu18:/usr/local/kafka_2.11-2.0.0/bin# netstat -antop|grep 9092|grep ESTABLISHED tcp 0 0 192.168.198.145:50396 192.168.198.145:9092 ESTABLISHED 18330/./main_linux keepalive (1.00/0/0) tcp 0 0 192.168.198.145:50394 192.168.198.145:9092 ESTABLISHED 18330/./main_linux keepalive (4.07/0/0) tcp 0 0 192.168.198.145:50392 192.168.198.145:9092 ESTABLISHED 18330/./main_linux keepalive (4.07/0/0) tcp6 0 0 192.168.198.145:9092 192.168.198.145:50394 ESTABLISHED 4367/java keepalive (3630.28/0/0) tcp6 0 0 192.168.198.145:9092 192.168.198.1:54181 ESTABLISHED 4367/java keepalive (1688.40/0/0) tcp6 0 0 192.168.198.145:9092 192.168.198.145:43006 ESTABLISHED 4367/java keepalive (4265.90/0/0) tcp6 0 0 192.168.198.145:9092 192.168.198.1:54183 ESTABLISHED 4367/java keepalive (1688.40/0/0) tcp6 0 0 192.168.198.145:43012 192.168.198.145:9092 ESTABLISHED 4699/java keepalive (4266.62/0/0) tcp6 0 0 192.168.198.145:9092 192.168.198.1:54182 ESTABLISHED 4367/java keepalive (1688.40/0/0) tcp6 0 0 192.168.198.145:9092 192.168.198.145:50396 ESTABLISHED 4367/java keepalive (3742.75/0/0) tcp6 0 0 192.168.198.145:43006 192.168.198.145:9092 ESTABLISHED 4699/java keepalive (4265.90/0/0) tcp6 0 0 192.168.198.145:9092 192.168.198.145:50392 ESTABLISHED 4367/java keepalive (3630.28/0/0) tcp6 0 0 192.168.198.145:9092 192.168.198.145:43012 ESTABLISHED 4367/java keepalive (4266.62/0/0
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.