zookeeper 서버를 server1, server2, server3 에 3대 운용한다고 할 때,

zoo.cfg에서 서버 설정을 아래처럼 하고,

...
...
server.1=server1.zookeeper.com:2888:3888
server.2=server2.zookeeper.com:2888:3888
server.3=server3.zookeeper.com:2888:3888

 

 

전체 서버에 동일한 zoo.cfg 로 세팅 후 실행하면 아래와 같은 에러를 내며 제대로 시작이 안될 경우,

2023-12-06 17:42:31,773 [myid:] - ERROR [ListenerHandler-server2.zookeeper.com/111.222.111.222:3888:o.a.z.s.q.QuorumCnxManager$Li
stener$ListenerHandler@1099] - Exception while listening to address server2.zookeeper.com/111.222.111.222:3888
java.net.BindException: Cannot assign requested address (Bind failed)
    at java.net.PlainSocketImpl.socketBind(Native Method)
    at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:387)
    at java.net.ServerSocket.bind(ServerSocket.java:390)
    at java.net.ServerSocket.bind(ServerSocket.java:344)
    at org.apache.zookeeper.server.quorum.QuorumCnxManager$Listener$ListenerHandler.createNewServerSocket(QuorumCnxManager.java:1141)
    at org.apache.zookeeper.server.quorum.QuorumCnxManager$Listener$ListenerHandler.acceptConnections(QuorumCnxManager.java:1070)
    at org.apache.zookeeper.server.quorum.QuorumCnxManager$Listener$ListenerHandler.run(QuorumCnxManager.java:1039)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:750)

 

 

 

zoo.cfg에서 local 서버의 경우 ip를 0.0.0.0으로 설정하면 해결됨.

(각 서버마다 zoo.cfg가 달라져야 한다는 이야기)

...
...
server.1=server1.zookeeper.com:2888:3888
server.2=0.0.0.0:2888:3888
server.3=server3.zookeeper.com:2888:3888

 

 

 

 

Posted by bloodguy
,