Java Kafka - 经纪人:组协调员不可用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/50952081/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Kafka - Broker: Group coordinator not available
提问by Yakovenko Alexey
I have the following structure:
我有以下结构:
zookeeper: 3.4.12
kafka: kafka_2.11-1.1.0
server1: zookeeper + kafka
server2: zookeeper + kafka
server3: zookeeper + kafka
Created topic with replication factor 3 and partitions 3 by kafka-topics shell script.
通过 kafka-topics shell 脚本创建具有复制因子 3 和分区 3 的主题。
./kafka-topics.sh --create --zookeeper localhost:2181 --topic test-flow --partitions 3 --replication-factor 3
And use group localConsumers. it works fine when leader is ok.
并使用组 localConsumers。当领导者正常时它工作正常。
./kafka-topics.sh --describe --zookeeper localhost:2181 --topic test-flow
Topic:test-flow PartitionCount:3 ReplicationFactor:3 Configs:
Topic: test-flow Partition: 0 Leader: 3 Replicas: 3,2,1 Isr: 3,2,1
Topic: test-flow Partition: 1 Leader: 1 Replicas: 1,3,2 Isr: 1,3,2
Topic: test-flow Partition: 2 Leader: 2 Replicas: 2,1,3 Isr: 2,1,3
Consumers' log
消费者日志
Received FindCoordinator response ClientResponse(receivedTimeMs=1529508772673, latencyMs=217, disconnected=false, requestHeader=RequestHeader(apiKey=FIND_COORDINATOR, apiVersion=1, clientId=consumer-1, correlationId=0), responseBody=FindCoordinatorResponse(throttleTimeMs=0, errorMessage='null', error=NONE, node=myserver3:9092 (id: 3 rack: null)))
But if leader is down - I get the error in consumer (systemctl stop kafka):
但是如果领导者宕机了 - 我在消费者中得到错误(systemctl stop kafka):
Node 3 is unavailable. ok
节点 3 不可用。好的
./kafka-topics.sh --describe --zookeeper localhost:2181 --topic test-flow
Topic:test-flow PartitionCount:3 ReplicationFactor:3 Configs:
Topic: test-flow Partition: 0 Leader: 2 Replicas: 3,2,1 Isr: 2,1
Topic: test-flow Partition: 1 Leader: 1 Replicas: 1,3,2 Isr: 1,2
Topic: test-flow Partition: 2 Leader: 2 Replicas: 2,1,3 Isr: 2,1
Consumers' log
消费者日志
Received FindCoordinator response
ClientResponse(receivedTimeMs=1529507314193, latencyMs=36,
disconnected=false,
requestHeader=RequestHeader(apiKey=FIND_COORDINATOR, apiVersion=1,
clientId=consumer-1, correlationId=149),
responseBody=FindCoordinatorResponse(throttleTimeMs=0,
errorMessage='null', error=COORDINATOR_NOT_AVAILABLE, node=:-1 (id: -1
rack: null)))
- Group coordinator lookup failed: The coordinator is not available.
- Coordinator discovery failed, refreshing metadata
Consumer unable to connect until leader is down or reconnect with another consumer group.
消费者无法连接,直到领导者关闭或与另一个消费者组重新连接。
Can't understand why it happens? Consumer should be rebalanced to another broker, but it doesn't.
不明白为什么会这样?消费者应该重新平衡到另一个经纪人,但事实并非如此。
采纳答案by Oleksandr Loushkin
Try to add properties into the server.conf and clean zookeeper cache. It should help
尝试将属性添加到 server.conf 并清理 zookeeper 缓存。它应该有帮助
offsets.topic.replication.factor=3
default.replication.factor=3
Root cause of this issue is impossibility to distribute topic offsets between nodes.
此问题的根本原因是无法在节点之间分配主题偏移量。
Auto generated topic: __consumer_offsets
自动生成的主题:__consumer_offsets
You can check it by
你可以通过
$ ./kafka-topics.sh --describe --zookeeper localhost:2181 --topic __consumer_offsets
Pay attention to this article: https://kafka.apache.org/documentation/#prodconfig
关注这篇文章:https: //kafka.apache.org/documentation/#prodconfig
by default it creates __consumer_offsets with RF - 1
默认情况下,它使用 RF - 1 创建 __consumer_offsets
Important thing is to configure replication factor before the kafka/cluster start. Otherwise it can bring some issues with re configuring instances like in your case.
重要的是在 kafka/cluster 启动之前配置复制因子。否则,它可能会在重新配置实例时带来一些问题,例如您的情况。