3

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?

ParkCheolu
  • 1,175
  • 2
  • 14
  • 30
  • 1
    Does this answer your question? [Kafka Broker doesn't find cluster id and creates new one after docker restart](https://stackoverflow.com/questions/59592518/kafka-broker-doesnt-find-cluster-id-and-creates-new-one-after-docker-restart) – Saif Ahmad Nov 26 '20 at 07:41

1 Answers1

5

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.

mj3c
  • 1,447
  • 15
  • 18
  • Very interesting. What would be a recommended location in Ubuntu OS for such a directrory that will persist? – Guy_g23 Aug 08 '23 at 07:49