解决ZooKeeper:java.net.BindException: Address already in use

大数据技术 潘老师 1年前 (2021-04-26) 1326 ℃ (0) 扫码查看

当我们在启动ZooKeeper时如果报错如下:

2021-04-26 17:42:37,967 [myid:3] - INFO  [main:NIOServerCnxnFactory@686] - binding to port 0.0.0.0/0.0.0.0:2181
2021-04-26 17:42:37,968 [myid:3] - ERROR [main:QuorumPeerMain@101] - Unexpected exception, exiting abnormally
java.net.BindException: Address already in use
    at sun.nio.ch.Net.bind0(Native Method)
    at sun.nio.ch.Net.bind(Net.java:433)
    at sun.nio.ch.Net.bind(Net.java:425)
    at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
    at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
    at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:67)
    at org.apache.zookeeper.server.NIOServerCnxnFactory.configure(NIOServerCnxnFactory.java:687)
    at org.apache.zookeeper.server.quorum.QuorumPeerMain.runFromConfig(QuorumPeerMain.java:148)
    at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:123)
    at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:82)

解决ZooKeeper:java.net.BindException: Address already in use
说明ZooKeeper中有端口被占用了,我们这里涉及到的端口是2181端口,通过如下指令查看哪个进程占用了该端口:

netstat -ano | findstr "2181"

如果没有netstat指令,可以执行如下指令安装后再去查看:

yum -y install net-tools

然后找到该进程的id,执行如下指令结束该进程即可:

kill -9 进程pid

最后再去启动ZooKeeper发现就ok了


版权声明:本站所有文章,如无特殊说明,均为本站原创。转载请务必注明文章来源,谢谢支持。
本文链接:https://www.panziye.com/java/bigdata/3102.html
喜欢 (2)
请潘老师喝杯Coffee吧!】
分享 (0)
用户头像
发表我的评论
取消评论
表情 贴图 签到 代码

Hi,您需要填写昵称和邮箱!

  • 昵称【必填】
  • 邮箱【必填】
  • 网址【可选】