Yebali

Kafka 토픽 수정하기 본문

카테고리 없음

Kafka 토픽 수정하기

예발이 2022. 2. 1. 14:08

토픽에 설정된 옵션을 변경하기 위해서는 'kafka-topics.sh'와 'kafka-configs.sh' 두 개를 사용해야 한다.

파티션 개수를 변경하려면 'kafka-topics.sh'를 사용해야 하고, 토픽 삭제 책인 리텐션 기간을 변경하려면 'kafka-configs.sh'를 사용해야 한다.

 

파티션의 개수 변경하기

'kafka-topics.sh'를 사용해 파티션의 개수를 4개로 변경하려면 아래의 명령어를 사용해야 한다.

bin/kafka-topics.sh \
--bootstrap-server=13.124.252.159:9092 \
--topic hello.kafka2 \
--alter \
--partitions 4

변경된 파티션 수는 bin/kafka-topics.sh --bootstrap-server=13.124.252.159:9092 --topic hello.kafka2 --describe로 확인 할 수 있다.

파티션의 리텐션 기간 변경하기

리텐션 기간을 172800000ms(2일)에서 8640000ms(1일)로 변경해보자.

bin/kafka-configs.sh \
--bootstrap-server=13.124.252.159:9092 \
--entity-type topics \
--entity-name hello.kafka2 \
--alter --add-config retention.ms=86400000

변경된 리텐션 기간은 bin/kafka-topics.sh --bootstrap-server=13.124.252.159:9092 --topic hello.kafka2 --describe로 확인 할 수 있다.