본문 바로가기

TIL(Today I Learned)

윈도우에서 Kafka 설치 및 실행

📌  Kafka 설치 및 실행

1. kafka 다운로드(https://kafka.apache.org/downloads)

 

2. 압축해제

git bash을 켜고 명령어 입력

tar -xvzf kafka_2.12-3.6.0.tgz

 

 

3. zookeeper 실행하기

cmd창 디렉토리 이동 후 명령어 입력

(C:\kafka_2.12-3.6.0\bin\windows)

zookeeper-server-start.bat ../../config/zookeeper.properties

 

4. kafka 실행

새로운 cmd창 디렉토리 이동 후 명령어 입력

(C:\kafka_2.12-3.6.0\bin\windows)

kafka-server-start.bat ../../config/server.properties

 


테스트 해보기

 

5. topic 생성

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

 

 

6. consumer 실행

새로운 cmd창 디렉토리 이동 후 명령어 입력

(C:\kafka_2.12-3.6.0\bin\windows)

kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic my_test_topic

 

 

-> 이 comsumer는 my_test_topic에 작성되는 모든 메시지를 수신한다.

 

6. producer 실행

새로운 cmd창 디렉토리 이동 후 명령어 입력

(C:\kafka_2.12-3.6.0\bin\windows)

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

 

그 다음 터미널에 메시지를 입력하고 enter

이렇게 되면 consumer terminal에서 메시지를 수신하여 출력한다.

 

 

 

 

 

 

 

 

 

 

References :

https://kafka.apache.org/downloads

https://www.geeksforgeeks.org/how-to-install-and-run-apache-kafka-on-windows/

https://m.blog.naver.com/jamsuham75/221807222138