Zookeeper启动失败:java.net.BindException: Address already in use

在启动Zookeeper时候失败:java.net.BindException: Address already in use

查看日志信息如下所示:

[ipaas@admin01 bin]$  ./zkServer.sh start-foreground
ZooKeeper JMX enabled by default
Using config: /home/ipaas/zookeeper/zookeeper-3.4.11/bin/../conf/zoo.cfg
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/ipaas/zookeeper/zookeeper-3.4.11/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/ipaas/zookeeper/zookeeper-3.4.11/lib/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
2019-09-23 04:52:12,325 [myid:] - INFO  [main:QuorumPeerConfig@136] - Reading configuration from: /home/ipaas/zookeeper/zookeeper-3.4.11/bin/../conf/zoo.cfg
2019-09-23 04:52:12,341 [myid:] - INFO  [main:QuorumPeer$QuorumServer@184] - Resolved hostname: 192.168.47.103 to address: /192.168.47.103
2019-09-23 04:52:12,341 [myid:] - INFO  [main:QuorumPeer$QuorumServer@184] - Resolved hostname: 192.168.47.102 to address: /192.168.47.102
2019-09-23 04:52:12,342 [myid:] - INFO  [main:QuorumPeer$QuorumServer@184] - Resolved hostname: 192.168.47.101 to address: /192.168.47.101
2019-09-23 04:52:12,342 [myid:] - INFO  [main:QuorumPeerConfig@398] - Defaulting to majority quorums
2019-09-23 04:52:12,345 [myid:1] - INFO  [main:DatadirCleanupManager@78] - autopurge.snapRetainCount set to 3
2019-09-23 04:52:12,346 [myid:1] - INFO  [main:DatadirCleanupManager@79] - autopurge.purgeInterval set to 0
2019-09-23 04:52:12,346 [myid:1] - INFO  [main:DatadirCleanupManager@101] - Purge task is not scheduled.
2019-09-23 04:52:12,373 [myid:1] - INFO  [main:QuorumPeerMain@130] - Starting quorum peer
2019-09-23 04:52:12,379 [myid:1] - INFO  [main:ServerCnxnFactory@117] - Using org.apache.zookeeper.server.NIOServerCnxnFactory as server connection factory
2019-09-23 04:52:12,492 [myid:1] - INFO  [main:Login@297] - Server successfully logged in.
2019-09-23 04:52:12,494 [myid:1] - INFO  [main:NIOServerCnxnFactory@89] - binding to port 0.0.0.0/0.0.0.0:2181
2019-09-23 04:52:12,495 [myid:1] - ERROR [main:QuorumPeerMain@92] - 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:90)
	at org.apache.zookeeper.server.quorum.QuorumPeerMain.runFromConfig(QuorumPeerMain.java:133)
	at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:114)
	at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:81)

如日志所示,该错误是由于Zookeeper对应的端口号被占用导致的。

查看端口占用情况:
[ipaas@admin01 bin]$ sudo netstat -nltp | grep 2181
tcp6       0      0 :::2181                 :::*                    LISTEN      37431/java

如上所示,占用Zookeeper对应端口号的应用是java,只需要kill掉该应用就能成功启动Zookeeper了。

[ipaas@admin01 bin]$ kill -9 37431

重新启动zookeeper,结果如下所示:

[ipaas@admin01 bin]$  ./zkServer.sh start-foreground
ZooKeeper JMX enabled by default
Using config: /home/ipaas/zookeeper/zookeeper-3.4.11/bin/../conf/zoo.cfg
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/ipaas/zookeeper/zookeeper-3.4.11/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/ipaas/zookeeper/zookeeper-3.4.11/lib/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
2019-09-23 04:56:33,944 [myid:] - INFO  [main:QuorumPeerConfig@136] - Reading configuration from: /home/ipaas/zookeeper/zookeeper-3.4.11/bin/../conf/zoo.cfg
2019-09-23 04:56:33,969 [myid:] - INFO  [main:QuorumPeer$QuorumServer@184] - Resolved hostname: 192.168.47.103 to address: /192.168.47.103
2019-09-23 04:56:33,969 [myid:] - INFO  [main:QuorumPeer$QuorumServer@184] - Resolved hostname: 192.168.47.102 to address: /192.168.47.102
2019-09-23 04:56:33,970 [myid:] - INFO  [main:QuorumPeer$QuorumServer@184] - Resolved hostname: 192.168.47.101 to address: /192.168.47.101
2019-09-23 04:56:33,970 [myid:] - INFO  [main:QuorumPeerConfig@398] - Defaulting to majority quorums
2019-09-23 04:56:33,978 [myid:1] - INFO  [main:DatadirCleanupManager@78] - autopurge.snapRetainCount set to 3
2019-09-23 04:56:33,979 [myid:1] - INFO  [main:DatadirCleanupManager@79] - autopurge.purgeInterval set to 0
2019-09-23 04:56:33,979 [myid:1] - INFO  [main:DatadirCleanupManager@101] - Purge task is not scheduled.
2019-09-23 04:56:34,007 [myid:1] - INFO  [main:QuorumPeerMain@130] - Starting quorum peer
2019-09-23 04:56:34,012 [myid:1] - INFO  [main:ServerCnxnFactory@117] - Using org.apache.zookeeper.server.NIOServerCnxnFactory as server connection factory
2019-09-23 04:56:34,134 [myid:1] - INFO  [main:Login@297] - Server successfully logged in.
2019-09-23 04:56:34,136 [myid:1] - INFO  [main:NIOServerCnxnFactory@89] - binding to port 0.0.0.0/0.0.0.0:2181
2019-09-23 04:56:34,141 [myid:1] - INFO  [main:QuorumPeer@1158] - tickTime set to 2000
2019-09-23 04:56:34,141 [myid:1] - INFO  [main:QuorumPeer@1204] - initLimit set to 10
2019-09-23 04:56:34,141 [myid:1] - INFO  [main:QuorumPeer@1178] - minSessionTimeout set to -1
2019-09-23 04:56:34,142 [myid:1] - INFO  [main:QuorumPeer@1189] - maxSessionTimeout set to -1
2019-09-23 04:56:34,161 [myid:1] - INFO  [main:QuorumPeer@1467] - QuorumPeer communication is not secured!
2019-09-23 04:56:34,161 [myid:1] - INFO  [main:QuorumPeer@1496] - quorum.cnxn.threads.size set to 20
2019-09-23 04:56:34,164 [myid:1] - INFO  [main:QuorumPeer@668] - currentEpoch not found! Creating with a reasonable default of 0. This should only happen when you are upgrading your installation
2019-09-23 04:56:34,175 [myid:1] - INFO  [main:QuorumPeer@683] - acceptedEpoch not found! Creating with a reasonable default of 0. This should only happen when you are upgrading your installation
2019-09-23 04:56:34,191 [myid:1] - INFO  [ListenerThread:QuorumCnxManager$Listener@736] - My election bind port: /192.168.47.101:3888
2019-09-23 04:56:34,201 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumPeer@909] - LOOKING
2019-09-23 04:56:34,202 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:FastLeaderElection@820] - New election. My id =  1, proposed zxid=0x0
2019-09-23 04:56:34,208 [myid:1] - INFO  [WorkerReceiver[myid=1]:FastLeaderElection@602] - Notification: 1 (message format version), 1 (n.leader), 0x0 (n.zxid), 0x1 (n.round), LOOKING (n.state), 1 (n.sid), 0x0 (n.peerEpoch) LOOKING (my state)
2019-09-23 04:56:34,214 [myid:1] - INFO  [WorkerSender[myid=1]:QuorumCnxManager@347] - Have smaller server identifier, so dropping the connection: (2, 1)
2019-09-23 04:56:34,218 [myid:1] - INFO  [WorkerSender[myid=1]:QuorumCnxManager@347] - Have smaller server identifier, so dropping the connection: (3, 1)
2019-09-23 04:56:34,427 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@347] - Have smaller server identifier, so dropping the connection: (2, 1)
2019-09-23 04:56:34,433 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@347] - Have smaller server identifier, so dropping the connection: (3, 1)
2019-09-23 04:56:34,435 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:FastLeaderElection@854] - Notification time out: 400
2019-09-23 04:56:34,848 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@347] - Have smaller server identifier, so dropping the connection: (2, 1)
2019-09-23 04:56:34,853 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@347] - Have smaller server identifier, so dropping the connection: (3, 1)
2019-09-23 04:56:34,854 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:FastLeaderElection@854] - Notification time out: 800
2019-09-23 04:56:35,658 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@347] - Have smaller server identifier, so dropping the connection: (2, 1)
2019-09-23 04:56:35,664 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@347] - Have smaller server identifier, so dropping the connection: (3, 1)
2019-09-23 04:56:35,665 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:FastLeaderElection@854] - Notification time out: 1600
2019-09-23 04:56:37,269 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@347] - Have smaller server identifier, so dropping the connection: (2, 1)
2019-09-23 04:56:37,273 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@347] - Have smaller server identifier, so dropping the connection: (3, 1)
2019-09-23 04:56:37,275 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:FastLeaderElection@854] - Notification time out: 3200
2019-09-23 04:56:40,506 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@347] - Have smaller server identifier, so dropping the connection: (2, 1)
2019-09-23 04:56:40,510 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@347] - Have smaller server identifier, so dropping the connection: (3, 1)
2019-09-23 04:56:40,512 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:FastLeaderElection@854] - Notification time out: 6400
2019-09-23 04:56:46,918 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@347] - Have smaller server identifier, so dropping the connection: (2, 1)
2019-09-23 04:56:46,922 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@347] - Have smaller server identifier, so dropping the connection: (3, 1)
2019-09-23 04:56:46,923 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:FastLeaderElection@854] - Notification time out: 12800
2019-09-23 04:56:59,729 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@347] - Have smaller server identifier, so dropping the connection: (2, 1)
2019-09-23 04:56:59,733 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@347] - Have smaller server identifier, so dropping the connection: (3, 1)
2019-09-23 04:56:59,734 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:FastLeaderElection@854] - Notification time out: 25600
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值