# jdk 설치
apt update
apt install -y openjdk-8-jdk
# Kafka 다운로드
wget https://dlcdn.apache.org/kafka/3.1.0/kafka_2.13-3.1.0.tgz
tar -xzvf kafka_2.13-3.1.0.tgz
mv kafka_2.13-3.1.0 /opt/kafka
# 호스트 이름 설정(각각 컴퓨터)
/etc/hostname
broker
producer
consumer
# 호스트 설정(모든 컴퓨터)
/etc/hosts
[브로커 IP] broker
[프로듀서 IP] producer
[컨슈머 IP] consumer
/opt/kafka/bin/zookeeper-server-start.sh config/zookeeper.properties
/opt/kafka/bin/kafka-server-start.sh config/server.properties
/opt/kafka/bin/kafka-topics.sh --create --topic [topicname] --bootstrap-server [broker IP]:9092
/opt/kafka/bin/kafka-topics.sh --describe --topic [topicname] --bootstrap-server [broker IP]:9092
/opt/kafka/bin/kafka-console-producer.sh --topic [topicname] --bootstrap-server [broker IP]:9092
/opt/kafka/bin/kafka-console-consumer.sh --topic [topicname] --from-beginning --bootstrap-server [broker IP]:9092