Linux

如何在 Ubuntu 上停止 ZooKeeper?

  • January 20, 2020

我已經按照此處的建議在 Ubuntu 14.04 (Trusty Tahr) 上安裝了 zookeeperd :

不幸的是,這個過程在某種程度上是不可停止的。我什至嘗試殺死 -9

user@node1:/opt/zookeeper-3.4.6$ ps -ef | grep zookeeper
zookeep+  4008     1  8 01:07 ?        00:00:00 /usr/bin/java -cp /etc/zookeeper/conf:/usr/share/java/jline.jar:/usr/share/java/log4j-1.2.jar:/usr/share/java/xercesImpl.jar:/usr/share/java/xmlParserAPIs.jar:/usr/share/java/netty.jar:/usr/share/java/slf4j-api.jar:/usr/share/java/slf4j-log4j12.jar:/usr/share/java/zookeeper.jar -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false -Dzookeeper.log.dir=/var/log/zookeeper -Dzookeeper.root.logger=INFO,ROLLINGFILE org.apache.zookeeper.server.quorum.QuorumPeerMain /etc/zookeeper/conf/zoo.cfg

展示過程

user      4055  2823  0 01:07 pts/3    00:00:00 grep --color=auto zookeeper

殺了它

user@node1:/opt/zookeeper-3.4.6$ sudo kill -9 4008

查看:

user@node1:/opt/zookeeper-3.4.6$ ps -ef | grep zookeeper
zookeep+  4075     1 24 01:07 ?        00:00:00 /usr/bin/java -cp /etc/zookeeper/conf:/usr/share/java/jline.jar:/usr/share/java/log4j-1.2.jar:/usr/share/java/xercesImpl.jar:/usr/share/java/xmlParserAPIs.jar:/usr/share/java/netty.jar:/usr/share/java/slf4j-api.jar:/usr/share/java/slf4j-log4j12.jar:/usr/share/java/zookeeper.jar -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false -Dzookeeper.log.dir=/var/log/zookeeper -Dzookeeper.root.logger=INFO,ROLLINGFILE org.apache.zookeeper.server.quorum.QuorumPeerMain /etc/zookeeper/conf/zoo.cfg

嘗試腳本

user@node1:/opt/zookeeper-3.4.6$ sudo /etc/init.d/zookeeper stop
user@node1:/opt/zookeeper-3.4.6$ ps -ef | grep zookeeper
zookeep+  4075     1 29 01:07 ?        00:00:04 /usr/bin/java -cp /etc/zookeeper/conf:/usr/share/java/jline.jar:/usr/share/java/log4j-1.2.jar:/usr/share/java/xercesImpl.jar:/usr/share/java/xmlParserAPIs.jar:/usr/share/java/netty.jar:/usr/share/java/slf4j-api.jar:/usr/share/java/slf4j-log4j12.jar:/usr/share/java/zookeeper.jar -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false -Dzookeeper.log.dir=/var/log/zookeeper -Dzookeeper.root.logger=INFO,ROLLINGFILE org.apache.zookeeper.server.quorum.QuorumPeerMain /etc/zookeeper/conf/zoo.cfg

沒有什麼幫助。

我怎樣才能停止 ZooKeeper?

你可以試試:

sudo service zookeeper stop

停止該過程。如果它不起作用,您可以檢查此連結

Stop ZooKeeper. On the ZooKeeper host machine, execute the following command:

su - zookeeper -c "export ZOOCFGDIR=/etc/zookeeper/conf ; export ZOOCFG=zoo.cfg ;source /etc/zookeeper/conf/zookeeper-env.sh ; /usr/lib/zookeeper/bin/zkServer.sh stop" 

如果上述命令沒有停止 Zookeeper 並且 kill -9 也無法停止,那麼可能存在殭屍程序。如果是這種情況,您可以查看此問答如何停止此類過程。

引用自:https://serverfault.com/questions/715404