Setting up a Local Kafka Environment on Windows
===============================================
Note: It's recommended to place Kafka and ZooKeeper folders in the root directory (C:/Windows) without any spaces in the folder names to avoid potential issues.
Prerequisites
Step 1: Download Kafka and ZooKeeper
Download the following files:
Step 2: Extract Kafka and ZooKeeper
Extract the downloaded Kafka and ZooKeeper files to C:/Windows
.
Step 3: Configure ZooKeeper
- Navigate to
C:/Windows/zookeeper/conf
. - Rename
zoo_sample.cfg
tozoo.cfg
. - Edit
zoo.cfg
and setdataDir=C:/Windows/zookeeper/data
.
Step 4: Start ZooKeeper
Open a terminal and navigate to C:/Windows/zookeeper
. Run:
bin\zkServer.cmd
Step 5: Configure Kafka
- Navigate to
C:/Windows/kafka/config
. - Edit
server.properties
. - Set
zookeeper.connect=localhost:2181
.
Step 6: Start Kafka Server
Open a terminal and navigate to C:/Windows/kafka
. Run:
bin\windows\kafka-server-start.bat config\server.properties
Step 7: Create a Topic
In a new terminal, navigate to C:/Windows/kafka
. Run:
kafka-topics.bat --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic test
Step 8: Start Producer
In a new terminal, navigate to C:/Windows/kafka
. Run:
bin\windows\kafka-console-producer.bat --broker-list localhost:9092 --topic test
Step 9: Start Consumer
In a new terminal, navigate to C:/Windows/kafka
. Run:
bin\windows\kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test --from-beginning
Top comments (2)
Hey @codegreen thanks so much for this tutorial!!! I needed it
Only, it's necessary update the step 7, because the command was:
kafka-topics.bat --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic test
cause the version of Kafka!
Thanks @miguel_geredaz_7988998 for pointing out, updated the command👍