Working with Zookeeper Command line

In this post we will look into Zookeeper CLI commands and how to use these to interact with Zookeeper. CLI generally comes handy for debugging purpose.

I am assuming that your Zookeeper server is already running on the local machine. To connect to Zookeeper we have to use . This will be installed along with the Zookeeper installation. You just have to locate this in your system using locate command.


Above command will provide the location of this file. Mine was located at /usr/share/zookeeper/bin/ . So to connect to Zookeeper from command line we just have to enter this command.

 sudo /usr/share/zookeeper/bin/

We will get following output.

 Connecting to localhost:2181
 Welcome to ZooKeeper!
 JLine support is enabled
 WatchedEvent state:SyncConnected type:None path:null
 [zk: localhost:2181(CONNECTED) 0]

This output confirms that we are connected to Zookeeper. Now we can perform following operations.

  • Create znodes
  • Get znode data
  • Watch znode for changes
  • Set data to znode
  • Create children of a znode
  • List children of a znode
  • Check Status
  • Remove / Delete a znode

Leave a Comment

Your email address will not be published. Required fields are marked *