2025-02-14-route53-not-working - 박수현 기술블로그 제출 #131
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Title : Route53가 제대로 동작하지 않을 때가 있다.
현재 프로젝트의 아키텍처는 아래와 같다.

[카프카1]
[카프카2]
[카프카3]
직면한 문제 : [카프카3]에서 기존 토픽을 상세조회하려고 하는데 위와 같이 timeout이 떴다.
위 문제 해결을 위해 시도한 방법
1. 위 에러와 동일한 블로그를 찾았다.
https://wildeveloperetrain.tistory.com/219 블로그를 통해 카프카의 server.properties 정보에서 listeners 정보를 업데이트 해주었다.
→ 그래도 안됨.
2. 주키퍼가 내가 설정한 토픽을 잘 바라보고 있는지 의심이 들었다.
https://developnote-blog.tistory.com/172 블로그대로
./zookeeper-shell.sh 172.31.8.236:2181
를 통해 직접 주키퍼에 접근했다.주키퍼가 내가 만든 토픽들을 제대로 보고 있었다.
→ 결론적으로 이 부분이 아니었음.
3. 각 서버간의 주키퍼와 카프카가 잘 켜져있는지 확인하기 위해, 9092, 2181 포트가 켜져있는지 확인했다.
아래와 같이 모두 잘 켜져있었음. → 결론적으로 이 부분이 아니었음.
[카프카1]

[카프카2]

[카프카3]

4. 토픽을 상세조회할때, 카프카를 통해 토픽 상세조회, 주키퍼를 통해 토픽 상세조회를 했다.
카프카를 통해 토픽을 상세조회할때, timeout이 났다. (주키퍼를 통해 토픽 상세조회 시 올바르게 동작) → 왜?
~/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 --topic cycleInfo-json-topic --describe
~/kafka/bin/kafka-topics.sh --zookeeper 172.31.11.207:2181, 172.31.3.191:2181, 172.31.8.236:2181 --topic cycleInfo-json-topic --describe
껐다 켜보자.
근데 termius에서 해당 EC2로 접속이 안되더라.
설마 route53이 문제인가?
[dig 도메인명 명령어]를 통해 내 자신, 상대방의 카프카 등의 도메인에 맞는 ip인지 확인했다.
!! 카프카3이 도메인에 맞는 ip가 아니었다.
기존에 route53에 ec2의 public ip을 넣어주었음에도 불구하고 제대로 동작을 안했던 것이다.
처음으로 돌아가자. 난 애초에 토픽을 상세조회하려고하는데 time out이 났고 이로 인해 제대로 동작이 안되었다.
토픽을 상세조회할때 사용한 명령어가 어떤식으로 동작하는지 확인하기 위해,
cat kafka-topics.sh
를 입력했다.kafka-topics.sh는 아래처럼 kafka.admin.topiccommand "$@” 로 되어있었다.
내부 코드를 확인하니, 살아있는 노드들을 확인할때 (liveBrokers) 도메인에 맞는 ip로 접근해야하는데 도메인에 맞지 않는 ip로 접근하다보니, timeout이 발생했던 것이다.
궁극적으로 route53가 올바르게 동작하지 않아, 제대로 DNS질의를 하지 못한것이었고, 난 /etc/hosts 파일에 도메인에 맞는 ip를 명시적으로 넣어줌으로써 해결할 수 있었다.