0% found this document useful (0 votes)
42 views2 pages

and Change Required Properties

1. Download and unzip Kafka from the provided link, then modify the log and data directory properties in server.properties and zookeeper.properties files respectively. 2. Start Zookeeper using zookeeper-server-start.bat, then start Kafka using kafka-server-start.bat. 3. Create a topic called "mytopic" with one partition using kafka-topics.bat.

Uploaded by

Saurabh Mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views2 pages

and Change Required Properties

1. Download and unzip Kafka from the provided link, then modify the log and data directory properties in server.properties and zookeeper.properties files respectively. 2. Start Zookeeper using zookeeper-server-start.bat, then start Kafka using kafka-server-start.bat. 3. Create a topic called "mytopic" with one partition using kafka-topics.bat.

Uploaded by

Saurabh Mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Download and Change Required Properties

1. Download Kafka from here (kafka_2.9.1-0.8.2.2) and unzip at your desired location.
2. Go to <kafka_dir>\config\server.properties file and change log file location property
'log.dirs' as per your environment.
log.dirs=<kafka_dir>\kafka-logs
3. Go to <kafka_dir>\config\zookeeper.properties file and change data directory
location property 'dataDir' as per your environment
dataDir=<kafka_dir>\zookeeper-data

Start Zookeeper and Kafka Servers


Kafka internally uses Zookeeper. If you would like to get more detail on Zookeeper
you can refer this link.
First you need to start Zookeeper server. To start it, execute below command:
<kafka_dir>\bin\windows\zookeeper-server-start.bat
..\..\config\zookeeper.properties
Now open another command prompt and start Kafka server:
<kafka_dir>\bin\windows\kafka-server-start.bat ..\..\config\server.properties

Create Topic
Now you need to create topic to publish and subscribe messages. To create topic you
just need to execute below command. As per below command you will be creating
topic 'mytopic' with single partition.
<kafka_dir>\bin\windows\kafka-topics.bat --create --zookeeper localhost:2181
--replication-factor 1 --partitions 1 --topic mytopic
After executing above command you must see below message on command prompt:
Created topic "mytopic".

Produce and Consume Messages


Open a command prompt and execute below command. This command prompt will be
treated as
producer.
<kafka_dir>\bin\windows\kafka-console-producer.bat --broker-list localhost:9092
--topic mytopic

Now open another command prompt and execute below command. This command
prompt will be treated as consumer.
<kafka_dir>\bin\windows\kafka-console-consumer.bat --zookeeper localhost:2181
--topic mytopic
If you will type any message in the producer command prompt and press enter, it will
be consumed by consumer and you must be able to see the same message in consumer
command prompt.

You might also like