我已经按照建议在 Ubuntu 14.04 (Trusty Tahr) 上安装了 zookeeperd这里:
不幸的是,这个过程不知何故无法停止。我甚至试过 kill -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?
答案1
您可以尝试:
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 也无法停止,则可能存在僵尸进程。您可以检查此问答如果确实如此,该如何停止此类过程?
答案2
从 zookeeper 根目录 ( cd ~/zookeeper-3.4.6
) 运行以下命令
sudo bin/zkServer.sh stop
答案3
bin/zookeeper-server-stop.sh
在 Mac 上不起作用。当尝试终止该进程时,即使使用 ,也会生成一个新进程SIGTERM
。
$ brew services stop zookeeper
答案4
就我个人而言,我设置了 $KAFKA_HOME 环境变量 - 让我的生活更轻松。如果您这样做,您可以按照以下方式为这些内容创建别名:
alias zstop='sudo $KAFKA_HOME/bin/zookeeper-server-stop.sh'
然后你就可以输入
zstop
或者,如果您安装到/opt/kafka
例如,您可以直接输入:
sudo /opt/kafka/bin/zookeeper-server-stop.sh
我还喜欢创建一个别名来启动 zookeeper,下面是我在文件底部添加的两行~/.bashrc
:
alias zstart='$KAFKA_HOME/bin/zookeeper-server-start.sh $KAFKA_HOME/config/zookeeper.properties'
alias zstop=''$KAFKA_HOME/bin/zookeeper-server-stop.sh'