Install Apache Kafka On Windows

This quick tutorial is going to cover how to install Apache Kafka on Windows.

1. Prerequisites

  • Install Java (The latest released version of JDK 1.8 is recommended)

2. Download Apache Kafka Distribution

Download an Apache Kafka distribution from its website. The current version is After downloading, extract it to any desired location, for example, D:\kafka_2.11- Then open Command Prompt (cmd) and go to that directory:

3. Start the server

3.1. Start ZooKeeper

Kafka uses ZooKeeper so you will need to first start a ZooKeeper server first. And you can use your own ZooKeeper or use the single-node ZooKeeper instance packaged with Apache Kafka. In this tutorial, we will use the ZooKeeper packaged with Kafka.

Let’s start the ZooKeeper by running the below command:

The successful start will output the logs to the command prompt similarly to below:

ZooKeeper is running on the port 2181.

3.2. Start Kafka Server

To start the Kafka server, we need to open another command prompt, go to the Apache Kafka directory and run following commands:

Kafka broker will listen on port 9092.

4. Basic Operations with Apache Kafka

4.1. Create a topic

Let’s create a topic named “hello-kafka” with a single partition and only one replica by opening a new command prompt and run the following command:

We can now see that topic if we run the list topic command:

The output is:

Note that instead of creating topic manually, we can configure Kafka brokers so that it can automatically create topics when a non-existent topic is published to.

4.2 Start Producer and Send Messages

We can use Kafka command line client that will take input from standard input and send it out as messages to the Kafka cluster. By default, each line will be sent as a separate message. Let’s send some messages to the server (topic: “hello-kafka”) by opening a new Command Prompt and run the following command:

Then enter some messages into the console, for example:

4.2 Start Consumer and Receive Messages

In similar to above, we can use Kafka command line to start consumer that will dump out messages to standard output. Let’s consume messages from the “hello-kafka” topic:

The output will be:

For some more operations with Apache Kafka, you can refer to another related article Apache Kafka Command Line Interface

5. Conclusion

The tutorial has illustrated us how to install Apache Kafka on Windows step by step. We got through how to download Kafka distribution, start ZooKeeper, Apache Kafka server, send messages and receive messages from Kafka server as well.

If you want to learn more about Apache Kafka, please check our other related articles:

Apache Kafka Tutorial

Getting started with Apache Kafka 0.9

Apache Kafka 0.9 Java Client API Example

Create Multi-threaded Apache Kafka Consumer

How To Write A Custom Serializer in Apache Kafka

Write An Apache Kafka Custom Partitioner

Apache Kafka Connect Example

Apache Flume Kafka Source And HDFS Sink Tutorial

Apache Kafka Connect MQTT Source Tutorial