zookeeper启动的时候显示成功,但是jps缺什么都没有。原来是端口被占用,启动失败了。

查看安装目录的logs目录下面的日志,发现是8080端口被其他进程占用了。(我启动了spark任务,spark的web ui默认也是使用8080端口)

 

题外话,zookeeper的启动日志有bug, Starting zookeeper ... STARTED日志打印出来后,就应该说明zookeeper启动成功。但是居然还是失败了,这里zookeeper团队应该改下源码逻辑了。

 

启动的日志

ZooKeeper JMX enabled by default
Using config: /opt/module/apache-zookeeper-3.5.7-bin/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

  

logs目录下面的日志

2021-12-18 12:21:44,948 [myid:] - INFO  [main:QuorumPeerConfig@135] - Reading configuration from: /opt/module/apache-zookeeper-3.5.7-bin/bin/../conf/zoo.cfg
2021-12-18 12:21:44,960 [myid:] - INFO  [main:QuorumPeerConfig@387] - clientPortAddress is 0.0.0.0:2181
2021-12-18 12:21:44,960 [myid:] - INFO  [main:QuorumPeerConfig@391] - secureClientPort is not set
2021-12-18 12:21:44,963 [myid:] - INFO  [main:DatadirCleanupManager@78] - autopurge.snapRetainCount set to 3
2021-12-18 12:21:44,963 [myid:] - INFO  [main:DatadirCleanupManager@79] - autopurge.purgeInterval set to 0
2021-12-18 12:21:44,963 [myid:] - INFO  [main:DatadirCleanupManager@101] - Purge task is not scheduled.
2021-12-18 12:21:44,963 [myid:] - WARN  [main:QuorumPeerMain@125] - Either no config or no quorum defined in config, running  in standalone mode
2021-12-18 12:21:44,968 [myid:] - INFO  [main:ManagedUtil@46] - Log4j found with jmx enabled.
2021-12-18 12:21:44,979 [myid:] - INFO  [main:QuorumPeerConfig@135] - Reading configuration from: /opt/module/apache-zookeeper-3.5.7-bin/bin/../conf/zoo.cfg
2021-12-18 12:21:44,979 [myid:] - INFO  [main:QuorumPeerConfig@387] - clientPortAddress is 0.0.0.0:2181
2021-12-18 12:21:44,979 [myid:] - INFO  [main:QuorumPeerConfig@391] - secureClientPort is not set
2021-12-18 12:21:44,979 [myid:] - INFO  [main:ZooKeeperServerMain@117] - Starting server
2021-12-18 12:21:44,982 [myid:] - INFO  [main:FileTxnSnapLog@115] - zookeeper.snapshot.trust.empty : false
2021-12-18 12:21:44,997 [myid:] - INFO  [main:Environment@109] - Server environment:zookeeper.version=3.5.7-f0fdd52973d373ffd9c86b81d99842dc2c7f660e, built on 02/10/2020 11:30 GMT
2021-12-18 12:21:44,997 [myid:] - INFO  [main:Environment@109] - Server environment:host.name=CentOS102
2021-12-18 12:21:44,997 [myid:] - INFO  [main:Environment@109] - Server environment:java.version=1.8.0_212
2021-12-18 12:21:44,998 [myid:] - INFO  [main:Environment@109] - Server environment:java.vendor=Oracle Corporation
2021-12-18 12:21:44,998 [myid:] - INFO  [main:Environment@109] - Server environment:java.home=/opt/module/jdk1.8.0_212/jre
2021-12-18 12:21:44,998 [myid:] - INFO  [main:Environment@109] - Server environment:java.class.path=/opt/module/apache-zookeeper-3.5.7-bin/bin/../zookeeper-server/target/classes:/opt/module/apache-zookeeper-3.5.7-bin/bin/../build/classes:/opt/module/apache-zookeeper-3.5.7-bin/bin/../zookeeper-server/target/lib/*.jar:/opt/module/apache-zookeeper-3.5.7-bin/bin/../build/lib/*.jar:/opt/module/apache-zookeeper-3.5.7-bin/bin/../lib/zookeeper-jute-3.5.7.jar:/opt/module/apache-zookeeper-3.5.7-bin/bin/../lib/zookeeper-3.5.7.jar:/opt/module/apache-zookeeper-3.5.7-bin/bin/../lib/slf4j-log4j12-1.7.25.jar:/opt/module/apache-zookeeper-3.5.7-bin/bin/../lib/slf4j-api-1.7.25.jar:/opt/module/apache-zookeeper-3.5.7-bin/bin/../lib/netty-transport-native-unix-common-4.1.45.Final.jar:/opt/module/apache-zookeeper-3.5.7-bin/bin/../lib/netty-transport-native-epoll-4.1.45.Final.jar:/opt/module/apache-zookeeper-3.5.7-bin/bin/../lib/netty-transport-4.1.45.Final.jar:/opt/module/apache-zookeeper-3.5.7-bin/bin/../lib/netty-resolver-4.1.45.Final.jar:/opt/module/apache-zookeeper-3.5.7-bin/bin/../lib/netty-handler-4.1.45.Final.jar:/opt/module/apache-zookeeper-3.5.7-bin/bin/../lib/netty-common-4.1.45.Final.jar:/opt/module/apache-zookeeper-3.5.7-bin/bin/../lib/netty-codec-4.1.45.Final.jar:/opt/module/apache-zookeeper-3.5.7-bin/bin/../lib/netty-buffer-4.1.45.Final.jar:/opt/module/apache-zookeeper-3.5.7-bin/bin/../lib/log4j-1.2.17.jar:/opt/module/apache-zookeeper-3.5.7-bin/bin/../lib/json-simple-1.1.1.jar:/opt/module/apache-zookeeper-3.5.7-bin/bin/../lib/jline-2.11.jar:/opt/module/apache-zookeeper-3.5.7-bin/bin/../lib/jetty-util-9.4.24.v20191120.jar:/opt/module/apache-zookeeper-3.5.7-bin/bin/../lib/jetty-servlet-9.4.24.v20191120.jar:/opt/module/apache-zookeeper-3.5.7-bin/bin/../lib/jetty-server-9.4.24.v20191120.jar:/opt/module/apache-zookeeper-3.5.7-bin/bin/../lib/jetty-security-9.4.24.v20191120.jar:/opt/module/apache-zookeeper-3.5.7-bin/bin/../lib/jetty-io-9.4.24.v20191120.jar:/opt/module/apache-zookeeper-3.5.7-bin/bin/../lib/jetty-http-9.4.24.v20191120.jar:/opt/module/apache-zookeeper-3.5.7-bin/bin/../lib/javax.servlet-api-3.1.0.jar:/opt/module/apache-zookeeper-3.5.7-bin/bin/../lib/jackson-databind-2.9.10.2.jar:/opt/module/apache-zookeeper-3.5.7-bin/bin/../lib/jackson-core-2.9.10.jar:/opt/module/apache-zookeeper-3.5.7-bin/bin/../lib/jackson-annotations-2.9.10.jar:/opt/module/apache-zookeeper-3.5.7-bin/bin/../lib/commons-cli-1.2.jar:/opt/module/apache-zookeeper-3.5.7-bin/bin/../lib/audience-annotations-0.5.0.jar:/opt/module/apache-zookeeper-3.5.7-bin/bin/../zookeeper-*.jar:/opt/module/apache-zookeeper-3.5.7-bin/bin/../zookeeper-server/src/main/resources/lib/*.jar:/opt/module/apache-zookeeper-3.5.7-bin/bin/../conf:
2021-12-18 12:21:44,998 [myid:] - INFO  [main:Environment@109] - Server environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2021-12-18 12:21:44,998 [myid:] - INFO  [main:Environment@109] - Server environment:java.io.tmpdir=/tmp
2021-12-18 12:21:44,998 [myid:] - INFO  [main:Environment@109] - Server environment:java.compiler=<NA>
2021-12-18 12:21:44,998 [myid:] - INFO  [main:Environment@109] - Server environment:os.name=Linux
2021-12-18 12:21:44,998 [myid:] - INFO  [main:Environment@109] - Server environment:os.arch=amd64
2021-12-18 12:21:44,998 [myid:] - INFO  [main:Environment@109] - Server environment:os.version=3.10.0-693.el7.x86_64
2021-12-18 12:21:44,998 [myid:] - INFO  [main:Environment@109] - Server environment:user.name=yuanqiao
2021-12-18 12:21:44,998 [myid:] - INFO  [main:Environment@109] - Server environment:user.home=/home/yuanqiao
2021-12-18 12:21:44,998 [myid:] - INFO  [main:Environment@109] - Server environment:user.dir=/opt/module/apache-zookeeper-3.5.7-bin
2021-12-18 12:21:44,999 [myid:] - INFO  [main:Environment@109] - Server environment:os.memory.free=10MB
2021-12-18 12:21:44,999 [myid:] - INFO  [main:Environment@109] - Server environment:os.memory.max=966MB
2021-12-18 12:21:44,999 [myid:] - INFO  [main:Environment@109] - Server environment:os.memory.total=15MB
2021-12-18 12:21:44,999 [myid:] - INFO  [main:ZooKeeperServer@938] - minSessionTimeout set to 4000
2021-12-18 12:21:45,000 [myid:] - INFO  [main:ZooKeeperServer@947] - maxSessionTimeout set to 40000
2021-12-18 12:21:45,000 [myid:] - INFO  [main:ZooKeeperServer@166] - Created server with tickTime 2000 minSessionTimeout 4000 maxSessionTimeout 40000 datadir /opt/module/apache-zookeeper-3.5.7-bin/zkData/version-2 snapdir /opt/module/apache-zookeeper-3.5.7-bin/zkData/version-2
2021-12-18 12:21:45,024 [myid:] - INFO  [main:Log@169] - Logging initialized @453ms to org.eclipse.jetty.util.log.Slf4jLog
2021-12-18 12:21:45,161 [myid:] - WARN  [main:ContextHandler@1520] - o.e.j.s.ServletContextHandler@1e127982{/,null,UNAVAILABLE} contextPath ends with /*
2021-12-18 12:21:45,162 [myid:] - WARN  [main:ContextHandler@1531] - Empty contextPath
2021-12-18 12:21:45,172 [myid:] - INFO  [main:Server@359] - jetty-9.4.24.v20191120; built: 2019-11-20T21:37:49.771Z; git: 363d5f2df3a8a28de40604320230664b9c793c16; jvm 1.8.0_212-b10
2021-12-18 12:21:45,202 [myid:] - INFO  [main:DefaultSessionIdManager@333] - DefaultSessionIdManager workerName=node0
2021-12-18 12:21:45,202 [myid:] - INFO  [main:DefaultSessionIdManager@338] - No SessionScavenger set, using defaults
2021-12-18 12:21:45,203 [myid:] - INFO  [main:HouseKeeper@140] - node0 Scavenging every 660000ms
2021-12-18 12:21:45,229 [myid:] - INFO  [main:ContextHandler@825] - Started o.e.j.s.ServletContextHandler@1e127982{/,null,AVAILABLE}
2021-12-18 12:21:45,242 [myid:] - ERROR [main:ZooKeeperServerMain@79] - Unable to start AdminServer, exiting abnormally
org.apache.zookeeper.server.admin.AdminServer$AdminServerException: Problem starting AdminServer on address 0.0.0.0, port 8080 and command URL /commands
	at org.apache.zookeeper.server.admin.JettyAdminServer.start(JettyAdminServer.java:107)
	at org.apache.zookeeper.server.ZooKeeperServerMain.runFromConfig(ZooKeeperServerMain.java:138)
	at org.apache.zookeeper.server.ZooKeeperServerMain.initializeAndRun(ZooKeeperServerMain.java:106)
	at org.apache.zookeeper.server.ZooKeeperServerMain.main(ZooKeeperServerMain.java:64)
	at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:128)
	at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:82)
Caused by: java.io.IOException: Failed to bind to /0.0.0.0:8080
	at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:346)
	at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:307)
	at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
	at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:231)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:72)
	at org.eclipse.jetty.server.Server.doStart(Server.java:385)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:72)
	at org.apache.zookeeper.server.admin.JettyAdminServer.start(JettyAdminServer.java:103)
	... 5 more
Caused by: java.net.BindException: 地址已在使用
	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 org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:342)
	... 12 more
Unable to start AdminServer, exiting abnormally

  

 

扩展知识:

如果查看linux端口是否被占用?

https://www.bilibili.com/video/BV19T4y1T7vo

如何修改spark的web ui的8080端口?

https://www.shangmayuan.com/a/f2a1c050fe4e46d99da4723d.html

 

posted on 2021-12-18 12:28  坚守梦想  阅读(1380)  评论(0编辑  收藏  举报