Message Queue/Kafka

Kafka 명령어

잔망루피 2023. 1. 20. 21:47
반응형

사용한 OS는 Windows

항상 Zookeeper service부터 켠다.


bin\windows\zookeeper-server-start.bat config\zookeeper.properties

Zookeeper service 시작

 

bin\windows\kafka-server-start.bat config\server.properties

새로운 터미널을 연다.

Kafka broker service 시작


bin\windows\kafka-topics.bat --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic test-topic

test-topic 이름으로 토픽을 생성

파티션 1개, replication이 1이라서 자기 자신만 있다.

 

bin\windows\kafka-topics.bat --list --bootstrap-server localhost:9092

토픽 리스트 확인

 

bin\windows\kafka-topics.bat --describe --bootstrap-server localhost:9092 --topic test-topic

test-topic 토픽 상세 보기

 

bin\windows\kafka-topics.bat --zookeeper localhost:2181 --alter --topic test-topic -partitions 2

test-topic 토픽의 파티션 수 변경

토픽의 파티션 수는 증가만 가능

파티션의 수만큼 컨슈머 역시 추가해줘야 처리 성능이 좋아질 수 있다.

 

bin\windows\kafka-consumer-groups.bat --bootstrap-server localhost:9092 --list

컨슈머 그룹 리스트 확인

 

bin\windows\kafka-consumer-groups.bat --bootstrap-server localhost:9092 --group test-consumer --describe

컨슈머 상태와 오프셋 확인

 

 bin\windows\kafka-topics.bat --zookeeper localhost:2181 --delete --topic MyTopic

MyTopic 토픽 삭제

delete.topic.enable이 true로 설정되어 있어야 한다.

 

 

참고 👇

https://log-laboratory.tistory.com/169

 

[kafka] 자주 사용하는카프카 명령어

카프카 사용시 자주 사용하는 명령어이다. 명령어 확인 경로: /usr/local/kafka/bin 토픽 생성 > bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic test-topic 토픽 리스트

log-laboratory.tistory.com

 

https://hbase.tistory.com/214

 

[Kafka] 카프카 자주 사용하는 명령어

카프카 클러스터를 운영하다보면 몇 가지 자주 사용하는 명령어들이 있다. 대부분 kafka-topic.sh 같은 스크립트를 이용한 쉘 명령어다. 토픽 생성 카프카 토픽은 kafka-topics.sh 스크립트를 이용해서

hbase.tistory.com

 

반응형