How to check if ZooKeeper is running or up from command prompt?
To check if Zookeeper is accessible. One method is to simply telnet to the proper port and execute the stats command.
root@host:~# telnet localhost 2181Trying 127.0.0.1...Connected to myhost.Escape character is '^]'.statsZookeeper version: 3.4.3-cdh4.0.1--1, built on 06/28/2012 23:59 GMTClients:Latency min/avg/max: 0/0/677Received: 4684478Sent: 4687034Outstanding: 0Zxid: 0xb00187dd0Mode: leaderNode count: 127182Connection closed by foreign host.
One other way would be to use 4 letter commands to validate if zookeeper service is healthy or not
echo stat | nc <zookeeper ip> 2181echo mntr | nc <zookeeper ip> 2181echo isro | nc <zookeeper ip> 2181
More details on the documentation link belowhttps://zookeeper.apache.org/doc/r3.1.2/zookeeperAdmin.html#sc_zkCommands
Go to bin directory of Zookeeper and type
./zkServer.sh status
For More info go through below link:
http://www.ibm.com/developerworks/library/bd-zookeeper/
Hope this could help you.