kafka runtime_error ai_generated true

ZooKeeper连接丢失异常:/brokers/ids的连接丢失错误

org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /brokers/ids

ID: kafka/zk-timeout-on-startup

其他格式: JSON · Markdown 中文 · English
78%修复率
85%置信度
1证据数
2023-08-15首次发现

版本兼容性

版本状态引入弃用备注
Kafka 3.4.0 active
ZooKeeper 3.8.1 active
Kafka 3.5.1 active

根因分析

Kafka代理在启动时因网络超时或ZooKeeper集群不可用而无法向ZooKeeper注册。

English

Kafka broker fails to register with ZooKeeper due to network timeout or ZooKeeper cluster unavailability during startup.

generic

官方文档

https://kafka.apache.org/documentation/#zk_connection_loss

解决方案

  1. Check ZooKeeper connectivity: `echo stat | nc zookeeper1 2181` and ensure ZooKeeper ensemble is healthy (quorum formed). Then verify Kafka broker can resolve ZooKeeper hostnames via DNS.
  2. Increase `zookeeper.connection.timeout.ms` in broker config to 30000 (30 seconds) and reduce `zookeeper.session.timeout.ms` to 18000 to allow more time for initial handshake.
  3. Example fix: set `zookeeper.connect=zk1:2181,zk2:2181,zk3:2181/kafka` and ensure `zookeeper.connection.timeout.ms=30000` in server.properties.

无效尝试

常见但无效的做法:

  1. 65% 失败

    It masks the symptom but does not fix the root cause of intermittent connectivity.

  2. 80% 失败

    The broker will still fail to connect if ZooKeeper is down or misconfigured.