티스토리 뷰

개발

Kafka 기본 명령어

danggeni 2023. 7. 20. 18:41
반응형

카프카(Kafka)에서 자주 사용되는 기본 명령어들을 공유 해봅니다.

 

 - Topic 생성

 - 생성된 Topic 목록 조회

 - Topic 상세 정보 조회

 - 메세지 전송 , 소비(Producer, Consumer)

 - Topic 삭제

bin/kafka-console-producer --bootstrap-server localhost:9092 --topic hello-world

Topic 목록 확인

Mac

bin/kafka-topics --bootstrap-server localhost:9092 --list

Windows

bin/kafka-topics.sh --bootstrap-server localhost:9092 --list

 

Topic 생성

topic 생성의 경우 기본적으로 Partitions을 지정하지 않는다면 default 1개의 Partitions 으로 생성된다.

Mac

bin/kafka-topics --create --topic hello-world --bootstrap-server localhost:9092

Windows

bin/kafka-topics.sh --create --topic hello-world --bootstrap-server localhost:9092

 

Topic 상세 정보 조회

Mac

bin/kafka-topics --describe --topic hello-world --bootstrap-server localhost:9092

Windows

bin/kafka-topics.sh --describe --topic hello-world --bootstrap-server localhost:9092

describe를 통한 topic 상세 정보 확인

 

Topic 메세지 전송(Producer)

Mac

bin/kafka-console-producer --bootstrap-server localhost:9092 --topic hello-world

Windows

bin/kafka-console-producer.sh --bootstrap-server localhost:9092 --topic hello-world

Producer를 통한 메세지 send

 

Topic 메세지소비(Consumer)

Mac

bin/kafka-console-consumer --bootstrap-server localhost:9092 --topic hello-world

Windows

 bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic hello-world

Producer를통해 전달받은 메세지가 갱신된다.

Topic 삭제

Mac

bin/kafka-topics --bootstrap-server localhost:9092 --delete --topic hello-world

Windows

bin/kafka-topics.sh --bootstrap-server localhost:9092 --delete --topic hello-world

 
이렇게 기본적인 생성 및 삭제, 그리고 메세지 생성, 소비  생성된 Topic 목록 정보와 상세정보를 보는 기본적으로 자주 사용되는 
Apache Kafka Command 를 정리해 보았습니다.
 
다음편에는 Kafka 와 관련된 매니징 툴들을 소개 해보겠습니다.
 
감사합니다 __)

참조

https://kafka.apache.org/documentation/

반응형
댓글
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함