I’m happy to announce the availability of zookeepercli: a lightweight, simple, fast and controlled command line client for ZooKeeper.
zookeepercli allows for:
- Basic CRUD-like operations:
create
,set
,delete
,exists
,get
,ls
(akachildren
). - Extended operations:
lsr
(ls recursive),creater
(create recursively) - Well formatted and controlled output: supporting either
txt
orjson
format - Single, no-dependencies binary file, based on a native Go ZooKeeper library by github.com/samuel/go-zookeeper (LICENSE)
I was dissatisfied with existing command line access to ZooKeeper. Uncontrolled and noisy output as well as large footprint were among the reasons. zookeepercli overcomes the above and provides with often required powers.
Usage samples:
$ zookeepercli --servers srv-1,srv-2,srv-3 -c create /demo_only "path placeholder" $ zookeepercli --servers srv-1,srv-2,srv-3 -c create /demo_only/key1 "value1" $ zookeepercli --servers srv-1,srv-2,srv-3 -c create /demo_only/key2 "value2" $ zookeepercli --servers srv-1,srv-2,srv-3 -c create /demo_only/key3 "value3" $ zookeepercli --servers srv-1,srv-2,srv-3 -c ls /demo_only key3 key2 key1 # Same as above, JSON format output: $ zookeepercli --servers srv-1,srv-2,srv-3 --format=json -c ls /demo_only ["key3","key2","key1"] $ zookeepercli --servers srv-1,srv-2,srv-3 -c delete /demo_only/key1 $ zookeepercli --servers srv-1,srv-2,srv-3 -c delete /demo_only/key2 $ zookeepercli --servers srv-1,srv-2,srv-3 -c delete /demo_only/key3 $ zookeepercli --servers srv-1,srv-2,srv-3 -c delete /demo_only # Create a path recursively (auto-generate parent directories if not exist): $ zookeepercli --servers=srv-1,srv-2,srv-3 -c creater "/demo_only/child/key1" "val1" $ zookeepercli --servers=srv-1,srv-2,srv-3 -c creater "/demo_only/child/key2" "val2" $ zookeepercli --servers=srv-1,srv-2,srv-3 -c get "/demo_only/child/key1" val1 # This path was auto generated due to recursive create: $ zookeepercli --servers=srv-1,srv-2,srv-3 -c get "/demo_only" zookeepercli auto-generated # ls recursively a path and all sub children: $ zookeepercli --servers=srv-1,srv-2,srv-3 -c lsr "/demo_only" child child/key1 child/key2
zookeepercli is released as open source by Outbrain under the Apache 2.0 license.
Quick links:
- Project page
- Pre-built binaries for download
- License
No intensive writes. This is not OLTP. I write at most once per 3-4 seconds, worst case, and I really don’t care about a few seconds latency (actually I don’t care about a minute latency, and for some data even for 30 minutes latency)
Ok, thanks for details Shlomi.
Thanks for this library. I am looking to update znode data using this library. I am getting error “FATAL zk: version conflict”. My Zookeeper version: 3.3.3. Please advice.
@Priya,
I’m going to have to relay you to the underlying library, https://godoc.org/github.com/samuel/go-zookeeper/zk, where I can find the ErrBadVersion constant declared.
Sorry I can’t help more than that. For what it’s worth, Im using ZooKeeper 3.3.5