簡體   English   中英

Kafka - 經紀人:組協調員不可用

[英]Kafka - Broker: Group coordinator not available

我有以下結構:

zookeeper: 3.4.12
kafka: kafka_2.11-1.1.0
server1: zookeeper + kafka
server2: zookeeper + kafka
server3: zookeeper + kafka

通過 kafka-topics shell 腳本創建具有復制因子 3 和分區 3 的主題。

./kafka-topics.sh --create --zookeeper localhost:2181 --topic test-flow --partitions 3 --replication-factor 3

並使用組 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

消費者日志

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)))

但是如果領導者宕機了 - 我在消費者中得到錯誤(systemctl stop kafka):

節點 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

消費者日志

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

消費者無法連接,直到領導者關閉或與另一個消費者組重新連接。

不明白為什么會這樣? 消費者應該重新平衡到另一個經紀人,但事實並非如此。

嘗試將屬性添加到 server.conf 並清理 zookeeper 緩存。 它應該有幫助

offsets.topic.replication.factor=3
default.replication.factor=3

此問題的根本原因是無法在節點之間分配主題偏移量。

自動生成的主題:__consumer_offsets

你可以通過

$ ./kafka-topics.sh --describe --zookeeper localhost:2181 --topic __consumer_offsets

關注這篇文章: https : //kafka.apache.org/documentation/#prodconfig

默認情況下,它使用 RF - 1 創建 __consumer_offsets

重要的是在 kafka/cluster 啟動之前配置復制因子。 否則,它可能會在重新配置實例時帶來一些問題,例如您的情況。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM