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 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 Kafka server. You can check How to Install Java on Windows here. If you have JRE already installed we can proceed.

Zookeeper Installation:

We need Zookeeper server running to run Kafka. We will see why do we need Zookeeper in next few articles on Kafka. 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

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

 

Kafka Configuration:

  1. Download latest version of Kafka from here.
  2. Extract downloaded file to a directory named Kafka and move that directory to some location like C drive.
  3. Go to Kafka config directory. “C:\kafka\config”
  4. Edit server.properties 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\server.properties
  3. If everything is configured correctly you will see following output

 

Kafka_server

Now your Kafka server is running on port number 9092. Let us validate this by listing topics present in 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

Kafka_topic_list

 

 

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

I am passionate about data analytics, machine learning, and artificial intelligence. Recently I have started blogging about my experience while learning these exciting technologies.

Leave a Reply

Close Menu