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. If you have JRE already installed we can proceed.
We need Zookeeper server running to run Kafka. We will see why do we need Zookeeper in the next few articles on Kafka. Following are steps to install Zookeeper on windows.
- Download Apache Zookeeper. You can use this link.
- 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.
- Go to Zookeeper config directory that is “C:/Zookeeper/conf”
- Rename file “zoo_sample.cfg” to “zoo.cfg”
- 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)
- Now we need to add Zookeeper to system environment variables. You can open that from Control Panel -> System -> Advanced System Settings ->Environmentt Variables
- In user variable, click on New then enter ZOOKEEPER_HOME as variable name and value as “C:/Zookeeper”.
- Edit System variable named Path. Click on new and add “%ZOOKEEPER_HOME%\bin” as a new variable to the path.
- Open a new command prompt and type zkserver. Zookeeper runs on port number 2181 by default. You can change that in conf file.
If you see output like this then Zookeeper is running successfully on your windows machine!!
- Download latest version of Kafka from here.
- Extract downloaded the file to a directory named Kafka and move that directory to some location like C drive.
- Go to Kafka config directory. “C:\kafka\config”
- Edit server.properties file and find log.dirs and change that to “log.dirs=C:\kafka\config\kafka-logs”
- After that Kafka will run on port number 9092 by default.
Running Kafka Server:
- Make sure that Zookeeper server is running on your machine.
- Open another command prompt and type command C:\>.\kafka\bin\windows\kafka-server-start.bat .\kafka\config\server.properties
- If everything is configured correctly you will see the following output
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
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.