https://kafka.apache.org/quickstart
1. Config Kafka and Zookeeper
- Vào ./config
- Sửa zookeeper.properties
dataDir=C:/Apps/kafka_2.12-2.8.0/logs/zookeeper
- Sửa server.properties
listeners=PLAINTEXT://localhost:9092
###
log.dirs=C:/Apps/kafka_2.12-2.8.0/logs/kafka-logs
2. Run Server
1. Start zookeeper
bin\windows\zookeeper-server-start.bat config\zookeeper.properties
-- Có thể lưu lại file zookeeper-run.bat để chạy cho nhanh
1 2 3 4 5 6 |
title Zookeeper Server Running ... rmdir C:\Apps\kafka_2.12-2.8.0\logs /S /Q echo Remove logs done!. cd C:\Apps\kafka_2.12-2.8.0 .\bin\windows\zookeeper-server-start.bat .\config\zookeeper.properties pause |
2. Start kafka-server
bin\windows\kafka-server-start.bat config\server.properties
-- Có thể lưu lại file kafka-run.bat để chạy cho nhanh
1 2 3 4 |
title Kafka Server Running ... cd C:\Apps\kafka_2.12-2.8.0 .\bin\windows\kafka-server-start.bat .\config\server.properties pause |
3. Show all topics in Zookeeper
bin\windows\kafka-topics.bat --list --zookeeper localhost:2181
-- Có thể lưu lại file list-topics-kafka.bat để chạy cho nhanh
1 2 3 |
title List Topic Kafka cd C:\Apps\kafka_2.12-2.8.0 cmd /k bin\windows\kafka-topics.bat --list --zookeeper localhost:2181 |
4. Producer send message to topic: "alarm-unique"
bin\windows\kafka-console-producer.bat --topic alarm-unique --bootstrap-server localhost:9092
-- Có thể lưu lại file producer-send-message.bat để chạy cho nhanh
1 2 3 4 |
title Producer Send Message set /p topic="Enter Topic: " cd C:\Apps\kafka_2.12-2.8.0 bin\windows\kafka-console-producer.bat --topic %topic% --bootstrap-server localhost:9092 |