Zookeeper啟動失敗:java.net.BindException: Address already in use


錯誤日志如下:

[hadoop@master zookeeper-3.4.5-cdh5.10.0]$ cat zookeeper.out 
2018-05-15 01:29:21,036 [myid:] - INFO  [main:QuorumPeerConfig@101] - Reading configuration from: /opt/modules/zookeeper-3.4.5-cdh5.10.0/bin/../conf/zoo.cfg
2018-05-15 01:29:21,045 [myid:] - INFO  [main:QuorumPeerConfig@334] - Defaulting to majority quorums
2018-05-15 01:29:21,048 [myid:1] - INFO  [main:DatadirCleanupManager@78] - autopurge.snapRetainCount set to 3
2018-05-15 01:29:21,048 [myid:1] - INFO  [main:DatadirCleanupManager@79] - autopurge.purgeInterval set to 0
2018-05-15 01:29:21,049 [myid:1] - INFO  [main:DatadirCleanupManager@101] - Purge task is not scheduled.
2018-05-15 01:29:21,065 [myid:1] - INFO  [main:QuorumPeerMain@132] - Starting quorum peer
2018-05-15 01:29:21,074 [myid:1] - INFO  [main:NIOServerCnxnFactory@94] - binding to port 0.0.0.0/0.0.0.0:2181
2018-05-15 01:29:21,076 [myid:1] - ERROR [main:QuorumPeerMain@94] - 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:95)
	at org.apache.zookeeper.server.quorum.QuorumPeerMain.runFromConfig(QuorumPeerMain.java:135)
	at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:116)
	at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:79)

    如日志中紅色字體所示,該錯誤是由於Zookeeper對應的端口號被占用導致的。

    查看端口占用情況:

[hadoop@master zookeeper-3.4.5-cdh5.10.0]$ sudo netstat -nltp | grep 2181
tcp        0      0 :::2181                     :::*                        LISTEN      3071/java

    如上所示,占用Zookeeper對應端口號的應用是java,只需要kill掉該應用就能成功啟動Zookeeper了。

[hadoop@master zookeeper-3.4.5-cdh5.10.0]$ sudo  kill -9 3071

    重啟如下:

[hadoop@master zookeeper-3.4.5-cdh5.10.0]$ bin/zkServer.sh start
JMX enabled by default
Using config: /opt/modules/zookeeper-3.4.5-cdh5.10.0/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[hadoop@master zookeeper-3.4.5-cdh5.10.0]$ jps
6481 Jps
5330 DataNode
5733 ResourceManager
5077 DFSZKFailoverController
6456 QuorumPeerMain
5225 NameNode
5514 JournalNode
5837 NodeManager

    Zookeeper啟動成功!

 

以上就是博主為大家介紹的這一板塊的主要內容,這都是博主自己的學習過程,希望能給大家帶來一定的指導作用,有用的還望大家點個支持,如果對你沒用也望包涵,有錯誤煩請指出。如有期待可關注博主以第一時間獲取更新哦,謝謝! 

 版權聲明:本文為博主原創文章,未經博主允許不得轉載。






免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM