Categories: Mule 4Mulesoft

Running Apache Kafka on Windows OS

In this tutorial, we will look at the step-by-step process for Kafka Installation on Windows. Kafka is an open-source stream-processing software platform and comes under the Apache software foundation.

Installation :

Download the kafka from https://kafka.apache.org/downloads

Java Setup:

Kafka requires Java 8 for running. And hence, this is the first step that we should do to install Kafka. To install Java, there are a couple of options. We can go for the Oracle JDK version 8 from the Official Oracle Website.

Kafka & Zookeeper Configuration:

Step 1: Download Apache Kafka from its Official Site.

Step 2: Extract tgz via cmd or from the available tool to a location of your choice. Copy the path of the Kafka folder. Now go to config inside Kafka folder and open zookeeper.properties file. Copy the path against the field dataDir and add /zookeeper-data to the path.

Step 3: we have to modify the config/server.properties file. Below is the change:

Basically, we are pointing the log.dirs to the new folder /data/kafka.

Run Kafka Server:

Step 1: Kafka requires Zookeeper to run. Basically, Kafka uses Zookeeper to manage the entire cluster and various brokers. Therefore, a running instance of Zookeeper is a prerequisite to Kafka.

To start Zookeeper, we can open a PowerShell prompt and execute the below command:

.\bin\windows\zookeeper-server-start.bat .\config\zookeeper.properties

If the command is successful, Zookeeper will start on port 2181.

Step 2: Now open another command prompt and change the directory to the kafka folder. Run kafka server using the command:

.\bin\windows\kafka-server-start.bat .\config\server.properties

Now your Kafka Server is up and running, you can create topics to store messages. Also, we can produce or consume data directly from the command prompt.

Create a Kafka Topic:

  1. Open a new command prompt in the location C:\kafka\bin\windows.
  2. Run the following command:
kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test

Creating Kafka Producer:

  1. Open a new command prompt in the location C:\kafka\bin\windows
  2. Run the following command:
kafka-console-producer.bat --broker-list localhost:9092 --topic test

Creating Kafka Consumer:

  1. Open a new command prompt in the location C:\kafka\bin\windows.
  2. Run the following command:
kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test --from-beginning

If you see these messages on consumer console,Congratulations!!! you all done. Then you can play with producer and consumer terminal bypassing some Kafka messages.

note: also read about Keywords in C & Variables & Constants in C.

Follow Me

If you like my post please follow me to read my latest post on programming and technology.

https://www.instagram.com/coderz.py/

https://www.facebook.com/coderz.py

Recent Posts

Generate Parenthesis | Intuition + Code | Recursion Tree | Backtracking | Java

Problem Statement: Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. Example…

3 months ago

Square Root of Integer

Given an integer A. Compute and return the square root of A. If A is…

1 year ago

Build Array From Permutation

Given a zero-based permutation nums (0-indexed), build an array ans of the same length where…

1 year ago

DSA: Heap

A heap is a specialized tree-based data structure that satisfies the heap property. It is…

2 years ago

DSA: Trie

What is a Trie in DSA? A trie, often known as a prefix tree, is…

2 years ago

Trees: Lowest Common Ancestor

What is the Lowest Common Ancestor? In a tree, the lowest common ancestor (LCA) of…

2 years ago