[Kafka ์—๋Ÿฌ] LEADER_NOT_AVAILABLE

2024. 1. 4. 23:36ใ†Backend/๐Ÿ”— Kafka

 

์ƒํ™ฉ

 

์นดํ”„์นด ํด๋Ÿฌ์Šคํ„ฐ ๊ตฌ์ถ• ์ค‘ ๋ฐœ์ƒํ•œ ์—๋Ÿฌ. 

๋„์ปค ์ปดํฌ์ฆˆ๋ฅผ ํ™œ์šฉํ•ด ๋ธŒ๋กœ์ปค 3๋Œ€, ์ฃผํ‚คํผ 1๋Œ€ ์กฐํ•ฉ์œผ๋กœ ์นดํ”„์นด ํด๋Ÿฌ์Šคํ„ฐ๋ฅผ ๊ตฌ์„ฑํ–ˆ๋‹ค.

๋ธŒ๋กœ์ปค ๋‚ด๋ถ€์—์„œ kafka-console-producer ๋กœ topic ์— ๋ฉ”์‹œ์ง€๋ฅผ ๋ฐœํ–‰ํ–ˆ๋Š”๋ฐ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ–ˆ๋‹ค.

 

์—๋Ÿฌ ๋ฉ”์‹œ์ง€

WARN [Producer clientId=console-producer] Error while fetching metadata with correlation id 3 : {test=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)

 

์›์ธ๊ณผ ํ•ด๊ฒฐ

๋ฉ”์‹œ์ง€๋ฅผ ๋ฐœํ–‰ํ•˜๊ณ ์ž ํ•œ ํ† ํ”ฝ์ด ์•„์ง ์ƒ์„ฑ๋˜์ง€ ์•Š์•˜๊ธฐ ๋•Œ๋ฌธ์— ๋ฐœ์ƒํ•œ ์—๋Ÿฌ์˜€๋‹ค.

๋„์ปค ์ปดํฌ์ฆˆ yml ์ž‘์„ฑ ์‹œ ์•„๋ž˜ ์˜ต์…˜์„ true ๋กœ ์„ค์ •ํ•˜๋ฉด ํ† ํ”ฝ์ด ์ž๋™์œผ๋กœ ์ƒ์„ฑ๋œ๋‹ค. 

auto.create.topics.enable=true

 

ํ•˜์ง€๋งŒ ์ด ๋ฐฉ๋ฒ•์€ ๊ถŒํ•˜์ง€ ์•Š๋Š”๋ฐ ํ† ํ”ฝ์„ ์ž˜๋ชป ์„ค์ •ํ•˜์—ฌ ๋ฉ”์‹œ์ง€๋ฅผ ๋ณด๋‚ด๋”๋ผ๋„, ์•„๋ฌด๋Ÿฐ ์—๋Ÿฌ์—†์ด ํ† ํ”ฝ์ด ์ƒ์„ฑ๋˜๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค. 

๋ฌผ๋ก  ๊ฐ„ํŽธํ•œ ๋ฐฉ๋ฒ•์ด๋ผ๊ณ  ์ƒ๊ฐํ•  ์ˆ˜๋„ ์žˆ์ง€๋งŒ, ๋ธŒ๋กœ์ปค ๋‚ด๋ถ€์— ๊ด€๋ฆฌ๋˜์ง€ ์•Š๋Š” ํ† ํ”ฝ์ด ์—ฌ๋Ÿฌ๊ฐœ ์ƒ๊ธฐ๊ณ  ์ถ”ํ›„์—๋Š” ๋ฉ”๋ชจ๋ฆฌ ๋ฌธ์ œ๋„ ์šฐ๋ ค๋˜๊ธฐ ๋•Œ๋ฌธ์— ๊ถŒ์žฅํ•˜์ง€ ์•Š๋Š”๋‹ค.

 

๊ทธ๋ž˜์„œ ์นดํ”„์นด ๋‚ด๋ถ€์—์„œ ์ง์ ‘ ํ† ํ”ฝ์„ ์ƒ์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๊ถŒ์žฅํ•œ๋‹ค.

$ kafka-console-producer --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic TOPIC-1

 

 

 

ref

- https://veneas.tistory.com/entry/Spring-for-Apache-Kafka-Error-while-fetching-metadata-with-correlation-id

- https://twowinsh87.github.io/etc/2019/09/28/etc-kafka2019-3-1/