1. 카프카 설치 위치로 이동
cd /opt/kafka
2. 주키퍼 실행상태 확인
service zookeeper status
3. 카프카 실행상태 확인
service kafka status
4. result라는 이름을 가진 토픽 생성
./bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --topic result
5. 전체 토픽 조회
./bin/kafka-topics.sh --list --bootstrap-server localhost:9092
6. result 토픽 상세조회
./bin/kafka-topics.sh --describe --bootstrap-server localhost:9092 --topic result
7. 토픽에 프로듀서를 이용해 다음과 같은 내용 입력
h
e
l
l
o
./bin/kafka-console-producer.sh --broker-list localhost:9092 --topic result
8. 컨슈머를 이용해 result 토픽 내용 조회해보기
./bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic result --from-beginning
9. 컨슈머가 켜져있는 터미널은 계속 켜둔 상태로 터미널을 하나 더 실행시켜서 카프카 설치 위치로 이동 후 다음과 같은 내용을 프로듀서로 입력해서 실시간으로 조회되는지 확인하기
p
a
r
k
./bin/kafka-console-producer.sh --broker-list localhost:9092 --topic result
p
a
r
k
10. result 토픽 내용 조회해보기
./bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic result --from-beginning
11. 토픽 내용 보관주기를 1초로 바꿔보기
./bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic result --config retention.ms=1000
12. result 토픽 내용 조회하기
./bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic result --from-beginning
13. result 토픽의 데이터 보관주기를 1시간으로 변경해보기
./bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic result --config retention.ms=3600000
14. result 토픽 상세조회하기
./bin/kafka-topics.sh --describe --bootstrap-server localhost:9092 --topic result
15. result 토픽의 파티션을 3으로 변경시켜보기
./bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic result -partitions 3
16. result 토픽 상세조회하기
./bin/kafka-topics.sh --describe --bootstrap-server localhost:9092 --topic result
17. result 토픽의 파티션을 5개로 변경해보기
./bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic result -partitions 5
18. result 토픽 상세조회하기
./bin/kafka-topics.sh --describe --bootstrap-server localhost:9092 --topic result
19. result 토픽의 파티션을 3개로 다시 줄여보고 에러 확인하기
./bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic result -partitions 3
20. result 토픽 상세조회하기
./bin/kafka-topics.sh --describe --bootstrap-server localhost:9092 --topic result
21. result 토픽 삭제해보기
./bin/kafka-topics.sh --delete --bootstrap-server localhost:9092 --topic result
22. 전체 토픽 조회하기
./bin/kafka-topics.sh --list --bootstrap-server localhost:9092
'Data Engineering > Kafka' 카테고리의 다른 글
[kafka] 도커컴포즈로 싱글노드 카프카 만드는 방법 (docker compose, single, kafka, zookeeper) (0) | 2021.12.23 |
---|---|
[kafka] 카프카의 구성요소 (0) | 2021.12.19 |
[kafka] 카프카 예제 및 명령어 공부 2 (0) | 2021.06.14 |
[kafka] 카프카 예제 및 명령어 공부 1 (0) | 2021.06.13 |
[kafka] 카프카 명령어 모음 Kafka Command Collection (2) | 2021.05.21 |