Zookeeper启动失败,提示:java.net.BindException: Address already in use
现象:[ ~]$ cat /version/app/wui/zookeeper.out2019-05-08 08:47:13,620 [myid:] - INFO[main:QuorumPeerConfig@136] - Reading configuration from: /usr/local/zk/bin/…/conf/zoo.cfg2019-05-08 08:47:13,633 ...
现象:
[ ~]$ cat /version/app/wui/zookeeper.out
2019-05-08 08:47:13,620 [myid:] - INFO [main:QuorumPeerConfig@136] - Reading configuration from: /usr/local/zk/bin/…/conf/zoo.cfg
2019-05-08 08:47:13,633 [myid:] - INFO [main:QuorumPeer
Q
u
o
r
u
m
S
e
r
v
e
r
@
184
]
−
R
e
s
o
l
v
e
d
h
o
s
t
n
a
m
e
:
129.0.63.2
t
o
a
d
d
r
e
s
s
:
/
129.0.63.22019
−
05
−
0808
:
47
:
13
,
633
[
m
y
i
d
:
]
−
I
N
F
O
[
m
a
i
n
:
Q
u
o
r
u
m
P
e
e
r
QuorumServer@184] - Resolved hostname: 129.0.63.2 to address: /129.0.63.2 2019-05-08 08:47:13,633 [myid:] - INFO [main:QuorumPeer
QuorumServer@184]−Resolvedhostname:129.0.63.2toaddress:/129.0.63.22019−05−0808:47:13,633[myid:]−INFO[main:QuorumPeerQuorumServer@184] - Resolved hostname: 129.0.63.1 to address: /129.0.63.1
2019-05-08 08:47:13,634 [myid:] - WARN [main:QuorumPeerConfig@351] - No server failure will be tolerated. You need at least 3 servers.
2019-05-08 08:47:13,634 [myid:] - INFO [main:QuorumPeerConfig@398] - Defaulting to majority quorums
2019-05-08 08:47:13,637 [myid:1] - INFO [main:DatadirCleanupManager@78] - autopurge.snapRetainCount set to 3
2019-05-08 08:47:13,637 [myid:1] - INFO [main:DatadirCleanupManager@79] - autopurge.purgeInterval set to 0
2019-05-08 08:47:13,638 [myid:1] - INFO [main:DatadirCleanupManager@101] - Purge task is not scheduled.
2019-05-08 08:47:13,647 [myid:1] - INFO [main:QuorumPeerMain@130] - Starting quorum peer
2019-05-08 08:47:13,654 [myid:1] - INFO [main:ServerCnxnFactory@117] - Using org.apache.zookeeper.server.NIOServerCnxnFactory as server connection factory
2019-05-08 08:47:13,657 [myid:1] - INFO [main:NIOServerCnxnFactory@89] - binding to port 0.0.0.0/0.0.0.0:2181
2019-05-08 08:47:13,657 [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)
原因:
zoo.cfg中选项clientPort配置的端口号2181已经被占用。
执行命令查看:
[~]$ sudo netstat -nltp | grep 2181
tcp6 0 0 :::2181 ::? LISTEN 6693/java
解决方法:
有两种方法:
一是:将占用2181端口的进程杀死:kill -9 6693;
或者是:修改clientPort选项的配置,比如配置为2282.
然后重启zookeeper服务即可。
更多推荐
所有评论(0)