Kafka cơ bản

Author: - Posted: 07/01/22 - Update: 20/08/22

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

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

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

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