1、报错

[root@node1 ~]# zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper-3.4.10/bin/../conf/zoo.cfg
Starting zookeeper ... already running as process 7366.
[root@node1 ~]# zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper-3.4.10/bin/../conf/zoo.cfg
Error contacting service. It is probably not running.
[root@node1 ~]#

查看日志

[root@node1 ~]# vi zookeeper.out
2018-04-19 22:19:40,395 [myid:1] - ERROR [node2/10.17.12.157:3888:QuorumCnxManager$Listener@763] - Exception while listening
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:375)
        at java.net.ServerSocket.bind(ServerSocket.java:329)
        at org.apache.zookeeper.server.quorum.QuorumCnxManager$Listener.run(QuorumCnxManager.java:742)

2、解决办法

百度了BindException: Cannot assign requested address (Bind failed),网友们提供的方法不能解决我的遇到的问题。
最后意外发现时我的配置文件zoo.cfg配置错误:

[root@node1 ~]# vi /opt/zookeeper-3.4.10/conf/zoo.cfg
server.1=node2:2888:3888
server.2=node2:2888:3888
server.3=node3:2888:3888

很显然,将server.1=node2:2888:3888修改为server.1=node1:2888:3888即可。
重启ZK,问题解决。

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐