Kafka Broker doesn’t find cluster id and creates new one after docker restart

If you are 100% sure you are connecting to the right ZooKeeper and the right Kafka log directories, but for some reason things don’t match and you don’t feel like losing all your data while trying to recover:

The Kafka data directory (check config/server.properties for log.dirs property, it defaults to /tmp/kafka-logs) contains a file called meta.properties. It contains the cluster ID. Which should have matched the ID registered to ZK. Either edit the file to match ZK, edit ZK to match the file, or delete the file (it contains the cluster id and the broker id, the first is currently broken and the second is in the config file normally). After this minor surgery, Kafka will start with all your existing data, since you didn’t delete any data file.

Like this:
mv /tmp/kafka-logs/meta.properties /tmp/kafka-logs/meta.properties_old

Leave a Comment