/
usage.py
310 lines (260 loc) · 12.3 KB
/
usage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
def commands_usage():
return """
server-list list all servers in a cluster
server-info show details on one server
server-add add one or more servers to the cluster
server-readd readd a server that was failed over
rebalance start a cluster rebalancing
rebalance-stop stop current cluster rebalancing
rebalance-status show status of current cluster rebalancing
failover failover one or more servers
cluster-init set the username,password and port of the cluster
cluster-edit modify cluster settings
node-init set node specific parameters
bucket-list list all buckets in a cluster
bucket-create add a new bucket to the cluster
bucket-edit modify an existing bucket
bucket-delete delete an existing bucket
bucket-flush flush all data from disk for a given bucket
bucket-compact compact database and index data
setting-compaction set auto compaction settings
setting-notification set notification settings
setting-alert set email alert settings
setting-autofailover set auto failover settings
setting-xdcr set xdcr related settings
xdcr-setup set up XDCR connection
xdcr-replicate xdcr operations
help show longer usage/help and examples
"""
def short_usage():
print "usage: couchbase-cli COMMAND CLUSTER [OPTIONS]"
print ""
print "CLUSTER is --cluster=HOST[:PORT] or -c HOST[:PORT]"
print ""
print "COMMANDs include" + commands_usage()
sys.exit(2)
def usage(error_msg=''):
if error_msg:
print "ERROR: %s" % error_msg
sys.exit(2)
print """couchbase-cli - command-line cluster administration tool
usage: couchbase-cli COMMAND CLUSTER [OPTIONS]
COMMAND:""" + commands_usage() + """
CLUSTER:
--cluster=HOST[:PORT] or -c HOST[:PORT]
OPTIONS:
-u USERNAME, --user=USERNAME admin username of the cluster
-p PASSWORD, --password=PASSWORD admin password of the cluster
-o KIND, --output=KIND KIND is json or standard
-d, --debug
server-add OPTIONS:
--server-add=HOST[:PORT] server to be added
--server-add-username=USERNAME admin username for the
server to be added
--server-add-password=PASSWORD admin password for the
server to be added
server-readd OPTIONS:
--server-add=HOST[:PORT] server to be added
--server-add-username=USERNAME admin username for the
server to be added
--server-add-password=PASSWORD admin password for the
server to be added
rebalance OPTIONS:
--server-add* see server-add OPTIONS
--server-remove=HOST[:PORT] the server to be removed
failover OPTIONS:
--server-failover=HOST[:PORT] server to failover
cluster-* OPTIONS:
--cluster-username=USER new admin username
--cluster-password=PASSWORD new admin password
--cluster-port=PORT new cluster REST/http port
--cluster-ramsize=RAMSIZEMB per node ram quota in MB
node-init OPTIONS:
--node-init-data-path=PATH per node path to store data
--node-init-index-path=PATH per node path to store index
bucket-* OPTIONS:
--bucket=BUCKETNAME bucket to act on
--bucket-type=TYPE memcached or couchbase
--bucket-port=PORT supports ASCII protocol and is auth-less
--bucket-password=PASSWORD standard port, exclusive with bucket-port
--bucket-ramsize=RAMSIZEMB ram quota in MB
--bucket-replica=COUNT replication count
--enable-flush=[0|1] enable/disable flush
--enable-index-replica=[0|1] enable/disable index replicas
--wait wait for bucket create to be complete before returning
--force force to execute command without asking for confirmation
--data-only compact datbase data only
--view-only compact view data only
setting-compacttion OPTIONS:
--compaction-db-percentage=PERCENTAGE at which point database compaction is triggered
--compaction-db-size=SIZE[MB] at which point database compaction is triggered
--compaction-view-percentage=PERCENTAGE at which point view compaction is triggered
--compaction-view-size=SIZE[MB] at which point view compaction is triggered
--compaction-period-from=HH:MM allow compaction time period from
--compaction-period-to=HH:MM allow compaction time period to
--enable-compaction-abort=[0|1] allow compaction abort when time expires
--enable-compaction-parallel=[0|1] allow parallel compaction for database and view
setting-notification OPTIONS:
--enable-notification=[0|1] allow notification
setting-alert OPTIONS:
--enable-email-alert=[0|1] allow email alert
--email-recipients=RECIPIENT email recipents, separate addresses with , or ;
--email-sender=SENDER sender email address
--email-user=USER email server username
--email-password=PWD email server password
--email-host=HOST email server host
--email-port=PORT email server port
--enable-email-encrypt=[0|1] email encrypt
--alert-auto-failover-node node was auto failover
--alert-auto-failover-max-reached maximum number of auto failover nodes was reached
--alert-auto-failover-node-down node wasn't auto failover as other nodes are down at the same time
--alert-auto-failover-cluster-small node wasn't auto fail over as cluster was too small
--alert-ip-changed node ip address has changed unexpectedly
--alert-disk-space disk space used for persistent storgage has reached at least 90% capacity
--alert-meta-overhead metadata overhead is more than 50%
--alert-meta-oom bucket memory on a node is entirely used for metadata
--alert-write-failed writing data to disk for a specific bucket has failed
setting-autofailover OPTIONS:
--enable-auto-failover=[0|1] allow auto failover
--auto-failover-timeout=TIMEOUT (>=30) specify timeout that expires to trigger auto failover
setting-xdcr OPTIONS:
--max-concurrent-reps=[32] maximum concurrent replications per bucket, 8 to 256.
--checkpoint-interval=[1800] intervals between checkpoints, 60 to 14400 seconds.
--worker-batch-size=[500] doc batch size, 500 to 10000.
--doc-batch-size=[2048]KB document batching size, 10 to 100000 KB
--failure-restart-interval=[30] interval for restarting failed xdcr, 1 to 300 seconds
--optimistic-replication-threshold=[256] document body size threshold (bytes) to trigger optimistic replication
xdcr-setup OPTIONS:
--create create a new xdcr configuration
--edit modify existed xdcr configuration
--delete delete existed xdcr configuration
--xdcr-cluster-name=CLUSTERNAME cluster name
--xdcr-hostname=HOSTNAME remote host name to connect to
--xdcr-username=USERNAME remote cluster admin username
--xdcr-password=PASSWORD remtoe cluster admin password
xdcr-replicate OPTIONS:
--create create and start a new replication
--delete stop and cancel a replication
--xdcr-from-bucket=BUCKET local bucket name to replicate from
--xdcr-clucter-name=CLUSTERNAME remote cluster to replicate to
--xdcr-to-bucket=BUCKETNAME remote bucket to replicate to
The default PORT number is 8091.
EXAMPLES:
Set data path for an unprovisioned cluster:
couchbse-cli node-init -c 192.168.0.1:8091 \\
--node-init-data-path=/tmp/data \\
--node-init-index-path=/tmp/index
List servers in a cluster:
couchbase-cli server-list -c 192.168.0.1:8091
Server information:
couchbase-cli server-info -c 192.168.0.1:8091
Add a node to a cluster, but do not rebalance:
couchbase-cli server-add -c 192.168.0.1:8091 \\
--server-add=192.168.0.2:8091 \\
--server-add-username=Administrator \\
--server-add-password=password
Add a node to a cluster and rebalance:
couchbase-cli rebalance -c 192.168.0.1:8091 \\
--server-add=192.168.0.2:8091 \\
--server-add-username=Administrator \\
--server-add-password=password
Remove a node from a cluster and rebalance:
couchbase-cli rebalance -c 192.168.0.1:8091 \\
--server-remove=192.168.0.2:8091
Remove and add nodes from/to a cluster and rebalance:
couchbase-cli rebalance -c 192.168.0.1:8091 \\
--server-remove=192.168.0.2 \\
--server-add=192.168.0.4 \\
--server-add-username=Administrator \\
--server-add-password=password
Stop the current rebalancing:
couchbase-cli rebalance-stop -c 192.168.0.1:8091
Set the username, password, port and ram quota:
couchbase-cli cluster-init -c 192.168.0.1:8091 \\
--cluster-init-username=Administrator \\
--cluster-init-password=password \\
--cluster-init-port=8080 \\
--cluster-init-ramsize=300
change the cluster username, password, port and ram quota:
couchbase-cli cluster-edit -c 192.168.0.1:8091 \\
--cluster-username=Administrator \\
--cluster-password=password \\
--cluster-port=8080 \\
--cluster-ramsize=300
Change the data path:
couchbase-cli node-init -c 192.168.0.1:8091 \\
--node-init-data-path=/tmp
List buckets in a cluster:
couchbase-cli bucket-list -c 192.168.0.1:8091
Create a new dedicated port couchbase bucket:
couchbase-cli bucket-create -c 192.168.0.1:8091 \\
--bucket=test_bucket \\
--bucket-type=couchbase \\
--bucket-port=11222 \\
--bucket-ramsize=200 \\
--bucket-replica=1
Create a couchbase bucket and wait for bucket ready:
couchbase-cli bucket-create -c 192.168.0.1:8091 \\
--bucket=test_bucket \\
--bucket-type=couchbase \\
--bucket-port=11222 \\
--bucket-ramsize=200 \\
--bucket-replica=1 \\
--wait
Create a new sasl memcached bucket:
couchbase-cli bucket-create -c 192.168.0.1:8091 \\
--bucket=test_bucket \\
--bucket-type=memcached \\
--bucket-password=password \\
--bucket-ramsize=200 \\
--enable-flush=1 \\
--enable-index-replica=1
Modify a dedicated port bucket:
couchbase-cli bucket-edit -c 192.168.0.1:8091 \\
--bucket=test_bucket \\
--bucket-port=11222 \\
--bucket-ramsize=400 \\
--enable-flush=1 \\
--enable-index-replica=1
Delete a bucket:
couchbase-cli bucket-delete -c 192.168.0.1:8091 \\
--bucket=test_bucket
Flush a bucket:
couchbase-cli bucket-flush -c 192.168.0.1:8091 \\
--force
Compact a bucket for both data and view
couchbase-cli bucket-compact -c 192.168.0.1:8091 \\
--bucket=test_bucket
Compact a bucket for data only
couchbase-cli bucket-compact -c 192.168.0.1:8091 \\
--bucket=test_bucket \\
--data-only
Compact a bucket for view only
couchbase-cli bucket-compact -c 192.168.0.1:8091 \\
--bucket=test_bucket \\
--view-only
Create a XDCR remote cluster
couchbase-cli xdcr-setup -c 192.168.0.1:8091 \\
--create \\
--xdcr-cluster-name=test \\
--xdcr-hostname=10.1.2.3:8091 \\
--xdcr-username=Administrator \\
--xdcr-password=password
Delete a XDCR remote cluster
couchbase-cli xdcr-delete -c 192.168.0.1:8091 \\
--xdcr-cluster-name=test
Start a replication stream
couchbase-cli xdcr-replicate -c 192.168.0.1:8091 \\
--create \\
--xdcr-cluster-name=test \\
--xdcr-from-bucket=default \\
--xdcr-to-bucket=default1
Delete a replication stream
couchbase-cli xdcr-replicate -c 192.168.0.1:8091 \\
--delete \\
--xdcr-replicator=f4eb540d74c43fd3ac6d4b7910c8c92f/default/default
"""
sys.exit(2)