How to install Kafka on Windows

Updated On - December 28, 2019  |  By Mahesh Mogal

In this article, we will learn how to install Kafka on Windows. There are a couple of options to install Kafka on Windows. One way is we can install docker on windows and then run the container of Kafka in that docker. We will be installing the standalone version of Kafka on Windows.

First, we need JRE (Java Runtime Environment) for running the Kafka server. You can check How to Install Java on Windows. If you have JRE already installed we can proceed.

Zookeeper Installation:

We need a Zookeeper server running to run Kafka. We will see why do we need Zookeeper in the next few articles on Kafka. The following are steps to install Zookeeper on windows.

  1. Download Apache Zookeeper. You can use this link.
  2. Extract downloaded Zookeeper files and rename that folder to Zookeeper (remove the version number from folder name). Keep that folder on location like C drive.
  3. Go to Zookeeper config directory that is "C:/Zookeeper/conf"
  4. Rename file “zoo_sample.cfg” to “zoo.cfg”
  5. We need to change dataDir in conf file. Open conf file in some editor like notepad++ or sublime text. Find dataDir and replace it with "dataDir=C:\zookeeper\data" (without quotes)
  6. Now we need to add Zookeeper to system environment variables. You can open that from Control Panel -> System -> Advanced System Settings ->Environmentt Variables
    1. In user variable, click on New then enter  ZOOKEEPER_HOME as variable name and value as "C:/Zookeeper".
    2. Edit System variable named Path. Click on new and add "%ZOOKEEPER_HOME%\bin" as a new variable to the path.
  7. Open a new command prompt and type zkserver.  Zookeeper runs on port number 2181 by default. You can change that in conf file.
Zookeeper server output in shell

If you see output like this then Zookeeper is running successfully on your windows machine!!

Kafka Configuration:

  1. Download the latest version of Kafka from here.
  2. Extract downloaded the file to a directory named Kafka and move that directory to some location like C drive.
  3. Go to the Kafka config directory. "C:\kafka\config"
  4. Edit file and find log.dirs and change that to "log.dirs=C:\kafka\config\kafka-logs"
  5. After that Kafka will run on port number 9092 by default.

Running Kafka Server:

  1. Make sure that Zookeeper server is running on your machine.
  2. Open another command prompt and type command                                                                                                      C:\>.\kafka\bin\windows\kafka-server-start.bat .\kafka\config\
  3. If everything is configured correctly you will see the following output
Kafka server output when running in shell

Now your Kafka server is running on port number 9092. Let us validate this by listing topics present in the Kafka server. Open another terminal and write following command

C:\>kafka\bin\windows\kafka-topics.bat --zookeeper localhost:2181 --list

You will see output like this

checking Kafka topics in server

If you get output like this you are all set. Kafka is configured on your machine. In the next articles, we will learn more about Kafka in detail.

Install Kafka on Windows
Mahesh Mogal
I am passionate about Cloud, Data Analytics, Machine Learning, and Artificial Intelligence. I like to learn and try out new things. I have started blogging about my experience while learning these exciting technologies.

Stay Updated with Latest Blogs

Get latest blogs delivered to your mail directly.

Recent Posts

Partitioning in Hive

Using Partitioning, We can increase hive query performance. But if we do not choose partitioning column correctly it can create small file issue.

Partitioning in Hive
Read More
Hive Data Manipulation - Loading Data to Hive Tables

We will learn how to load and populate data to hive table. We will also learn how to copy data to hive tables from local system.

Loading Data to Hive Tables
Read More
Create, Alter, Delete Tables in Hive

We will learn how to create Hive tables, also altering table columns, adding comments and table properties and deleting Hive tables.

manage tables in hive -2
Read More

Leave a Reply

Your email address will not be published. Required fields are marked *

2 comments on “How to install Kafka on Windows”

linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram
Share via
Copy link