How to setup and install Apache Kafka in windows.
Hello Readers,
This blog will give you idea of Apache Kafka installation in windows system. It helps you understand how Kafka starts in your system just using command prompt?
Prerequisite:
Your local environment must have Java 8+ installed.
Steps to follow:
1. First visit to link: https://www.apache.org/dyn/closer.cgi?path=/kafka/3.4.0/kafka_2.13-3.4.0.tgz
a. Download latest version of kafka.
b. After downloading extract tar in your system and if you want to rename it then rename it to Kafka.
2. Now to work with Kafka we need to start zookeeper first because it handles brokers inside Kafka cluster as well as holds the configuration regarding producer, consumer and Kafka topics.
a. Now start Zookeeper service go to your Kafka folder and open terminal and execute below files.
.\bin\windows\zookeeper-server-start.bat .\config\zookeeper.properties
b. Once Zookeeper service started then start Kafka broker service using below file. Open new terminal and go to your Kafka folder and execute below files.
.\bin\windows\kafka-server-start.bat .\config\server.properties
c. Then you can check logs in terminal Kafka broker service is started on 9092 port (localhost:9092) by default.
3. Now you can create new topic in Kafka broker to store you event using below file and command
go to your Kafka folder and open terminal, paste below command and press enter
.\bin\windows\kafka-topics.bat --create --topic first-event-topic --bootstrap-server localhost:9092
4. Once topic is created then we need to produce some event which is possible by using Kafka producer so for that will execute below command.
.\bin\windows\kafka-console-producer.bat --topic first-event-topic --bootstrap-server localhost:9092
a. Now pass some events
for example:
one
two
three
then press enter and ctrl + c and type Y to exit.
If we pass any event then we also need consumer to consume the events so for that will execute below command.
.\bin\windows\kafka-console-consumer.bat --topic first-event-topic --from-beginning --bootstrap-server localhost:9092
Thank you for reading. Hope this will help you. :)