How to check if ZooKeeper is running or up from command prompt?

Suren Baskaran picture Suren Baskaran · Mar 17, 2015 · Viewed 152k times · Source

I exploring a few options to setup kafka and I knew that the Zookeeper has to be up and running to initiate a kafka.

I would like to know how can I find the below.

1) hostname and port for my zookeeper instance---I checked the zoo.cfg and I could only find the ClientPort not the hostname, will hostname be the hostname of my box??

2) To check if ZooKeeper is up and running---I tried to do a ps -ef | grep "zoo" I could not find anything. May be I am using a wrong key word to search??

Any help would be really appreciated?

Answer

Mehul picture Mehul · Feb 14, 2016

One other way would be to use 4 letter commands to validate if zookeeper service is healthy or not

echo stat | nc <zookeeper ip> 2181
echo mntr | nc <zookeeper ip> 2181
echo isro  | nc <zookeeper ip> 2181

More details on the documentation link below https://zookeeper.apache.org/doc/r3.1.2/zookeeperAdmin.html#sc_zkCommands