Setup Apache Kafka Environment on Windows
Tags: microservices, data
Published: 2021-03-25 10:14:18

In this article, I will be walking you through the process of installing Apache Kafka successfully on Windows. Let's dive into it.

## Why use Apache Kafka?
Apache Kafka is an open-source distributed event streaming platform used by thousands of companies for high-performance data pipelines, streaming analytics, data integration, and mission-critical applications. You can use Kafka for real-time data streaming, big data collection, and real-time data analysis. It can be used with in-memory microservices ensuring durability. It will allow you to feed events to complex event streaming systems. It is one of the most commonly used fault-tolerant messaging systems.

## Prerequisites
- Download and Install the Java Runtime Environment (JRE8).
This can be done in two different ways which are by:
 - Download from the Oracle Java Official Downloads Page [here](https://www.oracle.com/java/technologies/javase-jre8-downloads.html)
 - Install using Chocolatey by pasting this script on your windows command line.

``` shell
choco install jdk8
```

 After installing, confirm your Java installation 

``` shell
java --version
```

- [Download](https://zookeeper.apache.org/releases.html) and Install Apache Zookeeper

Apache Zookeeper helps keeps track of the status of the Kafka cluster nodes and it also keeps track of Kafka topics, partitions.


## Get Started with Apache Kafka

For the installation process, please follow the steps given below:

#### Step 1: Visit Apache Kafka Official Download Page

- Download the latest stable release of Apache Kafka Binaries - https://kafka.apache.org/downloads


![apache-download page.png](https://res.cloudinary.com/dksyt7yvf/image/upload/v1615990418/EiK4kLYjo_xajvgs.png)
 

#### Step 2: Extract Apache Folder

- Visit your downloads folder 
- Extract the downloaded file and move it to any folder of your choice. For this tutorial, I recommend moving to the ` C:/ ` folder.

#### Step 3: Create directories for storing Kafka/zookeeper snapshots and logs
After moving  to the ` C:/ ` folder ;
- Create a ` data ` folder in the Kafka directory
- Create  ` Kafka ` and ` zookeeper ` directories inside the ` data ` folder

![Data folder in kafka](https://res.cloudinary.com/dksyt7yvf/image/upload/v1615991655/kafka_3_17_2021_3_30_48_PM_b9de1j.png)
![kafka-zookeeper folder in data dir](https://res.cloudinary.com/dksyt7yvf/image/upload/v1615991725/kafka_3_17_2021_3_30_51_PM_eetqu4.png)

#### Step 4: Update configuration file for Zookeeper and Kafka Logs

- In ` C:/kafka `, open the config folder in a text editor and update the ` zookeeper.properties ` file.
Change the `dataDir` variable to the path where your zookeeper snapshots will be stored as shown in the image below. 

![zookeeper-config-file](https://res.cloudinary.com/dksyt7yvf/image/upload/v1615993409/zookeeper.properties_-_koledashboard_-_Visual_Studio_Code_3_17_2021_3_48_25_PM_pfomkd.png)

- In the same config folder, update the `server.properties` file.
Update the `log.dirs` variable to the path where your Kafka logs will be stored.

![kafka-config-file](https://res.cloudinary.com/dksyt7yvf/image/upload/v1615993463/server.properties_-_koledashboard_-_Visual_Studio_Code_3_17_2021_3_48_07_PM_lghp33.png)


#### Step 5: Start Apache Zookeeper and Kafka
- Start Apache zookeeper, 
Open windows  command prompt, change your directory to ` c:/ ` and run the following scripts

```
cd kafka/bin/windows
```

```
zookeeper-server-start.bat ../../config/zookeeper.properties
```

- Start Apache Kafka, open up a new command prompt 

Run the following command from `C:\kafka\bin\windows` directory

```bash

kafka-server-start.bat  ../../config/server.properties

```

Apache Kafka should start running successfully on your machine 🎉🎉🎉🎉


## Conclusion

Apache Kafka is now successfully installed on your machine, you can start making use of Kafka for event and data streaming. Learn more about [Kafka Use cases](https://kafka.apache.org/documentation/#uses) and applications.

If you have any questions, don't hesitate to reach out me on Twitter: [@adeileri](https://twitter.com/adeileri)