1
1
# zookeepercli
2
2
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 )
4
4
5
5
Simple, lightweight, dependable CLI for ZooKeeper
6
6
@@ -9,109 +9,126 @@ Simple, lightweight, dependable CLI for ZooKeeper
9
9
* Basic CRUD-like operations: ` create ` , ` set ` , ` delete ` (aka ` rm ` ), ` exists ` , ` get ` , ` ls ` (aka ` children ` ).
10
10
* Extended operations: ` lsr ` (ls recursive), ` creater ` (create recursively), ` deleter ` (aka ` rmr ` , delete recursively)
11
11
* 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
13
13
by [ github.com/samuel/go-zookeeper] ( http://github.com/samuel/go-zookeeper ) ([ LICENSE] ( https://github.com/outbrain/zookeepercli/blob/master/go-zookeeper-LICENSE ) )
14
14
15
- ### Download & Install
15
+ ### Build:
16
+ Clone the repository:
17
+ ```
18
+ git clone --depth 1 https://github.com/openark/zookeepercli.git && zookeepercli
19
+ ```
16
20
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
20
26
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
22
31
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.
25
39
40
+ ### Usage:
41
+ ```
26
42
$ zookeepercli --help
27
43
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
37
53
-verbose=false: verbose
38
-
54
+ -version: print version and exit
55
+ ```
39
56
40
57
### Examples:
41
-
42
-
58
+
59
+
43
60
$ zookeepercli --servers srv-1,srv-2,srv-3 -c create /demo_only some_value
44
-
61
+
45
62
# Default port is 2181. The above is equivalent to:
46
63
$ zookeepercli --servers srv-1:2181,srv-2:2181,srv-3:2181 -c create /demo_only some_value
47
-
64
+
48
65
$ zookeepercli --servers srv-1,srv-2,srv-3 --format=txt -c get /demo_only
49
66
some_value
50
-
67
+
51
68
# Same as above, JSON format output:
52
69
$ zookeepercli --servers srv-1,srv-2,srv-3 --format=json -c get /demo_only
53
70
"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
56
73
$ zookeepercli --servers srv-1,srv-2,srv-3 -c exists /demo_only
57
74
true
58
-
75
+
59
76
$ zookeepercli --servers srv-1,srv-2,srv-3 -c set /demo_only another_value
60
-
77
+
61
78
$ zookeepercli --servers srv-1,srv-2,srv-3 --format=json -c get /demo_only
62
79
"another_value"
63
-
80
+
64
81
$ zookeepercli --servers srv-1,srv-2,srv-3 -c delete /demo_only
65
-
82
+
66
83
$ zookeepercli --servers srv-1,srv-2,srv-3 -c get /demo_only
67
84
2014-09-15 04:07:16 FATAL zk: node does not exist
68
-
85
+
69
86
$ zookeepercli --servers srv-1,srv-2,srv-3 -c create /demo_only "path placeholder"
70
87
$ zookeepercli --servers srv-1,srv-2,srv-3 -c create /demo_only/key1 "value1"
71
88
$ zookeepercli --servers srv-1,srv-2,srv-3 -c create /demo_only/key2 "value2"
72
89
$ zookeepercli --servers srv-1,srv-2,srv-3 -c create /demo_only/key3 "value3"
73
-
90
+
74
91
$ zookeepercli --servers srv-1,srv-2,srv-3 -c ls /demo_only
75
92
key3
76
93
key2
77
94
key1
78
-
95
+
79
96
# Same as above, JSON format output:
80
97
$ zookeepercli --servers srv-1,srv-2,srv-3 --format=json -c ls /demo_only
81
98
["key3","key2","key1"]
82
-
99
+
83
100
$ zookeepercli --servers srv-1,srv-2,srv-3 -c delete /demo_only
84
101
2014-09-15 08:26:31 FATAL zk: node has children
85
-
102
+
86
103
$ zookeepercli --servers srv-1,srv-2,srv-3 -c delete /demo_only/key1
87
104
$ zookeepercli --servers srv-1,srv-2,srv-3 -c delete /demo_only/key2
88
105
$ zookeepercli --servers srv-1,srv-2,srv-3 -c delete /demo_only/key3
89
106
$ zookeepercli --servers srv-1,srv-2,srv-3 -c delete /demo_only
90
107
91
108
# /demo_only path now does not exist.
92
-
109
+
93
110
# Create recursively a path:
94
111
$ zookeepercli --servers=srv-1,srv-2,srv-3 -c creater "/demo_only/child/key1" "val1"
95
112
$ zookeepercli --servers=srv-1,srv-2,srv-3 -c creater "/demo_only/child/key2" "val2"
96
-
113
+
97
114
# "-c creater" is same as "-c create --force"
98
115
99
116
$ zookeepercli --servers=srv-1,srv-2,srv-3 -c get "/demo_only/child/key1"
100
117
val1
101
118
102
119
# 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"
104
121
zookeepercli auto-generated
105
-
122
+
106
123
# 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"
108
125
child
109
126
child/key1
110
127
child/key2
111
128
112
129
# set value with read and write acl using digest authentication
113
130
$ zookeepercli --servers 192.168.59.103 --auth_usr "someuser" --auth_pwd "pass" --acls 1,2 -c create /secret4 value4
114
-
131
+
115
132
# get value using digest authentication
116
133
$ zookeepercli --servers 192.168.59.103 --auth_usr "someuser" --auth_pwd "pass" -c get /secret4
117
134
@@ -132,17 +149,17 @@ Otherwise the source code is freely available; you will need `git` installed as
132
149
# set an acl with world and digest authentication creating the node if it doesn't exist
133
150
$ zookeepercli --servers srv-1,srv-2,srv-3 -force -c setacl /demo_acl_create "world:anyone:rw,digest:someuser:hashedpw:crdwa"
134
151
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.
138
155
** zookeepercli** overcomes those limitations and provides with quick, well formatted output as well as
139
- enhanced functionality.
156
+ enhanced functionality.
140
157
141
158
### Docker
142
159
143
160
You can also build and run ** zookeepercli** in a Docker container. To build the image:
144
161
145
- $ docker build -t zookeepercli .
162
+ $ make build_docker_image
146
163
147
164
Now, you can run ** zookeepercli** from a container. Examples:
148
165
@@ -158,9 +175,4 @@ Now, you can run **zookeepercli** from a container. Examples:
158
175
Release under the [ Apache 2.0 license] ( https://github.com/outbrain/zookeepercli/blob/master/LICENSE )
159
176
160
177
Authored by [ Shlomi Noach] ( https://github.com/shlomi-noach ) at [ Outbrain] ( https://github.com/outbrain )
161
-
162
-
163
-
164
-
165
178
166
-
0 commit comments