[Kafka] could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkCilent) 해결방법

zhzkzhffk·2022년 7월 9일
1

Kafka

목록 보기
3/4

문제 발생

zookeeper를 실행하고, kafka를 실행한 후에..
이제 메시지 topic 등록을 진행하려고 하는데 kafka 서버에서 계속 WARN 메시지가 출력된다.

[2022-07-09 16:51:01,406] WARN [Controller id=0, targetBrokerId=0] Connection to node 0 (/218.38.137.27:9092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2022-07-09 16:51:01,407] INFO [Controller id=0, targetBrokerId=0] Client requested connection close from node 0 (org.apache.kafka.clients.NetworkClient)
[2022-07-09 16:51:01,513] INFO [Controller id=0, targetBrokerId=0] Node 0 disconnected. (org.apache.kafka.clients.NetworkClient)
[2022-07-09 16:51:01,513] WARN [Controller id=0, targetBrokerId=0] Connection to node 0 (/218.38.137.27:9092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2022-07-09 16:51:01,514] INFO [Controller id=0, targetBrokerId=0] Client requested connection close from node 0 (org.apache.kafka.clients.NetworkClient)
[2022-07-09 16:51:01,621] INFO [Controller id=0, targetBrokerId=0] Node 0 disconnected. (org.apache.kafka.clients.NetworkClient)
[2022-07-09 16:51:01,622] WARN [Controller id=0, targetBrokerId=0] Connection to node 0 (/218.38.137.27:9092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)

확실히 kafka 서버를 작동하는 script에 문제가 있는 것 같다.

$ bin/kafka-topics.sh --create --topic quickstart-events --bootstrap-server localhost:9092

해결방법

kafka 폴더 내에 config 폴더 안에 있는 server.properties 파일에 주석처리 되어있는 부분을 해제하고 zookeeper와 kafka를 순서대로 실행시키면 됩니다.

$ vi config/server.properties

############################# Socket Server Settings #############################

# The address the socket server listens on. It will get the value returned from
# java.net.InetAddress.getCanonicalHostName() if not configured.
#   FORMAT:
#     listeners = listener_name://host_name:port
#   EXAMPLE:
#     listeners = PLAINTEXT://your.host.name:9092
#listeners=PLAINTEXT://:9092

# Hostname and port the broker will advertise to producers and consumers. If not set,
# it uses the value for "listeners" if configured.  Otherwise, it will use the value
# returned from java.net.InetAddress.getCanonicalHostName().
advertised.listeners=PLAINTEXT://your.host.name:9092 //  ip 주소 (ex: localhost)

이떄 listeners=PLAINTEXT://:9092를 주석해제 하는 것이 아니라 advertised.listeners=PLAINTEXT://your.host.name:9092를 주석해제하고, 내 IP 주소를 적어주면 됩니다. (advertised.listeners의 역할: 카프카 클라이언트나 커맨드 라인 툴을 브로커와 연결할 때 쓰입니다.)

$ ./bin/kafka-topics.sh --bootstrap-server localhost:9092 --list

profile
Backend Developer

0개의 댓글