While trying to launch multiple Kafka brokers with different brokerId's. One being the default server.properties
and the other being serverTest.properties
with 2 lines changed, those being broker.id=1
and listeners=PLAINTEXT://localhost:6000
. The rest is the same default setting. I first start zookeeper, then the default kafka server.properties
then while launching serverTest.properties
I get the following exception: kafka.common.InconsistentBrokerIdException: Configured brokerId 1 doesn't match stored brokerId 0 in meta.properties
. My understanding is that the following above should actually launch multiple nodes, as I've seen others do in tutorials. I'm using Kafka 9.0.
6 Answers
Edit config/serverTest.properties and replace the existing config values as follows:
broker.id=2
port=9093
log.dir=/tmp/kafka-logs-2
If you want a third broker:
cp config/server.properties config/server3.properties
Edit config/server3.properties and replace the existing config values as follows:
broker.id=3
port=9094
log.dir=/tmp/kafka-logs-3
if you run on different machines you must change
advertised.host.name=192.168.x.x
else if you run in the same vmware machine, for example you should only change the port and log.dir as described above
This is old question, still this answer should help others. The problem is when you create new server.properties from existing server.properties, below line will get copied:
# A comma separated list of directories under which to store log files
log.dirs=/tmp/kafka-logs
So, even new broker tries to use the same log dir and hence it uses the meta.properties of kafka-logs which is created by broker 0 and has broker id as 0.
So, go to /tmp and delete all kafka-logs* files and then comment log.dirs=/tmp/kafka-logs
and then add the lines as you have added :)
The answers are perfect but it took me a while to figure it out to get it work. I would like to share my mistake and hope others can avoid it.
I followed the official tutorial with kafka here:
https://kafka.apache.org/quickstart#quickstart_multibroker.
and make a file copy as suggested in the guide:
cp config/server.properties config/server-1.properties
I open the file using vim. I do a search for broker.id and replace with the following(mistake by assuming there is no existing listeners and log.dirs) as below
# config/server-1.properties:
broker.id=1
listeners=PLAINTEXT://:9093
log.dirs=/tmp/kafka-logs-1
I started a new broker with
> bin/kafka-server-start.sh config/server-1.properties
crashed!!!. This is how I debug:
I went /tmp and checked the dir kafka-logs-1 did not appear. I realized that there should be something wrong with my log.dir in config. I double checked it in the config/server-1.propeties. I found that there were two lines of log.dirs.
#copy from the tutorial
log.dirs=/tmp/kafka-logs-1
# default one
log.dirs=/tmp/kafka-logs
Of course the last one overridden the first one thus making the new broker point to the first broker with id=0.
After removing the last log.dirs and keep only one log.dirs ( log.dirs=/tmp/kafka-logs-1 ) works like a charm.
Make sure the log directories, broker id and ports are different for each node/broker.
Sample configuration (server.properties):
Broker 1
broker.id=1
listeners=PLAINTEXT://:9092
log.dirs=/tmp/kafka-1-logs
Broker 2
broker.id=2
listeners=PLAINTEXT://:9093
log.dirs=/tmp/kafka-2-logs
Broker 3
broker.id=3
listeners=PLAINTEXT://:9094
log.dirs=/tmp/kafka-3-logs
Hope this will help. Happy hacking!!