Apache Kafka

How to Install Apache Kafka on Windows

Hi, my fellow tech enthusiasts! Are you ready to dive into the exciting world of Apache Kafka?

If you’ve been itching to learn how to install this powerful, open-source distributed streaming platform on your Windows machine, you’ve come to the right place!

This easy-to-follow, step-by-step tutorial will guide you through setting up the Apache Kafka on your Windows PC in no time. With our friendly tone and detailed explanations, you’ll feel like you’re learning from a trusted friend who has your back every step of the way.

As you embark on this exhilarating journey, you’ll soon discover the many benefits of using Apache Kafka for real-time data streaming and processing. From improving the scalability of your applications to enhancing the fault tolerance and data durability, there’s a whole new world of possibilities just waiting for you to explore.

So, whether you’re a seasoned developer or a curious newcomer, let’s start this incredible adventure and master the art of installing Apache Kafka on Windows together!

Requirements:

For this tutorial, we will show you how to install Apache Kafka on Windows using the Windows Subsystem for Linux feature.

For compatibility, you are required to have the Windows 10 Build 1903 and higher.

Note: Although it is possible to run Kafka on JVM on native Windows, it lacks some features which are tied to POSIX. For example, you may encounter some Apache Kafka server crashes after modifying topics.

Setting Up WSL on Windows

Once you make sure that you have the required Windows build version, we can proceed and enable the WSL on your machine.

Click on the start menu and search for “turn windows features on or off”. Select the matching option.

In the Windows Features window, select the following features and make sure that they are enabled:

  1. Windows Subsystem for Linux
  2. Virtual Machine Platform

Click on “Ok” to apply the changes to your system. This may require you to restart your system.

Once restarted, we must enable the WSL version 2 to ensure that we have the latest kernel version. We can do this by installing the WSL version 2 kernel update installer that is provided in the following link: https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi

Once configured, we can proceed to the next step.

Installing a Linux Distro on WSL

Once WSL is enabled, we must install a Linux distribution that we will use. For this, we recommend using Ubuntu since it is highly optimized to work with WSL on a wide range of scenarios.

Open the PowerShell prompt as administrator and run the following command:

$ wsl --install -d ubuntu

The previous command downloads and installs Ubuntu on WSL with a simple command.

Once completed, you can launch it from the start menu or run the following command:

$ wsl --distribution ubuntu

This launches the Ubuntu distro on the machine. Next, wait for the install process to complete and setup your accounts.

Installing the Java JDK

Run the following command in the Ubuntu terminal to refresh the system repositories:

$ sudo apt-get update

Install the Java-common package with the following command:

$ sudo apt-get install java-common -y

Finally, run the following command to install the OpenJDK 11 on the system:

$ sudo apt install openjdk-11-jdk -y

Once completed, check if the JDK has been configured correctly by verifying its version:

$ java --version

Installing Apache Kafka

Open your browser and download the latest version of Apache Kafka as provided in the following link: https://kafka.apache.org/downloads

$ wget https://downloads.apache.org/kafka/3.4.0/kafka_2.13-3.4.0.tgz

Once downloaded, extract the archive to your target directory.

$ tar -xvf kafka.tgz

Rename the extracted directory to Kafka:

$ sudo mv kafka_2.13-3.4.0/ kafka

Finally, move the kafka directory to /opt:

$ sudo mv kafka /opt/

Start the Zookeeper Service

Apache Kafka uses Zookeeper for cluster management. Hence, we need to make sure that the Zookeeper service is running before running Kafka.

We can do this by running the following command:

./bin/zookeeper-server-start.sh /opt/kafka/config/zookeeper.properties

Make sure that you are in the Kafka directory before running the previous command.

Start the Apache Kafka Server

Open another Ubuntu shell window and run the following commands to start the Kafka server:

$ cd /opt/kafka

and

/opt/kafka$ ./bin/kafka-server-start.sh /opt/kafka/config/server.properties

This should start the Kafka server using the default server configuration.

Conclusion

We discussed about how to configure the Apache Kafka on Windows using the Windows subsystem for Linux. You can also check other installation methods such as running Apache Kafka on Windows using Docker.

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list