How to install Kafka on Windows?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Apache Kafka is a powerful distributed event streaming platform capable of handling trillions of events a day. Originally developed by Linkedin, Kafka is open-source and widely used for building real-time streaming data pipelines and applications. This guide will walk you through the process of installing Kafka on a Windows operating system.
Prerequisites
Before you start the installation process, you need to ensure your system meets the following requirements:
- Java: Kafka is written in Java, so you will need Java installed on your machine. Kafka 2.13 requires Java 8 or higher. You can download Java from Oracle's official site.
Step 1: Download Kafka
- Visit the official Apache Kafka website.
- Select the version of Kafka you want to download. It's generally recommended to download the latest stable release.
- Click on the 'Binary downloads' section and download the binary files for Windows.
Step 2: Extract Kafka
- Once the download is complete, extract the Kafka binaries to your desired location. For instance, you might extract it to
C:\kafka.
Step 3: Set Up the Environment
- Set JAVA_HOME Variable: You need to ensure that the JAVA_HOME environment variable is set to the path where Java is installed on your local machine.
- Right-click on 'This PC' and select 'Properties'.
- Click on 'Advanced system settings'.
- In the 'System Properties' window, click on 'Environment Variables'.
- Under 'System Variables', click 'New'. Set the variable name to
JAVA_HOMEand the variable value to the path where Java is installed.
Step 4: Start the Kafka Environment
Kafka uses ZooKeeper, so you first need to start a ZooKeeper server.
Start ZooKeeper Server
- Open a new command prompt as an administrator.
- Navigate to your Kafka directory (e.g.,
cd C:\kafka). - Run the command:
- Keep this command prompt open.
Start Kafka Server
- Open another command prompt as an administrator.
- Navigate to the Kafka directory (e.g.,
cd C:\kafka). - Run the command:
Step 5: Create a Topic
Now that you have your ZooKeeper and Kafka servers running, you can create a Kafka topic to store your messages.
- Open another command prompt window.
- Run:
Step 6: Test Kafka
To test if your Kafka broker is working correctly:
Producer Test
- Open a new command prompt.
- Send some messages:
Consumer Test
- Open another command prompt.
- Start the consumer:
You should see the messages you typed in the producer prompt.
Summary Table
| Step | Action | Command/Action |
| 1 | Download Kafka | Download from Apache |
| 2 | Extract Kafka Files | Extract to C:\kafka |
| 3 | Set JAVA_HOME | Set in System Environment Variables |
| 4 | Start ZooKeeper Server | .\bin\windows\zookeeper-server-start.bat .\config\zookeeper.properties |
| 4 | Start Kafka Server | .\bin\windows\kafka-server-start.bat .\config\server.properties |
| 5 | Create Kafka Topic | .\bin\windows\kafka-topics.bat --create --topic test --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 |
| 6 | Test Producer and Consumer | Test commands as shown above |
Additional Details
- Logging: Kafka logs details about system behavior, and you can find these files under
<your-kafka-folder>\logs. - Configuration Files: Kafka's configuration is held under the
configfolder. Key files areserver.properties(for Kafka servers) andzookeeper.properties(for ZooKeeper).
Conclusion
By following these steps, you can get Apache Kafka up and running on a Windows machine. This setup is ideal for development and testing purposes. For a production environment, Kafka should ideally be run on a Linux-based system with a robust cluster configuration.

