Kafka Windows Development Environment

January 31, 2022
 
Installing Kafka Broker Locally on Windows Dev Box
Download Kafka
https://kafka.apache.org/downloads  



Uncompress/Unzip the tgz file and place the results into your desired location.

For this demonstration I am using this location: C:\DevBox\kafka\kafka_2.13-3.1.0 adapt the following instructions to match your location.

Create the following directories:
  • C:\DevBox\kafka\kafka_2.13-3.1.0\data
  • C:\DevBox\kafka\kafka_2.13-3.1.0\data\kafka
  • C:\DevBox\kafka\kafka_2.13-3.1.0\data\zookeeper

Configurations

Zookeeper
Update the dataDir value in the zookeeper configuration to use your new data directory:
Edit C:\DevBox\kafka\kafka_2.13-3.1.0\config\zookeeper.properties
dataDir=C:/DevBox/kafka/kafka_2.13-3.1.0/data/zookeeper (notice slash direction change)
 
Kafka
Update the log.dirs value in the Kafka configuration to use your new directory:
Edit C:\DevBox\kafka\kafka_2.13-3.1.0\config\server.properties
log.dirs=C:/DevBox/kafka/kafka_2.13-3.1.0/data/kafka  
 

Start

Navigate to the installation directory:
cd C:\DevBox\kafka\kafka_2.13-3.1.0  
The Windows Batch files are located in the bin:
cd C:\DevBox\kafka\kafka_2.13-3.1.0\bin\windows
 
Zookeeper
zookeeper-server-start.bat ..\..\config\zookeeper.properties
 
Kafka
kafka-server-start.bat ..\..\config\server.properties
 

Using Kafka

Now that Kafka is installed and running, you can create your first topic:
kafka-topics --bootstrap-server localhost:9092 --topic code_gorilla --create --partitions 3 --replication-factor 1  
 
You can confirm the creation of your topic by listing all the topics:
kafka-topics --bootstrap-server localhost:9092 --list  
 
You can also confirm that your data folder is being used by looking in the data directories:
 
 

 
If you want to test out the functionality you could perform simple operations from the command line to see your Kafka broker in action.
 
Consuming
Start up a consumer that will be waiting for messages in the topic:
kafka-console-consumer --bootstrap-server localhost:9092 --topic code_gorilla
 
Producing
Start the command line producer which will provide a prompt for you to enter messages.
kafka-console-producer --broker-list localhost:9092 --topic code_gorilla
Enter messages on the producer screen and you should see them displayed on the consumer screen. CTRL+C to exit

 
Return to articles