DEV Community

Carlos A. Martinez
Carlos A. Martinez

Posted on • Updated on

How to Install and Run Apache Kafka on Windows?

Hi coders

Apache Kafka

Apache Kafka is an open-source distributed event streaming platform used by thousands of companies for high-performance data pipelines, streaming analytics, data integration, and mission-critical applications.

Download Apache Kafka

Save and extract file for example:
C:\Software\Kafka\kafka_2.13-3.1.0

Change the directory into file zookeper.properties and server.properties

zookeper.properties

Image description

Typing next command

> zookeeper-server-start.bat ..\..\config\zookeeper.properties

On Windows

> \bin\windows>zookeeper-server-start.bat ..\..\config\zookeeper.properties

Image description

server.properties

Image description

Typing next command

> kafka-server-start.bat ..\..\config\server.properties

Topic

Create

>kafka-topics.bat --bootstrap-server localhost:9092 --create --replication-factor 1 --partitions 1 --topic test1

Created topic test1.

Create 2

>.\kafka-topics.bat --bootstrap-server localhost:9092 --create --topic test_topic1 -partitions 5 --replication-factor 1
WARNING: Due to limitations in metric names, topics with a period ('.') or underscore ('_') could collide. To avoid issues it is best to use either, but not both.
Created topic test_topic1.

Describe

>kafka-topics.bat --bootstrap-server localhost:9092 --describe --topic test1

Topic: test1
TopicId: dhcREXgtS1e_047--6necw
PartitionCount: 1
ReplicationFactor: 1
Configs: segment.bytes=1073741824
Topic: test1
Partition: 0
Leader: 0
Replicas: 0
Isr: 0

Describe 2

> .\kafka-topics.bat --bootstrap-server localhost:9092 --describe --topic test_topic1


Topic: test_topic1 TopicId: XZj8OwdcQ_OBWs7AEyUQ4A PartitionCount: 5 ReplicationFactor: 1 Configs: segment.bytes=1073741824
Topic: test_topic1 Partition: 0 Leader: 0 Replicas: 0 Isr: 0
Topic: test_topic1 Partition: 1 Leader: 0 Replicas: 0 Isr: 0
Topic: test_topic1 Partition: 2 Leader: 0 Replicas: 0 Isr: 0
Topic: test_topic1 Partition: 3 Leader: 0 Replicas: 0 Isr: 0
Topic: test_topic1 Partition: 4 Leader: 0 Replicas: 0 Isr: 0

List

>kafka-topics.bat --bootstrap-server localhost:9092 --list

test1

Update

>kafka-topics.bat --bootstrap-server localhost:9092 --alter --topic test1 --partitions 10

Delete

>kafka-topics.bat --bootstrap-server localhost:9092 --delete --topic test1

Producer

Create

>kafka-console-producer.bat --broker-list localhost:9092 --topic
test1

holi
qeu mas
carlos
hola

Consumer

Create

>kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test1 --from-beginning
holi
qeu mas
carlos
hola

>kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test1 --from-beginning --property print.key=true --property key.separator=" - "

  • --property print.key=true
  • --property key.separator=" - "

Source

Top comments (0)