关闭zookeeper时出现Stopping zookeeper ... no zookeeper to stop (could not find file /tmp/zookeeper/zookeeper_server.pid)

1. 问题

  最近同事在查看ft一个问题时,告诉我kafka和ft用的不是一个java环境,让我检查修改下。关闭kafka很正常,但是关zookeeper时死活关不掉,报错:

ZooKeeper JMX enabled by default
Using config: /usr/local/apache-zookeeper-3.5.8-bin/bin/../conf/zoo.cfg
Stopping zookeeper ... no zookeeper to stop (could not find file /tmp/zookeeper/zookeeper_server.pid)

查看原因及解决请直接跳到3

2. 排查

  先看下状态,好像没啥问题啊。

# ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/apache-zookeeper-3.5.8-bin/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost.
Mode: standalone

  接着关闭

# ./zkServer.sh stop
ZooKeeper JMX enabled by default
Using config: /usr/local/apache-zookeeper-3.5.8-bin/bin/../conf/zoo.cfg
Stopping zookeeper ... no zookeeper to stop (could not find file /tmp/zookeeper/zookeeper_server.pid)

  重启下

ZooKeeper JMX enabled by default
Using config: /usr/local/apache-zookeeper-3.5.8-bin/bin/../conf/zoo.cfg
ZooKeeper JMX enabled by default
Using config: /usr/local/apache-zookeeper-3.5.8-bin/bin/../conf/zoo.cfg
Stopping zookeeper ... no zookeeper to stop (could not find file /tmp/zookeeper/zookeeper_server.pid)
ZooKeeper JMX enabled by default
Using config: /usr/local/apache-zookeeper-3.5.8-bin/bin/../conf/zoo.cfg
Starting zookeeper ... FAILED TO START

  重启不了,查下进程(动杀心了)

# ps -ef|grep zookeeper
root      1540 19251  0 14:04 pts/3    00:00:00 grep --color=auto zookeeper
root     23777     1  0 9月10 ?       01:02:31 /usr/local/java/jdk1.8.0_191/bin/java -Dzookeeper.log.dir=/usr/local/apache-zookeeper-3.5.8-bin/bin/../logs -Dzookeeper.log.file=zookeeper-root-server-localhost.localdomain.log -Dzookeeper.root.logger=INFO,CONSOLE -XX:+HeapDumpOnOutOfMemoryError -XX:OnOutOfMemoryError=kill -9 %p -cp /usr/local/apache-zookeeper-3.5.8-bin/bin/../zookeeper-server/target/classes:/usr/local/apache-zookeeper-3.5.8-bin/bin/../build/classes:/usr/local/apache-zookeeper-3.5.8-bin/bin/../zookeeper-server/target/lib/*.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../build/lib/*.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/zookeeper-jute-3.5.8.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/zookeeper-3.5.8.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/slf4j-log4j12-1.7.25.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/slf4j-api-1.7.25.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/netty-transport-native-unix-common-4.1.48.Final.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/netty-transport-native-epoll-4.1.48.Final.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/netty-transport-4.1.48.Final.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/netty-resolver-4.1.48.Final.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/netty-handler-4.1.48.Final.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/netty-common-4.1.48.Final.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/netty-codec-4.1.48.Final.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/netty-buffer-4.1.48.Final.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/log4j-1.2.17.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/json-simple-1.1.1.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jline-2.11.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jetty-util-9.4.24.v20191120.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jetty-servlet-9.4.24.v20191120.jar:/usr/local/apachezookeeper-3.5.8-bin/bin/../lib/jetty-server-9.4.24.v20191120.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jetty-security-9.4.24.v20191120.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jetty-io-9.4.24.v20191120.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jetty-http-9.4.24.v20191120.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/javax.servlet-api-3.1.0.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jackson-databind-2.10.3.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jackson-core-2.10.3.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jackson-annotations-2.10.3.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/commons-cli-1.2.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/audience-annotations-0.5.0.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../zookeeper-*.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../zookeeper-server/src/main/resources/lib/*.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../conf:.:/usr/local/java/jdk1.8.0_191/lib/dt.jar:/usr/local/java/jdk1.8.0_191/lib/tools.jar -Xmx1000m -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.QuorumPeerMain /usr/local/apache-zookeeper-3.5.8-bin/bin/../conf/zoo.cfg
root     30344     1  1 9月14 ?       11:02:41 /usr/local/java/jdk1.8.0_191/bin/java -Xmx1G -Xms1G -server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:+ExplicitGCInvokesConcurrent -XX:MaxInlineLevel=15 -Djava.awt.headless=true -Xloggc:/usr/local/kafka_2.12-2.6.0/bin/../logs/kafkaServer-gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dkafka.logs.dir=/usr/local/kafka_2.12-2.6.0/bin/../logs -Dlog4j.configuration=file:bin/../config/log4j.properties -cp .:/usr/local/java/jdk1.8.0_191/lib/dt.jar:/usr/local/java/jdk1.8.0_191/lib/tools.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/activation-1.1.1.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/aopalliance-repackaged-2.5.0.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/argparse4j-0.7.0.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/audience-annotations-0.5.0.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/commons-cli-1.4.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/commons-lang3-3.8.1.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/connect-api-2.6.0.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/connect-basic-auth-extension-2.6.0.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/connect-file-2.6.0.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/connect-json-2.6.0.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/connect-mirror-2.6.0.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/connect-mirror-client-2.6.0.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/connect-runtime-2.6.0.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/connect-transforms-2.6.0.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/hk2-api-2.5.0.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/hk2-locator-2.5.0.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/hk2-utils-2.5.0.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/jackson-annotations-2.10.2.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/jackson-core-2.10.2.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/jackson-databind-2.10.2.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/jackson-dataformat-csv-2.10.2.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/jackson-datatype-jdk8-2.10.2.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/jackson-jaxrs-base-2.10.2.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/jackson-jaxrs-json-provider-2.10.2.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/jackson-module-jaxb-annotations-2.10.2.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/jackson-module-paranamer-2.10.2.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/jackson-module-scala_2.12-2.10.2.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/jakarta.activation-api-1.2.1.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/jakarta.annotation-api-1.3.4.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/jakarta.inject-2.5.0.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/jakarta.ws.rs-api-2.1.5.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/jakarta.xml.bind-api-2.3.2.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/javassist-3.22.0-CR2.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/javassist-3.26.0-GA.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/javax.servlet-api-3.1.0.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/javax.ws.rs-api-2.1.1.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/jaxb-api-2.3.0.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/jersey-client-2.28.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/jersey-common-2.28.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/jersey-container-servlet-2.28.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/jersey-container-servlet-core-2.28.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/jersey-hk2-2.28.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/jersey-media-jaxb-2.28.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/jersey-server-2.28.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/jetty-client-9.4.24.v20191120.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/jetty-continuation-9.4.24.v20191120.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/jetty-http-9.4.24.v20191120.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/jetty-io-9.4.24.v20191120.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/jetty-security-9.4.24.v20191120.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/jetty-server-9.4.24.v20191120.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/jetty-servlet-9.4.24.v20191120.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/jetty-servlets-9.4.24.v20191120.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/jetty-util-9.4.24.v20191120.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/jopt-simple-5.0.4.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/kafka_2.12-2.6.0.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/kafka_2.12-2.6.0-sources.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/kafka-clients-2.6.0.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/kafka-log4j-appender-2.6.0.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/kafka-streams-2.6.0.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/kafka-streams-examples-2.6.0.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/kafka-streams-scala_2.12-2.6.0.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/kafka-streams-test-utils-2.6.0.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/kafka-tools-2.6.0.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/log4j-1.2.17.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/lz4-java-1.7.1.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/maven-artifact-3.6.3.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/metrics-core-2.2.0.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/netty-buffer-4.1.50.Final.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/netty-codec-4.1.50.Final.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/netty-common-4.1.50.Final.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/netty-handler-4.1.50.Final.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/netty-resolver-4.1.50.Final.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/netty-transport-4.1.50.Final.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/netty-transport-native-epoll-4.1.50.Final.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/netty-transport-native-unix-common-4.1.50.Final.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/osgi-resource-locator-1.0.1.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/paranamer-2.8.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/plexus-utils-3.2.1.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/reflections-0.9.12.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/rocksdbjni-5.18.4.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/scala-collection-compat_2.12-2.1.6.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/scala-java8-compat_2.12-0.9.1.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/scala-library-2.12.11.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/scala-logging_2.12-3.9.2.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/scala-reflect-2.12.11.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/slf4j-api-1.7.30.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/slf4j-log4j12-1.7.30.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/snappy-java-1.1.7.3.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/validation-api-2.0.1.Final.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/zookeeper-3.5.8.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/zookeeper-jute-3.5.8.jar:/usr/local/kafka_2.12-2.6.0/bin/../libs/zstd-jni-1.4.4-7.jar kafka.Kafka config/server.properties

  看下2181端口情况

# netstat -nltp | grep 2181
tcp6       0      0 :::2181                 :::*                    LISTEN      23777/java

  23777也就是jps查出来的zookeeper进程

# jps
23777 QuorumPeerMain
14904 StarterKt
12477 Jps

  kill掉就行了

# kill -9 23777
# jps
14087 Jps
14904 StarterKt
# netstat -nltp | grep 2181

  现在应该已经停了,先看下状态

ZooKeeper JMX enabled by default
Using config: /usr/local/apache-zookeeper-3.5.8-bin/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost.
Error contacting service. It is probably not running.

  确实停止了,接着重启

# ./zkServer.sh restart
ZooKeeper JMX enabled by default
Using config: /usr/local/apache-zookeeper-3.5.8-bin/bin/../conf/zoo.cfg
ZooKeeper JMX enabled by default
Using config: /usr/local/apache-zookeeper-3.5.8-bin/bin/../conf/zoo.cfg
Stopping zookeeper ... no zookeeper to stop (could not find file /tmp/zookeeper/zookeeper_server.pid)
ZooKeeper JMX enabled by default
Using config: /usr/local/apache-zookeeper-3.5.8-bin/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

  看下日志

# cat ../logs/zookeeper-root-server-localhost.localdomain.out
2021-10-27 14:47:42,260 [myid:] - INFO  [main:QuorumPeerConfig@135] - Reading configuration from: /usr/local/apache-zookeeper-3.5.8-bin/bin/../conf/zoo.cfg
2021-10-27 14:47:42,272 [myid:] - INFO  [main:QuorumPeerConfig@387] - clientPortAddress is 0.0.0.0:2181
2021-10-27 14:47:42,272 [myid:] - INFO  [main:QuorumPeerConfig@391] - secureClientPort is not set
2021-10-27 14:47:42,274 [myid:] - INFO  [main:DatadirCleanupManager@78] - autopurge.snapRetainCount set to 3
2021-10-27 14:47:42,274 [myid:] - INFO  [main:DatadirCleanupManager@79] - autopurge.purgeInterval set to 0
2021-10-27 14:47:42,274 [myid:] - INFO  [main:DatadirCleanupManager@101] - Purge task is not scheduled.
2021-10-27 14:47:42,274 [myid:] - WARN  [main:QuorumPeerMain@125] - Either no config or no quorum defined in config, running  in standalone mode
2021-10-27 14:47:42,277 [myid:] - INFO  [main:ManagedUtil@45] - Log4j 1.2 jmx support found and enabled.
2021-10-27 14:47:42,284 [myid:] - INFO  [main:QuorumPeerConfig@135] - Reading configuration from: /usr/local/apache-zookeeper-3.5.8-bin/bin/../conf/zoo.cfg
2021-10-27 14:47:42,284 [myid:] - INFO  [main:QuorumPeerConfig@387] - clientPortAddress is 0.0.0.0:2181
2021-10-27 14:47:42,284 [myid:] - INFO  [main:QuorumPeerConfig@391] - secureClientPort is not set
2021-10-27 14:47:42,285 [myid:] - INFO  [main:ZooKeeperServerMain@117] - Starting server
2021-10-27 14:47:42,286 [myid:] - INFO  [main:FileTxnSnapLog@115] - zookeeper.snapshot.trust.empty : false
2021-10-27 14:47:42,295 [myid:] - INFO  [main:Environment@109] - Server environment:zookeeper.version=3.5.8-f439ca583e70862c3068a1f2a7d4d068eec33315, built on 05/04/2020 15:07 GMT
2021-10-27 14:47:42,295 [myid:] - INFO  [main:Environment@109] - Server environment:host.name=localhost
2021-10-27 14:47:42,295 [myid:] - INFO  [main:Environment@109] - Server environment:java.version=1.8.0_171
2021-10-27 14:47:42,296 [myid:] - INFO  [main:Environment@109] - Server environment:java.vendor=Oracle Corporation
2021-10-27 14:47:42,296 [myid:] - INFO  [main:Environment@109] - Server environment:java.home=/opt/FineTube/jre
2021-10-27 14:47:42,296 [myid:] - INFO  [main:Environment@109] - Server environment:java.class.path=/usr/local/apache-zookeeper-3.5.8-bin/bin/../zookeeper-server/target/classes:/usr/local/apache-zookeeper-3.5.8-bin/bin/../build/classes:/usr/local/apache-zookeeper-3.5.8-bin/bin/../zookeeper-server/target/lib/*.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../build/lib/*.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/zookeeper-jute-3.5.8.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/zookeeper-3.5.8.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/slf4j-log4j12-1.7.25.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/slf4j-api-1.7.25.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/netty-transport-native-unix-common-4.1.48.Final.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/netty-transport-native-epoll-4.1.48.Final.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/netty-transport-4.1.48.Final.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/netty-resolver-4.1.48.Final.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/netty-handler-4.1.48.Final.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/netty-common-4.1.48.Final.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/netty-codec-4.1.48.Final.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/netty-buffer-4.1.48.Final.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/log4j-1.2.17.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/json-simple-1.1.1.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jline-2.11.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jetty-util-9.4.24.v20191120.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jetty-servlet-9.4.24.v20191120.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jetty-server-9.4.24.v20191120.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jetty-security-9.4.24.v20191120.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jetty-io-9.4.24.v20191120.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jetty-http-9.4.24.v20191120.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/javax.servlet-api-3.1.0.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jackson-databind-2.10.3.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jackson-core-2.10.3.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jackson-annotations-2.10.3.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/commons-cli-1.2.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/audience-annotations-0.5.0.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../zookeeper-*.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../zookeeper-server/src/main/resources/lib/*.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../conf:/usr/local/apache-zookeeper-3.5.8-bin/bin/../zookeeper-server/target/classes:/usr/local/apache-zookeeper-3.5.8-bin/bin/../build/classes:/usr/local/apache-zookeeper-3.5.8-bin/bin/../zookeeper-server/target/lib/*.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../build/lib/*.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/zookeeper-jute-3.5.8.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/zookeeper-3.5.8.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/slf4j-log4j12-1.7.25.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/slf4j-api-1.7.25.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/netty-transport-native-unix-common-4.1.48.Final.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/netty-transport-native-epoll-4.1.48.Final.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/netty-transport-4.1.48.Final.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/netty-resolver-4.1.48.Final.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/netty-handler-4.1.48.Final.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/netty-common-4.1.48.Final.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/netty-codec-4.1.48.Final.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/netty-buffer-4.1.48.Final.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/log4j-1.2.17.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/json-simple-1.1.1.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jline-2.11.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jetty-util-9.4.24.v20191120.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jetty-servlet-9.4.24.v20191120.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jetty-server-9.4.24.v20191120.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jetty-security-9.4.24.v20191120.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jetty-io-9.4.24.v20191120.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jetty-http-9.4.24.v20191120.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/javax.servlet-api-3.1.0.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jackson-databind-2.10.3.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jackson-core-2.10.3.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jackson-annotations-2.10.3.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/commons-cli-1.2.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/audience-annotations-0.5.0.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../zookeeper-*.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../zookeeper-server/src/main/resources/lib/*.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../conf:.:/usr/local/java/jdk1.8.0_191/lib/dt.jar:/usr/local/java/jdk1.8.0_191/lib/tools.jar
2021-10-27 14:47:42,296 [myid:] - INFO  [main:Environment@109] - Server environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2021-10-27 14:47:42,296 [myid:] - INFO  [main:Environment@109] - Server environment:java.io.tmpdir=/tmp
2021-10-27 14:47:42,296 [myid:] - INFO  [main:Environment@109] - Server environment:java.compiler=<NA>
2021-10-27 14:47:42,296 [myid:] - INFO  [main:Environment@109] - Server environment:os.name=Linux
2021-10-27 14:47:42,296 [myid:] - INFO  [main:Environment@109] - Server environment:os.arch=amd64
2021-10-27 14:47:42,296 [myid:] - INFO  [main:Environment@109] - Server environment:os.version=3.10.0-957.el7.x86_64
2021-10-27 14:47:42,296 [myid:] - INFO  [main:Environment@109] - Server environment:user.name=root
2021-10-27 14:47:42,297 [myid:] - INFO  [main:Environment@109] - Server environment:user.home=/root
2021-10-27 14:47:42,297 [myid:] - INFO  [main:Environment@109] - Server environment:user.dir=/usr/local/apache-zookeeper-3.5.8-bin/bin
2021-10-27 14:47:42,297 [myid:] - INFO  [main:Environment@109] - Server environment:os.memory.free=466MB
2021-10-27 14:47:42,297 [myid:] - INFO  [main:Environment@109] - Server environment:os.memory.max=889MB
2021-10-27 14:47:42,297 [myid:] - INFO  [main:Environment@109] - Server environment:os.memory.total=481MB
2021-10-27 14:47:42,298 [myid:] - INFO  [main:ZooKeeperServer@938] - minSessionTimeout set to 4000
2021-10-27 14:47:42,298 [myid:] - INFO  [main:ZooKeeperServer@947] - maxSessionTimeout set to 40000
2021-10-27 14:47:42,298 [myid:] - INFO  [main:ZooKeeperServer@166] - Created server with tickTime 2000 minSessionTimeout 4000 maxSessionTimeout 40000 datadir /tmp/zookeeper/version-2 snapdir /tmp/zookeeper/version-2
2021-10-27 14:47:42,314 [myid:] - INFO  [main:Log@169] - Logging initialized @351ms to org.eclipse.jetty.util.log.Slf4jLog
2021-10-27 14:47:42,391 [myid:] - WARN  [main:ContextHandler@1520] - o.e.j.s.ServletContextHandler@527740a2{/,null,UNAVAILABLE} contextPath ends with /*
2021-10-27 14:47:42,391 [myid:] - WARN  [main:ContextHandler@1531] - Empty contextPath
2021-10-27 14:47:42,403 [myid:] - INFO  [main:Server@359] - jetty-9.4.24.v20191120; built: 2019-11-20T21:37:49.771Z; git: 363d5f2df3a8a28de40604320230664b9c793c16; jvm 1.8.0_171-b11
2021-10-27 14:47:42,432 [myid:] - INFO  [main:DefaultSessionIdManager@333] - DefaultSessionIdManager workerName=node0
2021-10-27 14:47:42,432 [myid:] - INFO  [main:DefaultSessionIdManager@338] - No SessionScavenger set, using defaults
2021-10-27 14:47:42,433 [myid:] - INFO  [main:HouseKeeper@140] - node0 Scavenging every 660000ms
2021-10-27 14:47:42,441 [myid:] - INFO  [main:ContextHandler@825] - Started o.e.j.s.ServletContextHandler@527740a2{/,null,AVAILABLE}
2021-10-27 14:47:42,452 [myid:] - INFO  [main:AbstractConnector@330] - Started ServerConnector@4c70fda8{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
2021-10-27 14:47:42,452 [myid:] - INFO  [main:Server@399] - Started @490ms
2021-10-27 14:47:42,452 [myid:] - INFO  [main:JettyAdminServer@112] - Started AdminServer on address 0.0.0.0, port 8080 and command URL /commands
2021-10-27 14:47:42,456 [myid:] - INFO  [main:ServerCnxnFactory@135] - Using org.apache.zookeeper.server.NIOServerCnxnFactory as server connection factory
2021-10-27 14:47:42,457 [myid:] - INFO  [main:NIOServerCnxnFactory@673] - Configuring NIO connection handler with 10s sessionless connection timeout, 2 selector thread(s), 16 worker threads, and 64 kB direct buffers.
2021-10-27 14:47:42,458 [myid:] - INFO  [main:NIOServerCnxnFactory@686] - binding to port 0.0.0.0/0.0.0.0:2181
2021-10-27 14:47:42,468 [myid:] - INFO  [main:ZKDatabase@117] - zookeeper.snapshotSizeFactor = 0.33
2021-10-27 14:47:42,471 [myid:] - INFO  [main:FileTxnSnapLog@404] - Snapshotting: 0x0 to /tmp/zookeeper/version-2/snapshot.0
2021-10-27 14:47:42,473 [myid:] - INFO  [main:FileTxnSnapLog@404] - Snapshotting: 0x0 to /tmp/zookeeper/version-2/snapshot.0
2021-10-27 14:47:42,484 [myid:] - INFO  [main:ContainerManager@64] - Using checkIntervalMs=60000 maxPerMinute=10000
2021-10-27 14:54:36,925 [myid:] - INFO  [SyncThread:0:FileTxnLog@218] - Creating new log file: log.1
2021-10-27 14:56:18,586 [myid:] - INFO  [SessionTracker:ZooKeeperServer@398] - Expiring session 0x101408d56b10000, timeout of 30000ms exceeded

  没啥报错

# sh ./zkCli.sh
Connecting to localhost:2181
2021-10-27 14:54:36,820 [myid:] - INFO  [main:Environment@109] - Client environment:zookeeper.version=3.5.8-f439ca583e70862c3068a1f2a7d4d068eec33315, built on 05/04/2020 15:07 GMT
2021-10-27 14:54:36,823 [myid:] - INFO  [main:Environment@109] - Client environment:host.name=localhost
2021-10-27 14:54:36,823 [myid:] - INFO  [main:Environment@109] - Client environment:java.version=1.8.0_171
2021-10-27 14:54:36,825 [myid:] - INFO  [main:Environment@109] - Client environment:java.vendor=Oracle Corporation
2021-10-27 14:54:36,825 [myid:] - INFO  [main:Environment@109] - Client environment:java.home=/opt/FineTube/jre
2021-10-27 14:54:36,825 [myid:] - INFO  [main:Environment@109] - Client environment:java.class.path=/usr/local/apache-zookeeper-3.5.8-bin/bin/../zookeeper-server/target/classes:/usr/local/apache-zookeeper-3.5.8-bin/bin/../build/classes:/usr/local/apache-zookeeper-3.5.8-bin/bin/../zookeeper-server/target/lib/*.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../build/lib/*.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/zookeeper-jute-3.5.8.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/zookeeper-3.5.8.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/slf4j-log4j12-1.7.25.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/slf4j-api-1.7.25.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/netty-transport-native-unix-common-4.1.48.Final.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/netty-transport-native-epoll-4.1.48.Final.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/netty-transport-4.1.48.Final.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/netty-resolver-4.1.48.Final.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/netty-handler-4.1.48.Final.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/netty-common-4.1.48.Final.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/netty-codec-4.1.48.Final.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/netty-buffer-4.1.48.Final.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/log4j-1.2.17.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/json-simple-1.1.1.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jline-2.11.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jetty-util-9.4.24.v20191120.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jetty-servlet-9.4.24.v20191120.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jetty-server-9.4.24.v20191120.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jetty-security-9.4.24.v20191120.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jetty-io-9.4.24.v20191120.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jetty-http-9.4.24.v20191120.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/javax.servlet-api-3.1.0.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jackson-databind-2.10.3.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jackson-core-2.10.3.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/jackson-annotations-2.10.3.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/commons-cli-1.2.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../lib/audience-annotations-0.5.0.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../zookeeper-*.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../zookeeper-server/src/main/resources/lib/*.jar:/usr/local/apache-zookeeper-3.5.8-bin/bin/../conf:.:/usr/local/java/jdk1.8.0_191/lib/dt.jar:/usr/local/java/jdk1.8.0_191/lib/tools.jar
2021-10-27 14:54:36,825 [myid:] - INFO  [main:Environment@109] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2021-10-27 14:54:36,825 [myid:] - INFO  [main:Environment@109] - Client environment:java.io.tmpdir=/tmp
2021-10-27 14:54:36,825 [myid:] - INFO  [main:Environment@109] - Client environment:java.compiler=<NA>
2021-10-27 14:54:36,825 [myid:] - INFO  [main:Environment@109] - Client environment:os.name=Linux
2021-10-27 14:54:36,825 [myid:] - INFO  [main:Environment@109] - Client environment:os.arch=amd64
2021-10-27 14:54:36,825 [myid:] - INFO  [main:Environment@109] - Client environment:os.version=3.10.0-957.el7.x86_64
2021-10-27 14:54:36,825 [myid:] - INFO  [main:Environment@109] - Client environment:user.name=root
2021-10-27 14:54:36,825 [myid:] - INFO  [main:Environment@109] - Client environment:user.home=/root
2021-10-27 14:54:36,825 [myid:] - INFO  [main:Environment@109] - Client environment:user.dir=/usr/local/apache-zookeeper-3.5.8-bin/bin
2021-10-27 14:54:36,825 [myid:] - INFO  [main:Environment@109] - Client environment:os.memory.free=239MB
2021-10-27 14:54:36,827 [myid:] - INFO  [main:Environment@109] - Client environment:os.memory.max=245MB
2021-10-27 14:54:36,827 [myid:] - INFO  [main:Environment@109] - Client environment:os.memory.total=245MB
2021-10-27 14:54:36,829 [myid:] - INFO  [main:ZooKeeper@868] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@6996db8
2021-10-27 14:54:36,834 [myid:] - INFO  [main:X509Util@79] - Setting -D jdk.tls.rejectClientInitiatedRenegotiation=true to disable client-initiated TLS renegotiation
2021-10-27 14:54:36,839 [myid:] - INFO  [main:ClientCnxnSocket@237] - jute.maxbuffer value is 4194304 Bytes
2021-10-27 14:54:36,850 [myid:] - INFO  [main:ClientCnxn@1653] - zookeeper.request.timeout value is 0. feature enabled=
Welcome to ZooKeeper!

  重新查看

# ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/apache-zookeeper-3.5.8-bin/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost.
Mode: standalone

  jps看下

20419 Jps
14904 StarterKt
19692 ZooKeeperMain
3278 QuorumPeerMain

  重新关闭

ZooKeeper JMX enabled by default
Using config: /usr/local/apache-zookeeper-3.5.8-bin/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED

  成功关闭,OK!

3. 后记

  难道最开始就没启动成功??以前是怎么运行的??
  后来仔细问了才知道,之前启动的是kafka里面的zookeeper,是在/usr/local/kafka目录里,用的是nohup bin/zookeeper-server-start.sh config/zookeeper.properties > zk.log 2>&1 &启动,而我是在/usr/local/zookeeper目录里,用./zkServer.sh start启动,两个应该启动的不是同一个服务,也就不能用对方的命令来关闭。
  所以只需要到kafka的目录里,使用./zookeeper-server-stop.sh关闭就行了

posted @ 2021-10-27 15:33  沧浪浊兮  阅读(4199)  评论(1编辑  收藏  举报