Ruby Kafka未捕获的异常:未能找到组协调器

时间:2018-06-23 14:43:04

标签: ruby docker apache-kafka ruby-kafka

我将Apache Kafka用作Docker容器https://hub.docker.com/r/wurstmeister/kafka/

我能够使用Spring Kafka从Java应用程序成功连接到Kafka。

但是当我尝试通过Ruby Kafka从Ruby应用程序连接到Kafka时,出现以下错误:

Uncaught exception: Failed to find group coordinator

Java和Ruby应用程序之间的唯一区别是Ruby应用程序位于本地网络中的另一台计算机上,但是我可以从Ruby机器上看到Kafka机器以及那里的所有端口。

如何找到问题并解决?

已更新

I, [2018-06-25T10:06:49.513848 #62261]  INFO -- : New topics added to target list: post.sent
I, [2018-06-25T10:06:49.514036 #62261]  INFO -- : Fetching cluster metadata from kafka://10.0.0.102:9093
D, [2018-06-25T10:06:49.514262 #62261] DEBUG -- : Opening connection to 10.0.0.102:9093 with client id test...
D, [2018-06-25T10:06:49.518350 #62261] DEBUG -- : Sending topic_metadata API request 1 to 10.0.0.102:9093
D, [2018-06-25T10:06:49.519336 #62261] DEBUG -- : Waiting for response 1 from 10.0.0.102:9093
D, [2018-06-25T10:06:49.530220 #62261] DEBUG -- : Received response 1 from 10.0.0.102:9093
I, [2018-06-25T10:06:49.530351 #62261]  INFO -- : Discovered cluster metadata; nodes: 10.0.75.1:9093 (node_id=1001)
D, [2018-06-25T10:06:49.530439 #62261] DEBUG -- : Closing socket to 10.0.0.102:9093
I, [2018-06-25T10:06:49.530682 #62261]  INFO -- : Joining group `my_group`
D, [2018-06-25T10:06:49.530812 #62261] DEBUG -- : Getting group coordinator for `my_group`
D, [2018-06-25T10:06:49.531019 #62261] DEBUG -- : Opening connection to 10.0.75.1:9093 with client id test...
D, [2018-06-25T10:06:49.616368 #62261] DEBUG -- : Handling fetcher command: subscribe
I, [2018-06-25T10:06:49.616797 #62261]  INFO -- : Will fetch at most 1048576 bytes at a time per partition from post.sent
D, [2018-06-25T10:06:49.617262 #62261] DEBUG -- : Handling fetcher command: configure
D, [2018-06-25T10:06:49.617462 #62261] DEBUG -- : Handling fetcher command: start
D, [2018-06-25T10:06:49.617599 #62261] DEBUG -- : Fetching batches
I, [2018-06-25T10:06:49.618108 #62261]  INFO -- : Fetching cluster metadata from kafka://10.0.0.102:9093
D, [2018-06-25T10:06:49.619053 #62261] DEBUG -- : Opening connection to 10.0.0.102:9093 with client id test...
D, [2018-06-25T10:06:49.624053 #62261] DEBUG -- : Sending topic_metadata API request 1 to 10.0.0.102:9093
D, [2018-06-25T10:06:49.625459 #62261] DEBUG -- : Waiting for response 1 from 10.0.0.102:9093
D, [2018-06-25T10:06:49.635283 #62261] DEBUG -- : Received response 1 from 10.0.0.102:9093
I, [2018-06-25T10:06:49.635468 #62261]  INFO -- : Discovered cluster metadata; nodes: 10.0.75.1:9093 (node_id=1001)
D, [2018-06-25T10:06:49.635596 #62261] DEBUG -- : Closing socket to 10.0.0.102:9093
I, [2018-06-25T10:06:49.635853 #62261]  INFO -- : There are no partitions to fetch from, sleeping for 1s
D, [2018-06-25T10:06:50.637187 #62261] DEBUG -- : Fetching batches
I, [2018-06-25T10:06:50.637804 #62261]  INFO -- : There are no partitions to fetch from, sleeping for 1s
D, [2018-06-25T10:06:51.642172 #62261] DEBUG -- : Fetching batches
I, [2018-06-25T10:06:51.642471 #62261]  INFO -- : There are no partitions to fetch from, sleeping for 1s
D, [2018-06-25T10:06:52.645354 #62261] DEBUG -- : Fetching batches
I, [2018-06-25T10:06:52.645640 #62261]  INFO -- : There are no partitions to fetch from, sleeping for 1s
D, [2018-06-25T10:06:53.647833 #62261] DEBUG -- : Fetching batches
I, [2018-06-25T10:06:53.648259 #62261]  INFO -- : There are no partitions to fetch from, sleeping for 1s
D, [2018-06-25T10:06:54.650357 #62261] DEBUG -- : Fetching batches
I, [2018-06-25T10:06:54.650647 #62261]  INFO -- : There are no partitions to fetch from, sleeping for 1s
D, [2018-06-25T10:06:55.652582 #62261] DEBUG -- : Fetching batches
I, [2018-06-25T10:06:55.653477 #62261]  INFO -- : There are no partitions to fetch from, sleeping for 1s
D, [2018-06-25T10:06:56.657937 #62261] DEBUG -- : Fetching batches
I, [2018-06-25T10:06:56.659627 #62261]  INFO -- : There are no partitions to fetch from, sleeping for 1s
D, [2018-06-25T10:06:57.664130 #62261] DEBUG -- : Fetching batches
I, [2018-06-25T10:06:57.664861 #62261]  INFO -- : There are no partitions to fetch from, sleeping for 1s
D, [2018-06-25T10:06:58.666290 #62261] DEBUG -- : Fetching batches
I, [2018-06-25T10:06:58.666620 #62261]  INFO -- : There are no partitions to fetch from, sleeping for 1s
E, [2018-06-25T10:06:59.534809 #62261] ERROR -- : Timed out while trying to connect to 10.0.75.1:9093: Operation timed out
D, [2018-06-25T10:06:59.535083 #62261] DEBUG -- : Closing socket to 10.0.75.1:9093
E, [2018-06-25T10:06:59.535342 #62261] ERROR -- : Failed to get group coordinator info from 10.0.75.1:9093 (node_id=1001): Operation timed out
I, [2018-06-25T10:06:59.535567 #62261]  INFO -- : Leaving group `my_group`
D, [2018-06-25T10:06:59.535709 #62261] DEBUG -- : Getting group coordinator for `my_group`
D, [2018-06-25T10:06:59.535875 #62261] DEBUG -- : Opening connection to 10.0.75.1:9093 with client id test...
D, [2018-06-25T10:06:59.666983 #62261] DEBUG -- : Handling fetcher command: stop
E, [2018-06-25T10:07:09.540409 #62261] ERROR -- : Timed out while trying to connect to 10.0.75.1:9093: Operation timed out
D, [2018-06-25T10:07:09.540833 #62261] DEBUG -- : Closing socket to 10.0.75.1:9093
E, [2018-06-25T10:07:09.541172 #62261] ERROR -- : Failed to get group coordinator info from 10.0.75.1:9093 (node_id=1001): Operation timed out
Exiting
Uncaught exception: Failed to find group coordinator

1 个答案:

答案 0 :(得分:2)

您的经纪人返回Group Coordinator Not Available错误。 在正常情况下,这是您的Kafka集群配置协调器节点时的临时情况。 不幸的是,在您的情况下,集群中的某些设备无法正常运行,并且未分配协调器。

您应该从日志开始检查群集配置。

您可能会发现发布在here上的解决方案很有用,我在此引用:

  

使用bootstrap-server参数时,连接通过   经纪人而不是Zookeeper。经纪人使用__consumer_offsets来   存储有关每个主题的承诺偏移量的信息:   消费者组(groupID)。在这种情况下,__consumer_offsets为   指向无效的经纪人ID。因此,上述例外是   显示。要检查此主题的代理ID是否正确,   执行以下命令:

kafka-topics.sh --describe --zookeeper <zkHost:zkPort> --topic __consumer_offsets
  

然后,使用以下命令将其与在Zookeeper中注册的经纪人进行比较:   以下命令:

zkCli.sh -server <zkHost:zkPort>
  

连接到Zookeeper后,使用以下命令检查经纪人ID   以下命令:

[zk: server1.openstacklocal:2181(CONNECTED) 0] ls /brokers/ids
  

如果经纪人ID不匹配,请继续解决此问题   文章。

     

解决方案:

     

要解决此问题,请执行以下操作:

Connect to Zookeeper using the following command:
 zkCli.sh -server <zkHost:zkPort>
  

使用以下命令删除__consumer_offset:

 znode rmr /brokers/topcis/__consumer_offset
  

重新启动代理。

相关问题