How to generating cluster ID

How to generating cluster ID

Cluster ID is required for each Kafka instance to know, to which instance it must to connect and make cluster. It is also used to preparing storage space. We need to set all Kafka instance same cluster ID. If you omit this settings, all Kafka instance generate their own ID and reject make cluster.

There is many ways, how to generate the ID, but I recommend use this chain of Bash command:

$ cat /proc/sys/kernel/random/uuid | tr -d '-' | base64 | cut -b 1-22

You can also use built-in script:

$ bin/kafka-storage.sh random-uuid

Or just start one Kafka instance without the cluster ID settings and it will be generated to the logs.

Sources:

Blog sleeplessbeastie.eu
Apache Kafka Documentation

Last modified March 1, 2023: Upgrade Kafka to KRaft mode (#24) (aa536e1)