11# zookeepercli
22
3- [ ![ downloads] ( https://img.shields.io/github/downloads/outbrain/zookeepercli/total.svg )] ( https://github.com/outbrain/zookeepercli/releases )
3+ [ ![ downloads] ( https://img.shields.io/github/downloads/outbrain/zookeepercli/total.svg )] ( https://github.com/outbrain/zookeepercli/releases )
44
55Simple, lightweight, dependable CLI for ZooKeeper
66
@@ -9,109 +9,126 @@ Simple, lightweight, dependable CLI for ZooKeeper
99 * Basic CRUD-like operations: ` create ` , ` set ` , ` delete ` (aka ` rm ` ), ` exists ` , ` get ` , ` ls ` (aka ` children ` ).
1010 * Extended operations: ` lsr ` (ls recursive), ` creater ` (create recursively), ` deleter ` (aka ` rmr ` , delete recursively)
1111 * Well formatted and controlled output: supporting either ` txt ` or ` json ` format
12- * Single, no-dependencies binary file, based on a native Go ZooKeeper library
12+ * Single, no-dependencies binary file, based on a native Go ZooKeeper library
1313 by [ github.com/samuel/go-zookeeper] ( http://github.com/samuel/go-zookeeper ) ([ LICENSE] ( https://github.com/outbrain/zookeepercli/blob/master/go-zookeeper-LICENSE ) )
1414
15- ### Download & Install
15+ ### Build:
16+ Clone the repository:
17+ ```
18+ git clone --depth 1 https://github.com/openark/zookeepercli.git && zookeepercli
19+ ```
1620
17- There are [ pre built binaries] ( https://github.com/outbrain/zookeepercli/releases ) for download.
18- You can find ` RPM ` and ` deb ` packages, as well as pre-compiled, dependency free ` zookeepercli ` executable binary.
19- In fact, the only file installed by the pre-built ` RPM ` and ` deb ` packages is said executable binary file.
21+ Build :
22+ ```
23+ make build # build binary with local goland
24+ make package # previous + build deb, rpm, apk, tar, zip packages
25+ make all # all previous steps
2026
21- Otherwise the source code is freely available; you will need ` git ` installed as well as ` go ` , and you're on your own.
27+ make build_in_docker # build binary with using docker container (golang-alpine)
28+ make package_in_docker # previous + build deb, rpm, apk, tar, zip packages with using docker container
29+ make build_docker_image # build docker image with zookeepercli
30+ make all_in_docker # all previous steps
2231
23-
24- ### Usage:
32+ make clean # clean all build artifacts
33+ ```
34+
35+ For build packages locally you need requires fpm: https://github.com/jordansissel/fpm .
36+
37+ You can find the binary in the ` bin ` directory. \
38+ Also you can find ` deb ` , ` rpm ` , ` apk ` , ` tar ` and ` zip ` packages in pkgs_out.
2539
40+ ### Usage:
41+ ```
2642 $ zookeepercli --help
2743 Usage of zookeepercli:
28- -acls="31": optional, csv list [1|,2|,4|,8|,16|,31]
29- -auth_pwd="": optional, digest scheme, pwd
30- -auth_usr="": optional, digest scheme, user
31- -c="": command (exists|get|ls|lsr|create|creater|set|delete|rm|deleter|rmr|getacl|setacl)
32- -debug=false: debug mode (very verbose)
33- -force=false: force operation
34- -format="txt": output format (txt|json)
35- -servers="": srv1[:port1][,srv2[:port2]...]
36- -stack=false: add stack trace upon error
44+ -acls="31": optional, csv list [1|,2|,4|,8|,16|,31]
45+ -auth_pwd="": optional, digest scheme, pwd
46+ -auth_usr="": optional, digest scheme, user
47+ -c="": command (exists|get|ls|lsr|create|creater|set|delete|rm|deleter|rmr|getacl|setacl)
48+ -debug=false: debug mode (very verbose)
49+ -force=false: force operation
50+ -format="txt": output format (txt|json)
51+ -servers="": srv1[:port1][,srv2[:port2]...]
52+ -stack=false: add stack trace upon error
3753 -verbose=false: verbose
38-
54+ -version: print version and exit
55+ ```
3956
4057### Examples:
41-
42-
58+
59+
4360 $ zookeepercli --servers srv-1,srv-2,srv-3 -c create /demo_only some_value
44-
61+
4562 # Default port is 2181. The above is equivalent to:
4663 $ zookeepercli --servers srv-1:2181,srv-2:2181,srv-3:2181 -c create /demo_only some_value
47-
64+
4865 $ zookeepercli --servers srv-1,srv-2,srv-3 --format=txt -c get /demo_only
4966 some_value
50-
67+
5168 # Same as above, JSON format output:
5269 $ zookeepercli --servers srv-1,srv-2,srv-3 --format=json -c get /demo_only
5370 "some_value"
54-
55- # exists exits with exit code 0 when path exists, 1 when path does not exist
71+
72+ # exists exits with exit code 0 when path exists, 1 when path does not exist
5673 $ zookeepercli --servers srv-1,srv-2,srv-3 -c exists /demo_only
5774 true
58-
75+
5976 $ zookeepercli --servers srv-1,srv-2,srv-3 -c set /demo_only another_value
60-
77+
6178 $ zookeepercli --servers srv-1,srv-2,srv-3 --format=json -c get /demo_only
6279 "another_value"
63-
80+
6481 $ zookeepercli --servers srv-1,srv-2,srv-3 -c delete /demo_only
65-
82+
6683 $ zookeepercli --servers srv-1,srv-2,srv-3 -c get /demo_only
6784 2014-09-15 04:07:16 FATAL zk: node does not exist
68-
85+
6986 $ zookeepercli --servers srv-1,srv-2,srv-3 -c create /demo_only "path placeholder"
7087 $ zookeepercli --servers srv-1,srv-2,srv-3 -c create /demo_only/key1 "value1"
7188 $ zookeepercli --servers srv-1,srv-2,srv-3 -c create /demo_only/key2 "value2"
7289 $ zookeepercli --servers srv-1,srv-2,srv-3 -c create /demo_only/key3 "value3"
73-
90+
7491 $ zookeepercli --servers srv-1,srv-2,srv-3 -c ls /demo_only
7592 key3
7693 key2
7794 key1
78-
95+
7996 # Same as above, JSON format output:
8097 $ zookeepercli --servers srv-1,srv-2,srv-3 --format=json -c ls /demo_only
8198 ["key3","key2","key1"]
82-
99+
83100 $ zookeepercli --servers srv-1,srv-2,srv-3 -c delete /demo_only
84101 2014-09-15 08:26:31 FATAL zk: node has children
85-
102+
86103 $ zookeepercli --servers srv-1,srv-2,srv-3 -c delete /demo_only/key1
87104 $ zookeepercli --servers srv-1,srv-2,srv-3 -c delete /demo_only/key2
88105 $ zookeepercli --servers srv-1,srv-2,srv-3 -c delete /demo_only/key3
89106 $ zookeepercli --servers srv-1,srv-2,srv-3 -c delete /demo_only
90107
91108 # /demo_only path now does not exist.
92-
109+
93110 # Create recursively a path:
94111 $ zookeepercli --servers=srv-1,srv-2,srv-3 -c creater "/demo_only/child/key1" "val1"
95112 $ zookeepercli --servers=srv-1,srv-2,srv-3 -c creater "/demo_only/child/key2" "val2"
96-
113+
97114 # "-c creater" is same as "-c create --force"
98115
99116 $ zookeepercli --servers=srv-1,srv-2,srv-3 -c get "/demo_only/child/key1"
100117 val1
101118
102119 # This path was auto generated due to recursive create:
103- $ zookeepercli --servers=srv-1,srv-2,srv-3 -c get "/demo_only"
120+ $ zookeepercli --servers=srv-1,srv-2,srv-3 -c get "/demo_only"
104121 zookeepercli auto-generated
105-
122+
106123 # ls recursively a path and all sub children:
107- $ zookeepercli --servers=srv-1,srv-2,srv-3 -c lsr "/demo_only"
124+ $ zookeepercli --servers=srv-1,srv-2,srv-3 -c lsr "/demo_only"
108125 child
109126 child/key1
110127 child/key2
111128
112129 # set value with read and write acl using digest authentication
113130 $ zookeepercli --servers 192.168.59.103 --auth_usr "someuser" --auth_pwd "pass" --acls 1,2 -c create /secret4 value4
114-
131+
115132 # get value using digest authentication
116133 $ zookeepercli --servers 192.168.59.103 --auth_usr "someuser" --auth_pwd "pass" -c get /secret4
117134
@@ -132,17 +149,17 @@ Otherwise the source code is freely available; you will need `git` installed as
132149 # set an acl with world and digest authentication creating the node if it doesn't exist
133150 $ zookeepercli --servers srv-1,srv-2,srv-3 -force -c setacl /demo_acl_create "world:anyone:rw,digest:someuser:hashedpw:crdwa"
134151
135- The tool was built in order to allow with shell scripting seamless integration with ZooKeeper.
136- There is another, official command line tool for ZooKeeper that the author found inadequate
137- in terms of output format and output control, as well as large footprint.
152+ The tool was built in order to allow with shell scripting seamless integration with ZooKeeper.
153+ There is another, official command line tool for ZooKeeper that the author found inadequate
154+ in terms of output format and output control, as well as large footprint.
138155** zookeepercli** overcomes those limitations and provides with quick, well formatted output as well as
139- enhanced functionality.
156+ enhanced functionality.
140157
141158### Docker
142159
143160You can also build and run ** zookeepercli** in a Docker container. To build the image:
144161
145- $ docker build -t zookeepercli .
162+ $ make build_docker_image
146163
147164Now, you can run ** zookeepercli** from a container. Examples:
148165
@@ -158,9 +175,4 @@ Now, you can run **zookeepercli** from a container. Examples:
158175Release under the [ Apache 2.0 license] ( https://github.com/outbrain/zookeepercli/blob/master/LICENSE )
159176
160177Authored by [ Shlomi Noach] ( https://github.com/shlomi-noach ) at [ Outbrain] ( https://github.com/outbrain )
161-
162-
163-
164-
165178
166-
0 commit comments