DEV Community

Manish Thakurani for CodeGreen

Posted on

Setting up a Local Kafka Environment on Windows

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

  1. Navigate to C:/Windows/zookeeper/conf.
  2. Rename zoo_sample.cfg to zoo.cfg.
  3. Edit zoo.cfg and set dataDir=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

  1. Navigate to C:/Windows/kafka/config.
  2. Edit server.properties.
  3. 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:

bin\windows\kafka-topics.bat --create --zookeeper localhost:2181 --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

Now you have a local Kafka environment set up on your Windows machine!

Top comments (0)