kafka-docker: Cluster ID Mismatch
Hi - I’m new to Kafka so perhaps I’m not understanding something. First, thanks for providing this dockerized Kafka image. It works great. I have the Kafka logs volume mounted and using docker-compose stop and docker-compose up -d --no-recreate seem to be doing the trick. I am curious how one should handle data persistence a container is torn down (e.g. docker-compose down). It seems that all of the necessary data is still there on the docker host, but when starting the Kafka container runs into an issue where the Cluster ID does not match the id specified in meta.properties, and the Kafka container exits. Is there a way around this? Perhaps more environment variables that need to be specified in the compose file? Thanks in advance for any guidance and/or suggestions you may have.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 25
Hi I had the same problem and I solved it, you can check my docker-compose.yml. First, delete your current files before applying the following config. After that, you can docker-compose up and docker-compose down then docker-compose up
Then you will see that your topics will remain there and the Kafka will work The problem that I had, was the wrong zookeeper path after I changed the path, then Kafka started working. I hope that it helps the ones that have this problem
I found my mistake…
meta.propertiesis stored in the container’s/kafka/kafka-logspath. According to the docker configuration above, themeta.propertiesstored here are stored in/opt/data/kafkaoutside the container, and these files remain with or without the container or stack exiting. The problem is that if you don’t delete these files, the newly created container will be referred to themeta.propertiesof the previous container. If you have the same settings as me, try deleting all files except the log folder for each topics.@cricket007 - does this help?
@cricket007 - Sorry. I’m still a little confused here. If I need to recreate the Kafka container, but want to reuse the data from the last container (e.g. use a volume mount), what is the best way to do this? With a single kafka broker, I’m seeing cluster id mismatch errors as indicated above. Any guidance would be greatly appreciated.
@klongmitre this is indeed the issue. For anyone interested: Kafka version 2.4 has introduced a check if the cluster.id matches the one stored in Zookeeper. Kafka itself stores this in meta.properties. The meta.properties shouldn’t be thrown away, instead you should keep both the zookeepers logs and data so that the cluster id is persistant.
Agreed. I’m not trying to scale the service. It’s a single broker set-up. My interest is in enabling persistent data store (via volume mounts), but if the container is destroyed, the persistent store is no longer useable due to the Cluster ID mismatch.