4

Using Kafka on Ubuntu: Zookeeper started Kafka started Topic Created Producer started Consumer started Messages are delivering fine from producer to consumer

I created 2 new server.properties files as: server-1.properties as:

broker.id=1
listeners=PLAINTEXT://:9093
log.dir=C:\kafka\kafka-logs-1

server-2.properties as:

broker.id=2
listeners=PLAINTEXT://:9094
log.dir=C:\kafka\kafka-logs-2

When i started the new broker as:

bin\windows\kafka-server-start.sh config\server-1.properties &

Got Error as:

kafka.common.KafkaException: Socket server failed to bind to 0.0.0.0:9092: Address already in use: bind
Giorgos Myrianthous
  • 36,235
  • 20
  • 134
  • 156
Rahul Sharma
  • 43
  • 1
  • 5

4 Answers4

4

This happens because the brokers you've added, are both listening to port 9092 which is currently in use by the first broker.

In server-1.properties file you need to add

port=9093

and in server-2.properties

port=9094

Keep these lines listeners=PLAINTEXT://:9093, listeners=PLAINTEXT://:9094 commented out.

Also make sure you use different broker.id for every instance.

If you are trying to setup a Multi-broker Kafka Cluster with a single Zookeeper node, you might find this video useful.

Giorgos Myrianthous
  • 36,235
  • 20
  • 134
  • 156
2

if you are using multiple brokers then use the following type of broker declaration on the

server.properties

broker.id=0
listeners=PLAINTEXT://:9092
log.dirs=/tmp/kafka-logs

server.1.properties

broker.id=1
listeners=PLAINTEXT://:9093
log.dirs=/tmp/kafka-logs1

server.2.properties

broker.id=2
listeners=PLAINTEXT://:9094
log.dirs=/tmp/kafka-logs2

server.3.properties

broker.id=3
listeners=PLAINTEXT://:9095
log.dirs=/tmp/kafka-logs3
Saurabh Verma
  • 627
  • 1
  • 14
  • 27
0

I had the same issue on my local setup with 3 different vms running kafka and 1 zookeeper, 2 were starting fine except one. I was referred to check the /etc/hosts which had wrong ip set to the name, after fixing that my 3 brokers started without any issue

Loki
  • 51
  • 3
0

If you are running confluent version, make sure to update the following

first broker: confluent.metadata.server.listeners=http://0.0.0.0:8090

second broker: confluent.metadata.server.listeners=http://0.0.0.0:8091

Venkat Papana
  • 4,757
  • 13
  • 52
  • 74