Getting Kafka 0.8.0 running on Windows isn’t straight forward if you follow the instructions. They are somewhat misleading, and the bat files are old. But with correct instructions and updated bat files it’s easy and can be done under 10 minutes. Some say you need Cygwin in order to run Kafka. This is not true. Only Server JRE is required.
Step 0. Prerequisite – Java SE Server JRE
You need Java SE Server JRE in order to run Kafka. If you have JDK installed, you already have Server JRE installed.
- Download Java SE Server JRE
For me Chrome changed the extension. If that happens change it back to .tar.gz in order to unpack it.
- Unpack it to a folder, for example c:\JreServer
Update the system environment variable PATH to include C:\JreServer\jre\bin (Control Panel and search for environment variable).
Step 1. Download Kafka
- Download the binaries for Kafka from http://kafka.apache.org/downloads.html
- Unzip to a folder, for example c:\kafka
Update the bat files
Unfortunately the bat files for Kafka 0.8.0 are full of errors, so in order to start Zookeeper and Kafka they must be replaced.
- Download updated windows bat files from https://github.com/HCanber/kafka/releases
- Unzip and copy them into c:\kafka\bin\windows (overwrite the files already there)
The config files need to be updated.
- Open config\server.properties and locate
log.dirs=/tmp/kafka-logs. If you keep the default it will result in an error later on. Set it to a full path without . or .. in it and with forward slashes. Example:
- This step is optional but you might want to set the data directory for Zookeeper as well. Open config\zookeeper.properties and locate
Step 2. Start the server
Note! Before executing the commands below you need to change directory to the folder where you unzipped Kafka:
- Start Zookeeper in a Command Prompt or PowerShell Console.
- Start Kafka in another Command Prompt or PowerShell Console.
Step 3. Create a topic
- Create a topic.
.\bin\windows\kafka-create-topic.bat --zookeeper localhost:2181 --replica 1 --partition 1 --topic test
- List topics.
.\bin\windows\kafka-list-topic.bat --zookeeper localhost:2181
Step 4. Send some messages
- Start Console Producer
.\bin\windows\kafka-console-producer.bat --broker-list localhost:9092 --topic test
- Write some messages
This is a message This is another message
Step 5. Start a consumer
- Start Console Consumer
.\bin\windows\kafka-console-consumer.bat --zookeeper localhost:2181 --topic test --from-beginning