Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I run ZooKeeper's zkCli.sh commands from Bash?

Is it possible to run a zkCli.sh command, like ls / or get /, from Bash directly without going inside the ZooKeeper shell?

I am using ZooKeeper version 3.4.6-1569965.

For example, something like this:

$ ./zkCli.sh get /

I am able to do this only after connecting to the ZooKeeper shell and then running get / from there, like below:

$ ./zkCli.sh
Connecting to localhost:2181
Welcome to ZooKeeper!

WATCHER::

WatchedEvent state:AuthFailed type:None path:null
JLine support is enabled

WATCHER::

WatchedEvent state:SyncConnected type:None path:null
[zk: localhost:2181(CONNECTED) 0] get /
[]
like image 860
rkrishnan Avatar asked Jan 13 '16 01:01

rkrishnan


1 Answers

zkCli.sh has supported process commands since version 3.4.7.

See ZK Shell/Cli not processing commands

Such as:

./zkCli.sh -server xxxxx:2181 get /test

zkcli, a Go command-line interface for ZooKeeper is also a simple solution.

zkcli --servers srv-1,srv-2,srv-3 create /demo_only some_value
like image 75
jolestar Avatar answered Oct 10 '22 19:10

jolestar