Apache Kafka multi-broker Setup in Windows

Prerequisite

Before proceeding, you need to have java and Kafka installed.
For Kafka setup refer to https://medium.com/@catchanilonline/apache-kafka-setup-in-windows-420f3cfd33b9

Setup

2. Update these properties as shown below

in “server0.properties” file
broker.id=0
log.dirs=D:/kafka/data/kafka0
listeners=PLAINTEXT://your.host.name:9092

in “server1.properties” file
broker.id=1
log.dirs=D:/kafka/data/kafka1
listeners=PLAINTEXT://your.host.name:9093

in “server2.properties” file
broker.id=2
log.dirs=D:/kafka/data/kafka2
listeners=PLAINTEXT://your.host.name:9094

3. Create three new folders in “D:/kafka/data” as kafka0, kafka1, kafka2

4. First, start zookeeper

D:\kafka>zookeeper-server-start.bat config\zookeeper.properties

5. Now start one by one all three brokers as shown below

start kafka0 broker
D:\kafka>kafka-server-start.bat config\server0.properties

start kafka1 broker
D:\kafka>kafka-server-start.bat config\server1.properties

start kafka2 broker
D:\kafka>kafka-server-start.bat config\server2.properties

6. Testing the setup, using the below commands

kafka-topics — zookeeper 127.0.0.1:2181 — topic multi-reps — create — partitions 6 — replication-factor 3

kafka-topics — zookeeper 127.0.0.1:2181 — topic multi-reps — describe

Great, we are all set.

Happy Programming!