DEV Community

Code Green
Code Green

Posted on • Edited on

5

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:

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

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

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (2)

Collapse
 
miguel_geredaz_7988998 profile image
Miguel Güere Díaz

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!

Collapse
 
codegreen profile image
Code Green • Edited

Thanks @miguel_geredaz_7988998 for pointing out, updated the command👍

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs