1、启动zookeeper,但是报错,端口被占用;

2020-04-02 09:56:21,701 [myid:] - ERROR [main:ZooKeeperServerMain@90] - Unexpected exception, exiting abnormally java.net.BindException: Address already in use: bind
        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:676)
        at org.apache.zookeeper.server.ZooKeeperServerMain.runFromConfig(ZooKeeperServerMain.java:158)
        at org.apache.zookeeper.server.ZooKeeperServerMain.initializeAndRun(ZooKeeperServerMain:112)
        at org.apache.zookeeper.server.ZooKeeperServerMain.main(ZooKeeperServerMain.java:67)
        at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:140)
        at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:90)
2020-04-02 09:56:21,707 [myid:] - INFO  [main:ZKAuditProvider@42] - ZooKeeper audit is disabled.
2020-04-02 09:56:21,708 [myid:] - ERROR [main:ServiceUtils@42] - Exiting JVM with code 1Unexpected 

2、通过cmd查询端口,命令:netstat -ano | findstr 2181    发现没有被占用

3、看了很多方法都不行,后来才发现。使用命令 netsh interface ipv4 show excludedportrange protocol=tcp,   这个是查询windows10下面的Hyper-V的端口保留的TCP范围,结果显示:端口2181Hyper-V给保留了

 

两种解决方案:

1、修改端口:配置文件将zookeeper的端口改为高位端口,比如21810  。

2、关闭Hyper-V。使用默认端口   操作如下:控制面板--程序---程序和功能---启动或关闭windows功能,去掉对号

 

 

 

 

 

 

Logo

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

更多推荐