简体   繁体   English

Zookeeper 何时更改 Kafka 集群 ID?

[英]When does Zookeeper change Kafka cluster ID?

Sometimes I enforce the following error when trying to run Kafka broker:有时我在尝试运行 Kafka 代理时会强制执行以下错误:

ERROR Fatal error during KafkaServer startup. Prepare to shutdown (kafka.server.KafkaServer)
kafka.common.InconsistentClusterIdException: The Cluster ID m1Ze6AjGRwqarkcxJscgyQ doesn't match stored clusterId Some(1TGYcbFuRXa4Lqojs4B9Hw) in meta.properties. The broker is trying to join the wrong cluster. Configured zookeeper.connect may be wrong.
        at kafka.server.KafkaServer.startup(KafkaServer.scala:220)
        at kafka.server.KafkaServerStartable.startup(KafkaServerStartable.scala:44)
        at kafka.Kafka$.main(Kafka.scala:84)
        at kafka.Kafka.main(Kafka.scala)
[2020-01-04 15:58:43,303] INFO shutting down (kafka.server.KafkaServer)

I know what the error message means and it can be solved with removing meta.properties in the Kafka log dir.我知道错误消息的含义,可以通过删除 Kafka 日志目录中的 meta.properties 来解决。

I now want to know when this happens exactly to prevent this from happening.我现在想知道什么时候会发生这种情况,以防止这种情况发生。 Why/when does sometimes the cluster ID that Zookeeper looks for changes?为什么/有时 Zookeeper 查找的集群 ID 会发生变化?

Kafka requires Zookeeper to start. Kafka 需要 Zookeeper 启动。 When you run zk with out-of-the-box setup, it contains data/log dir set as the tmp directory.当您使用开箱即用的设置运行 zk 时,它包含设置为 tmp 目录的数据/日志目录。 When your instance/machine restarts tmp directory is flushed, and zookeeper looses its identity and creates a new one.当您的实例/机器重新启动时,tmp 目录被刷新,zookeeper 失去其身份并创建一个新的身份。 Kafka cannot connect to a new zk as meta.properties file contains reference of the previous cluster_id Kafka 无法连接到新的 zk,因为meta.properties文件包含对先前cluster_id 的引用

To avoid this configure your $KAFKA_HOME/config/zookeeper.properties change dataDir to a directory that will persist after Zookeeper shuts down / restarts.为了避免这种情况,请配置您的$KAFKA_HOME/config/zookeeper.propertiesdataDir为在 Zookeeper 关闭/重新启动后仍将保留的目录。

This would avoid zk to lose its cluster_id everytime machine restarts.这将避免 zk 在每次机器重新启动时丢失其 cluster_id。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM