Menu

Installing and Setting Up Apache Kafka

4. Installing and Setting Up Apache Kafka

a. Kafka Prerequisites

Before you install Kafka, you need a few basic tools in place. Kafka requires JDK 11 or later because the broker runs on the JVM. For the Python examples in this course, you also need Python 3.8 or later and the confluent-kafka library.

It is smart to verify those first with java -version and pip install confluent-kafka. That way, you catch setup issues early instead of discovering them halfway through your first Kafka script. A little checking up front saves a lot of confusion later.

b. Installing Kafka on Windows

Kafka can run directly on Windows, but many developers find WSL easier to work with. The native Windows scripts do work, but file path limits and line-ending differences can sometimes make setup annoying. WSL avoids many of those issues by giving you a Linux-like environment.

After downloading and extracting Kafka, Windows users can run the .bat scripts in bin\windows\. Even so, WSL with Ubuntu is often the smoother choice for beginners. It also matches the Linux-style setup used in many production environments.

c. Installing Kafka on Linux

Linux is the most common environment for Kafka development and production. Installation usually means downloading the Kafka binaries, extracting them, and setting up the broker for KRaft mode. This replaces the older ZooKeeper-based approach described in older guides.

On Ubuntu, the setup usually includes generating a cluster ID, formatting storage, and starting the broker with the server properties file. Once that is complete, Kafka is ready to accept connections. For beginners, this is usually the cleanest way to get a working Kafka installation.

d. Starting Kafka Services

Starting Kafka in KRaft mode usually means launching the broker with the right configuration. In a small development setup, one command can start both the broker and controller roles together. That is enough for local testing and learning.

A simple way to confirm the broker is running is to list topics using the bootstrap server address. If Kafka responds, the service started correctly. If you get a connection error, it usually means the broker did not come up properly.

Comparison: Windows vs Linux Setup

Aspect

Windows

Linux

Ease of setupModerateEasier
Common workflowWSL preferredNative
Path issuesMore likelyLess likely
Production similarityLowerHigher