# jdk 설치
$ sudo apt-get update
$ sudo apt-get install -y openjdk-11-jdk
# 카프카 다운로드 (https://kafka.apache.org/downloads)
cd /usr/local
sudo wget https://downloads.apache.org/kafka/3.3.1/kafka_2.13-3.3.1.tgz
# 압축해제
sudo tar -xvf kafka_2.13-3.3.1.tgz
sudo mv kafka_2.13-3.3.1 kafka
# 주키퍼 데몬 등록
sudo vi /etc/systemd/system/zookeeper.service
[Unit]
Description=Apache Zookeeper service
Documentation=http://zookeeper.apache.org
Requires=network.target remote-fs.target
After=network.target remote-fs.target
[Service]
Type=simple
ExecStart=/usr/local/kafka/bin/zookeeper-server-start.sh /usr/local/kafka/config/zookeeper.properties
ExecStop=/usr/local/kafka/bin/zookeeper-server-stop.sh
Restart=on-abnormal
[Install]
WantedBy=multi-user.target
# 카프카 데몬 등록
sudo vi /etc/systemd/system/kafka.service
[Unit]
Description=Apache Kafka Service
Documentation=http://kafka.apache.org/documentation.html
Requires=zookeeper.service
[Service]
Type=simple
ExecStart=/usr/local/kafka/bin/kafka-server-start.sh /usr/local/kafka/config/server.properties
ExecStop=/usr/local/kafka/bin/kafka-server-stop.sh
[Install]
WantedBy=multi-user.target
# 데몬 등록
sudo systemctl daemon-reload
# 주키퍼 실행
sudo systemctl start zookeeper
sudo systemctl status zookeeper
# 카프카 실행
sudo systemctl start kafka
sudo systemctl status kafka
# 자동실행 등록
sudo systemctl enable zookeeper
sudo systemctl enable kafka
# 테스트
cd /usr/local/kafka/bin
1) 토픽생성
./kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic test
(kafka 2.2버전 이상부터 --zookeeper 옵션대신 --bootstrap-server 사용)
2) 토픽리스트
./kafka-topics.sh --list --bootstrap-server localhost:9092
3) 메세지 발행
./kafka-console-producer.sh --broker-list localhost:9092 --topic test
4) 메세지 구독
./kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning
# kafka mqtt 연동
- kafka-connect-mqtt (https://github.com/johanvandevenne/kafka-connect-mqtt)
'Data Engineering > MQTT' 카테고리의 다른 글
[RabbitMQ] TLS 적용 (0) | 2022.09.21 |
---|---|
무료 mqtt broker (0) | 2022.09.12 |
Kafka 설치(윈도우) (0) | 2022.02.10 |
mqtt-explorer 설치 (0) | 2022.02.08 |
RabbitMQ 리눅스 설치 (0) | 2022.02.08 |