How can I stop ZooKeeper on Ubuntu?

Solution 1:

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.

Solution 2:

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

sudo bin/zkServer.sh stop