Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When does Zookeeper change Kafka cluster ID?

Sometimes I enforce the following error when trying to run Kafka broker:

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.

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?

like image 346
ParkCheolu Avatar asked Oct 15 '25 17:10

ParkCheolu


1 Answers

Kafka requires Zookeeper to start. When you run zk with out-of-the-box setup, it contains data/log dir set as the tmp directory. When your instance/machine restarts tmp directory is flushed, and zookeeper looses its identity and creates a new one. Kafka cannot connect to a new zk as meta.properties file contains reference of the previous 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.

This would avoid zk to lose its cluster_id everytime machine restarts.

like image 94
Shrutarshi Saha Avatar answered Oct 19 '25 15:10

Shrutarshi Saha