Run ZooKeeper Client Commands


How to run ZooKeeper Client Commands?



If you have a ZooKeeper Server running, you can follow these steps to run some ZooKeeper client commands:

1. On the client computer, download and install Apache ZooKeeper binary package.

2. Run the client script to connect to the ZooKeeper server. You see the client command prompt.

fyicenter$ bin/ -server

Connecting to
... Client environment:zookeeper.version=3.7.0-...
... Client
... Client environment:java.version=15
... Client environment:java.vendor=Oracle Corporation
... Client environment:java.home=/usr/bin/java
... Client environment:java.class.path=...
... Client environment:java.library.path=...
... Client
... Client environment:java.compiler=<NA>
... INFO  [main:ZooKeeper@637] - Initiating client connection, ...
... INFO  [main:X509Util@77] - Setting -D ...
... INFO  [main:ClientCnxnSocket@239] - jute.maxbuffer value is 1048575 Bytes
... INFO  [main:ClientCnxn@1726] - zookeeper.request.timeout value is 0. 

Welcome to ZooKeeper!

... INFO  [main-SendThread...] - Opening socket connection to server  
... INFO  [main-SendThread...] - SASL config status: Will not attempt 
  to authenticate using SASL (unknown error)
JLine support is enabled

... INFO  [main-SendThread...] - Socket connection established, ...
... INFO  [main-SendThread...] - Session establishment complete on server ...


WatchedEvent state:SyncConnected type:None path:null

[zk: 0] 

3. Try the "help" command.

[zk: 1] help

ZooKeeper -server host:port -client-configuration properties-file cmd args
  addWatch [-m mode] path # optional mode, default is PERSISTENT_RECURSIVE
  addauth scheme auth
  config [-c] [-w] [-s]
  connect host:port
  create [-s] [-e] [-c] [-t ttl] path [data] [acl]
  delete [-v version] path
  deleteall path [-b batch size]
  delquota [-n|-b|-N|-B] path
  get [-s] [-w] path
  getAcl [-s] path
  getAllChildrenNumber path
  getEphemerals path
  listquota path
  ls [-s] [-w] [-R] path
  printwatches on|off
  reconfig [-s] [-v version] [[-file path] | [-members serverID=...]
  redo cmdno
  removewatches path [-c|-d|-a] [-l]
  set [-s] [-v version] path data
  setAcl [-s] [-v version] [-R] path acl
  setquota -n|-b|-N|-B val path
  stat [-w] path
  sync path

4. Try the "ls" command. There is one 1 node with 2 child nodes.

[zk: 4] ls /
[zk: 5] ls /zookeeper
[config, quota]
[zk: 6] ls /zookeeper/config 
[zk: 7] ls /zookeeper/quota 

5. Quit the connection.

[zk: 21] quit 


WatchedEvent state:Closed type:None path:null
INFO  [main:ZooKeeper@1232] - Session: 0x10005dd8df40000 closed
INFO  [main-EventThread:ClientCnxn...] - EventThread shut down for session: ...
ERROR [main:ServiceUtils@42] - Exiting JVM with code 0


FAQ for Apache ZooKeeper

Start Standalone ZooKeeper Server

Using Apache ZooKeeper

⇑⇑ FAQ for Apache ZooKeeper

2022-02-19, 909🔥, 0💬