📌 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/
'TIL(Today I Learned)' 카테고리의 다른 글
Redis란 무엇일까? (0) | 2024.01.09 |
---|---|
Apache Kafka란 무엇일까? (1) | 2023.12.19 |
성능 향상을 위한 메시지 큐 도입 (0) | 2023.11.20 |
TIL-231118([프로그래머스/자바] 간단한 식 계산하기) (0) | 2023.11.18 |
TIL-231117(JPA N+1 문제) (0) | 2023.11.17 |