6

I have installed zookeeperd on Ubuntu 14.04 (Trusty Tahr) as suggested here:

Unfortunately this process is somehow not stoppable. I tried even 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

show process

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

kill it

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

Check:

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

Try script

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

Nothing helps.

How could I stop ZooKeeper?

Peter Mortensen
  • 2,319
  • 5
  • 23
  • 24
merlin
  • 2,033
  • 11
  • 37
  • 72

4 Answers4

13

You could try:

sudo service zookeeper stop

to stop the process. If it does not work you could check this link:

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" 

If above commands do not stop the Zookeeper and the kill -9 is also not able to stop then there is perhaps a zombie process. You could check this Q&A how to stop such processes if that is the case.

030
  • 5,731
  • 12
  • 61
  • 107
3

From the zookeper root directory (cd ~/zookeeper-3.4.6) run the following command

sudo bin/zkServer.sh stop
Chenna V
  • 161
  • 1
  • 5
0

bin/zookeeper-server-stop.sh did not work on Mac. And a new process was getting spawned when trying to kill the process, even with SIGTERM.

Instead, stop ZooKeeper with Homebrew:

$ brew services stop zookeeper

Peter Mortensen
  • 2,319
  • 5
  • 23
  • 24
-1

Personally, I set an environment variable of $KAFKA_HOME - makes my life easier. If you do, you can create an alias for these sorts of things in the following manner:

alias zstop='sudo $KAFKA_HOME/bin/zookeeper-server-stop.sh'

And then you can just type

zstop

Or, if you installed into /opt/kafka for example, you could just type:

sudo /opt/kafka/bin/zookeeper-server-stop.sh

I also like to create an alias to start zookeeper, here are two lines I added to the bottom of my ~/.bashrc file:

alias zstart='$KAFKA_HOME/bin/zookeeper-server-start.sh $KAFKA_HOME/config/zookeeper.properties'
alias zstop=''$KAFKA_HOME/bin/zookeeper-server-stop.sh'
Peter Mortensen
  • 2,319
  • 5
  • 23
  • 24
Maashu
  • 101
  • 1