Launching multiple Kafka brokers fails

2019-06-16 20:40发布

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.

5条回答
在下西门庆
2楼-- · 2019-06-16 21:00

And, speaking from experience, don't forget to edit the broker.id entries in the kafka-logs-*/meta.properties files to match your changes (or delete the files and let kafka regenerate them).

查看更多
倾城 Initia
3楼-- · 2019-06-16 21:13

Make sure in your server.properties and serverTest.properties you have different log.dirs

If you had to make any log.dirs changes don't forget to remove previous folders stored on your PC

查看更多
走好不送
4楼-- · 2019-06-16 21:19

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 :)

查看更多
我命由我不由天
5楼-- · 2019-06-16 21:19

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.

查看更多
成全新的幸福
6楼-- · 2019-06-16 21:25

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

查看更多
登录 后发表回答