728x90
반응형
1. 개요
프로듀서에 비해 컨슈머 offset이 뒤쳐져있고, 더 이상 프로듀서가 메시지를 발행하고 있지 않은데 Consumer Lag이 남아있는 경우 offset을 변경하는 방법
왜 남아있는지는 다양한 원인에 의해서 일 거 같은데.. 상황에 맞게 연구가 필요할듯함.
lag에 의한 메시지가 유실되어도 상관없는 경우(앱 오류나 특정 상황으로 인해 consumer lag이 남아있는 경우)에 적용
2. 방법
kafka-consumer-groups.sh shell은 docker를 사용하는 경우 아래 명령어를 실행하여 접근 가능
docker exec -it {yourKafkaDockerContainerName} /bin/bash
cd /bin
ls
ls 명령어로 kafka 툴 관련 .sh 파일들이 있는지 확인. 없다면 다른 위치 찾아봐야함
1. 컨슈머 애플리케이션을 끈다. 또는 컨슈머를 inactive 상태로 만든다(켜져 있으면 offset 조정 불가)
2. 다음 명령어로 consumer groups 확인
kafka-consumer-groups --bootstrap-server {yourBrokerServer} --describe --group {yourConsumerGroupName} --topic {yourTopicName}
3. --dry-run으로 실행 결과 미리보기
kafka-consumer-groups --bootstrap-server {yourBrokerServer} --group {yourConsumerGroupName} --topic {yourTopicName} --reset-offsets --to-latest --dry-run
4. --execute로 실행하고 offset 확인
kafka-consumer-groups --bootstrap-server {yourBrokerServer} --group {yourConsumerGroupName} --topic {yourTopicName} --reset-offsets --to-latest --execute
5.
- --partition {yourPartitionNumber} 옵션을 추가로 주어 특정 파티션만 offset을 reset 할 수 있음
- --to-latest, --to-earliest, --to-offset {offsetYouWant} 옵션도 줄 수 있음
대략 아래 그림과 같이 표시된다
참조
728x90
반응형
'Programming-[Backend] > Kafka' 카테고리의 다른 글
[카프카 핵심 가이드] 1. 카프카 시작하기 (1) | 2024.11.07 |
---|---|
[TIL] Kafka Transaction mode, offset lag = 1 유지 현상 (1) | 2024.09.05 |
카프카 멱등성(Idempotence) 설정, Retry 및 DLT 설정 시 유의사항 (2) | 2024.07.23 |
[TIL] 카프카 로그 압축 정보 local container에서 확인 방법(kafka-run-class, DumpLogSegments) (0) | 2024.06.24 |
[검증 중] Kafka - testcontainer : Transaction 묶기, graceful shutdown, 수동 커밋, await (0) | 2024.06.02 |