BigData/Kafka
Kafka topic producer consumer 테스트
개발자웅이
2023. 7. 25. 16:57
이전 포스팅에서 설치한 kafka가 정상 동작하는지 테스트해보겠습니다
mast01,02,03서버에 kafka cluster가 설치되어있습니다.
https://developer-woong.tistory.com/52
Apache Kafka 설치
centos7 기준입니다. 실행 유저는 hadoop, 버전은 2.8.2로 설치할 것이며, mast01,02,03 3대의 서버에 cluster mode로 설치할 예정입니다. zookeeper가 설치되어있음을 가정하고, mast01,02,03서버에 zookeeper가 설치
developer-woong.tistory.com
1. Kafka Topic Create
action server: mast01
user: hadoop
pwd: /opt/apps/kafka-2.8.2
cmd:
# 파티션이 하나, 복제 수가 3개인 testTopic이라는 일므의 토픽을 생성합니다.
./bin/kafka-topics.sh --create --bootstrap-server mast01:9092,mast02:9092,mast03:9092 --replication-factor 3 --partitions 1 --topic testTopic
# 생성되었는지 토픽 리스트를 확인합니다.
./bin/kafka-topics.sh --list --bootstrap-server mast01:9092,mast02:9092,mast03:9092
1. Kafka Producer, Consumer
action server: mast02, mast03
user: hadoop
pwd: /opt/apps/kafka-2.8.2
cmd:
# mast02서버에서 프로듀서 콘솔 띄우기
./bin/kafka-console-producer.sh --bootstrap-server mast01:9092,mast02:9092,mast03:9092 --topic testTopic
# mast03서버에서 컨슈머 콘솔 띄우기
./bin/kafka-console-consumer.sh --bootstrap-server mast01:9092,mast02:9092,mast03:9092 --topic testTopic --from-beginning
mast02서버의 프로듀서에서 메시지 입력 시 실시간으로 mast02서버의 컨슈머에서 확인
반응형