4

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?

11

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.

  • 1
    "sudo service zookeeper stop" worked perfectly! Thank you. – merlin Aug 20 '15 at 5:43
3

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

sudo bin/zkServer.sh stop
-1

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

  • The question was: '... on Ubuntu'. So anything using brew will certainly not apply. – Patrick Mevzek Oct 12 '18 at 15:49
-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'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.