본문 바로가기
카테고리 없음

아파치 카프카 서버 외부 접속 설정

by 오피스포디 2022. 6. 12.
반응형

우분투에 아파치 카프카가 설치되어 있는 상황으로 가정하겠습니다. 이때 이 카프카가 설치된 컴퓨터 이외의 PC에서 이 카프카로 접속하려고 하니까 추가 설정이 필요하더라고요.

 

일단 카프카는 아래 경로에 설치되어 있다고 가정합니다.

 

cd /usr/local/kafka/

 

kafka 폴더 하위에 여러 항목이 있는데, 그 중에 config 폴더에 들어가면 여러 설정 파일들이 들어가 있습니다. 이 중에 server.properties 라는 파일을 수정해줘야 합니다.

 

cd config
sudo vi server.properties

 

많은 내용이 있는데, 두개만 수정하면 됩니다.

 

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

# The address the socket server listens on. If not configured, the host name will be equal to the value of
# java.net.InetAddress.getCanonicalHostName(), with PLAINTEXT listener name, and port 9092.
#   FORMAT:
#     listeners = listener_name://host_name:port
#   EXAMPLE:
#     listeners = PLAINTEXT://your.host.name:9092
listeners=PLAINTEXT://:9092 # 이부분을 주석 제거

# Listener name, hostname and port the broker will advertise to clients.
# If not set, it uses the value for "listeners".
advertised.listeners=PLAINTEXT://192.168.0.xxx:9092 # 이 부분도 주석을 제거하고, 카프카 서버 IP 추가

 

이렇게 하면 카프카 서버가 아닌 외부 PC에서도 접속할 수 있게 됩니다. IP를 192.168.xxx.xxx 로 쓰려면 하나의 공유기 안에 있는 네트워크인 상황에서 동작한다는 것만 기억하시면 됩니다.

 

그리고 나서 카프카 서비스만 stop/start 해줍니다.

 

sudo systemctl stop kafka
sudo systemctl start kafka

 

이제 외부에서도 접속 가능하게 바뀌었을 겁니다.

반응형

댓글