ZooKeeper启动报错,未成功开启服务

1、问题示例

(1)启动ZooKeeper服务报错

[Hadoop@master ~]$ zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /home/Hadoop/ZooKeeper/zookeeper-3.7.0/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Error contacting service. It is probably not running.

(2)查看ZooKeeper日志

[Hadoop@master ZooKeeper]$ zkServer.sh start-foreground
ZooKeeper JMX enabled by default
Using config: /home/Hadoop/ZooKeeper/zookeeper-3.7.0/bin/../conf/zoo.cfg
2021-11-02 00:53:27,801 [myid:] - INFO [main:QuorumPeerConfig@174] - Reading configuration from: /home/Hadoop/ZooKeeper/zookeeper-3.7.0/bin/../conf/zoo.cfg
2021-11-02 00:53:27,810 [myid:] - INFO [main:QuorumPeerConfig@444] - clientPortAddress is 0.0.0.0:2181
2021-11-02 00:53:27,810 [myid:] - INFO [main:QuorumPeerConfig@448] - secureClientPort is not set
2021-11-02 00:53:27,810 [myid:] - INFO [main:QuorumPeerConfig@464] - observerMasterPort is not set
2021-11-02 00:53:27,811 [myid:] - INFO [main:QuorumPeerConfig@481] - metricsProvider.className is org.apache.zookeeper.metrics.impl.DefaultMetricsProvider
2021-11-02 00:53:27,816 [myid:1] - INFO [main:DatadirCleanupManager@78] - autopurge.snapRetainCount set to 3
2021-11-02 00:53:27,816 [myid:1] - INFO [main:DatadirCleanupManager@79] - autopurge.purgeInterval set to 0
2021-11-02 00:53:27,817 [myid:1] - INFO [main:DatadirCleanupManager@101] - Purge task is not scheduled.
2021-11-02 00:53:27,818 [myid:1] - INFO [main:ManagedUtil@44] - Log4j 1.2 jmx support found and enabled.
2021-11-02 00:53:27,823 [myid:1] - INFO [main:QuorumPeerMain@152] - Starting quorum peer, myid=1
2021-11-02 00:53:27,830 [myid:1] - INFO [main:ServerMetrics@62] - ServerMetrics initialized with provider org.apache.zookeeper.metrics.impl.DefaultMetricsProvider@19dfb72a
2021-11-02 00:53:27,832 [myid:1] - INFO [main:DigestAuthenticationProvider@47] - ACL digest algorithm is: SHA1
2021-11-02 00:53:27,832 [myid:1] - INFO [main:DigestAuthenticationProvider@61] - zookeeper.DigestAuthenticationProvider.enabled = true
2021-11-02 00:53:27,835 [myid:1] - INFO [main:ServerCnxnFactory@169] - Using org.apache.zookeeper.server.NIOServerCnxnFactory as server connection factory
2021-11-02 00:53:27,836 [myid:1] - WARN [main:ServerCnxnFactory@309] - maxCnxns is not configured, using default value 0.
2021-11-02 00:53:27,837 [myid:1] - INFO [main:NIOServerCnxnFactory@652] - Configuring NIO connection handler with 10s sessionless connection timeout, 1 selector thread(s), 4 worker threads, and 64 kB direct buffers.
2021-11-02 00:53:27,841 [myid:1] - INFO [main:NIOServerCnxnFactory@660] - binding to port 0.0.0.0/0.0.0.0:2181
2021-11-02 00:53:27,842 [myid:1] - ERROR [main:QuorumPeerMain@114] - Unexpected exception, exiting abnormally
java.net.BindException: 地址已在使用
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:438)
at sun.nio.ch.Net.bind(Net.java:430)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:225)
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:662)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.runFromConfig(QuorumPeerMain.java:169)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:137)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:91)
2021-11-02 00:53:27,843 [myid:1] - INFO [main:ZKAuditProvider@42] - ZooKeeper audit is disabled.
2021-11-02 00:53:27,844 [myid:1] - ERROR [main:ServiceUtils@42] - Exiting JVM with code 1

2、问题剖析

 

3、解决方案

 

上一篇:力扣 - 剑指 Offer 53 - II. 0~n-1中缺失的数字


下一篇:【力扣】 - 53. 最大子序和