Open hamsunwoo opened 1 week ago
문제: 주키퍼 3개를 늘렸을 때 연결이 안되는 문제가 있었다. 주키퍼 로그를 살펴보니
2024-11-13 00:50:30,508 [myid:] - ERROR [ListenerHandler-zookeeper1/192.168.16.2:3889:o.a.z.s.q.QuorumCnxManager$Listener$ListenerHandler@1099] - Exception while listening to address zookeeper1/192.168.16.2:3889
zookeeper2 | java.net.BindException: Cannot assign requested address (Bind failed)
zookeeper2 | at java.base/java.net.PlainSocketImpl.socketBind(Native Method)
zookeeper2 | at java.base/java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:452)
zookeeper2 | at java.base/java.net.ServerSocket.bind(ServerSocket.java:395)
zookeeper2 | at java.base/java.net.ServerSocket.bind(ServerSocket.java:349)
zookeeper2 | at org.apache.zookeeper.server.quorum.QuorumCnxManager$Listener$ListenerHandler.createNewServerSocket(QuorumCnxManager.java:1141)
zookeeper2 | at org.apache.zookeeper.server.quorum.QuorumCnxManager$Listener$ListenerHandler.acceptConnections(QuorumCnxManager.java:1070)
zookeeper2 | at org.apache.zookeeper.server.quorum.QuorumCnxManager$Listener$ListenerHandler.run(QuorumCnxManager.java:1039)
zookeeper2 | at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
zookeeper2 | at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
zookeeper2 | at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
zookeeper2 | at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
zookeeper2 | at java.base/java.lang.Thread.run(Thread.java:829)
java.net.BindException: Cannot assign requested address (Bind failed) 오류는 ZooKeeper 인스턴스가 3889 포트에 바인딩하려고 할 때 실패했음을 나타낸다.
원래 코드는 이랬다.
zookeeper1:
image: bitnami/zookeeper:3.6.3
container_name: zookeeper1
hostname: zookeeper1
environment:
- ALLOW_ANONYMOUS_LOGIN=yes
- ZOO_MY_ID=1
- ZOO_SERVERS=zookeeper1:2888:3889;zookeeper2:2888:3889;zookeeper3:2888:3889
- ZOO_TICK_TIME=2000 # 2초
- ZOO_INIT_LIMIT=10 # 초기 연결 제한 시간
- ZOO_SYNC_LIMIT=5 # 동기화 제한 시간
ports:
- "2181:2181"
networks:
- kafka_network
zookeeper2:
image: bitnami/zookeeper:3.6.3
container_name: zookeeper2
hostname: zookeeper2
environment:
- ALLOW_ANONYMOUS_LOGIN=yes
- ZOO_MY_ID=2
- ZOO_SERVERS=zookeeper1:2888:3889;zookeeper2:2888:3889;zookeeper3:2888:3889
- ZOO_TICK_TIME=2000 # 2초
- ZOO_INIT_LIMIT=10 # 초기 연결 제한 시간
- ZOO_SYNC_LIMIT=5 # 동기화 제한 시간
ports:
- "2182:2181"
networks:
- kafka_network
zookeeper3:
image: bitnami/zookeeper:3.6.3
container_name: zookeeper3
hostname: zookeeper3
environment:
- ALLOW_ANONYMOUS_LOGIN=yes
- ZOO_MY_ID=3
- ZOO_SERVERS=zookeeper1:2888:3889;zookeeper2:2888:3889;zookeeper3:2888:3889
- ZOO_TICK_TIME=2000 # 2초
- ZOO_INIT_LIMIT=10 # 초기 연결 제한 시간
- ZOO_SYNC_LIMIT=5 # 동기화 제한 시간
ports:
- "2183:2181"
networks:
- kafka_network
ZOO_SERVERS=zookeeper1:2888:3889;zookeeper2:2888:3889;zookeeper3:2888:3889 를 없애니 잘 작동되었다.