1CBC(1) CBC(1)
2
3
4
6 cbc - Couchbase Client Commandline Utility
7
9 cbc COMMAND [OPTIONS]
10 cbc help
11 cbc version
12 cbc cat KEYS ... [OPTIONS]
13 cbc create KEY -V VALUE [OPTIONS]
14 cbc create KEY [OPTIONS]
15 cbc cp FILES ... [OPTIONS]
16 cbc incr KEY [OPTIONS]
17 cbc decr KEY [OPTIONS]
18 cbc touch KEY [OPTIONS]
19 cbc rm KEY [OPTIONS]
20 cbc hash KEY [OPTIONS]
21 cbc stats KEYS ... [OPTIONS]
22 cbc observe KEYS ... [OPTIONS]
23 cbc view VIEWPATH [OPTIONS]
24 cbc lock KEY [OPTIONS]
25 cbc unlock KEY CAS [OPTIONS]
26 cbc admin -P PASSWORD RESTAPI [OPTIONS]
27 cbc bucket-create -P PASSWORD NAME [OPTIONS]
28 cbc bucket-delete -P PASSWORD NAME [OPTIONS]
29 cbc bucket-flush NAME [OPTIONS]
30 cbc role-list [OPTIONS]
31 cbc user-list [OPTIONS]
32 cbc user-upsert NAME [OPTIONS]
33 cbc user-delete NAME [OPTIONS]
34 cbc connstr SPEC
35 cbc query QUERY ... [OPTIONS]
36 cbc write-config [OPTIONS ...]
37 cbc strerror HEX-OR-DECIMAL-CODE
38 cbc ping [OPTIONS ...]
39 cbc watch [KEYS ...] [OPTIONS ...]
40 cbc keygen [KEYS ...] [OPTIONS ...]
41
43 cbc is a utility for communicating with a Couchbase cluster.
44
45 cbc should be invoked with the command name first and then a series of
46 command options appropriate for the specific command. cbc help will al‐
47 ways show the full list of available commands.
48
50 Options may be read either from the command line, or from a configura‐
51 tion file (see cbcrc(4)):
52
53 The following common options may be applied to most of the commands
54
55 -U, --spec=SPEC
56 A string describing the cluster to connect to. The string is in
57 a URI-like syntax, and may also contain other options. See the
58 EXAMPLES section for information. Typically such a URI will look
59 like couchbase://host1,host2,host3/bucket.
60
61 The default for this option is couchbase://localhost/default
62
63 -u, --username=USERNAME
64 Specify the username for the bucket. Since Couchbase 5.x this is
65 mandatory switch, and it must specify the name of the user ex‐
66 isiting on cluster (read more at "Security/Authorization" sec‐
67 tion of the server manual). For older servers this field should
68 be either left empty or set to the name of the bucket itself.
69
70 -P, --password=PASSWORD:
71
72
73 -P -, --password=-
74 Specify the password for the bucket. As for servers before 5.x
75 this was only needed if the bucket is protected with a password.
76 For cluster version after 5.x, the password is mandatory, and
77 should match the selected account (read more at "Security/Autho‐
78 rization" section of the server manual).
79
80 Specifying the - as the password indicates that the program
81 should prompt for the password. You may also specify the pass‐
82 word on the commandline, directly, but is insecure as command
83 line arguments are visible via commands such as ps.
84
85 -T, --timings
86 Dump command timings at the end of execution. This will display
87 a histogram showing the latencies for the commands executed.
88
89 -v, --verbose
90 Specify more information to standard error about what the client
91 is doing. You may specify this option multiple times for in‐
92 creased output detail.
93
94 -D, --cparam=OPTION=VALUE
95 Provide additional client options. Acceptable options can also
96 be placed in the connection string, however this option is pro‐
97 vided as a convenience. This option may be specified multiple
98 times, each time specifying a key=value pair (for example, -Dop‐
99 eration_timeout=10 -Dconfig_cache=/foo/bar/baz). See ADDITIONAL
100 OPTIONS for more information
101
102 -y, --compress
103 Enable compressing of documents. When the library is compiled
104 with compression support, this option will enable Snappy com‐
105 pression for outgoing data. Incoming compressed data handled au‐
106 tomatically regardless of this option. Note, that because the
107 compression support have to be negotiated with the server, first
108 packets might be sent uncompressed even when this switch was
109 specified. This is because the library might queue data commands
110 before socket connection has been established, and the library
111 will negotiate compression feature. If it is known that all
112 server support compression repeating the switch (like -yy) will
113 force compression for all outgoing mutations, even scheduled be‐
114 fore establishing connection.
115
116 --truststorepath=PATH
117 The path to the server´s SSL certificate. This is typically re‐
118 quired for SSL connectivity unless the certificate has already
119 been added to the OpenSSL installation on the system (only ap‐
120 plicable with couchbases:// scheme)
121
122 --certpath=PATH
123 The path to the server´s SSL certificate. This is typically re‐
124 quired for SSL connectivity unless the certificate has already
125 been added to the OpenSSL installation on the system (only ap‐
126 plicable with couchbases:// scheme). This also should contain
127 client certificate when certificate authentication used, and in
128 this case other public certificates could be extracted into
129 truststorepath chain.
130
131 --keypath=PATH
132 The path to the client SSL private key. This is typically re‐
133 quired for SSL client certificate authentication. The certifi‐
134 cate itself have to go first in chain specified by certpath
135 (only applicable with couchbases:// scheme)
136
137 --dump Dump verbose internal state after operations are done.
138
140 The following options may be included in the connection string (via the
141 -U option) as URI-style query params (e.g. couchbase://host/bucket?op‐
142 tion1=value1&option2=value2) or as individual key=value pairs passed to
143 the -D switch (e.g. -Doption1=value1 -Doption2=value). The -D will in‐
144 ternally build the connection string, and is provided as a convenience
145 for options to be easily passed on the command-line
146
147 • operation_timeout=SECONDS: Specify the operation timeout in sec‐
148 onds. This is the time the client will wait for an operation to
149 complete before timing it out. The default is 2.5
150
151 • config_cache=PATH: Enables the client to make use of a file based
152 configuration cache rather than connecting for the bootstrap opera‐
153 tion. If the file does not exist, the client will first connect to
154 the cluster and then cache the bootstrap information in the file.
155
156 • truststorepath=PATH: The path to the server´s SSL certificate. This
157 is typically required for SSL connectivity unless the certificate
158 has already been added to the OpenSSL installation on the system
159 (only applicable with couchbases:// scheme)
160
161 • certpath=PATH: The path to the server´s SSL certificate. This is
162 typically required for SSL connectivity unless the certificate has
163 already been added to the OpenSSL installation on the system (only
164 applicable with couchbases:// scheme). This also should contain
165 client certificate when certificate authentication used, and in
166 this case other public certificates could be extracted into trust‐
167 storepath chain.
168
169 • keypath=PATH: The path to the client SSL private key. This is typi‐
170 cally required for SSL client certificate authentication. The cer‐
171 tificate itself have to go first in chain specified by certpath
172 (only applicable with couchbases:// scheme)
173
174 • ipv6=allow: Enable IPv6.
175
176 • ssl=no_verify: Temporarily disable certificate verification for SSL
177 (only applicable with couchbases:// scheme). This should only be
178 used for quickly debugging SSL functionality.
179
180 • sasl_mech_force=MECHANISM: Force a specific SASL mechanism to be
181 used when performing the initial connection. This should only need
182 to be modified for debugging purposes. The currently supported
183 mechanisms are PLAIN and CRAM-MD5
184
185 • bootstrap_on=<both,http,cccp>: Specify the bootstrap protocol the
186 client should use when attempting to connect to the cluster. Op‐
187 tions are: cccp: Bootstrap using the Memcached protocol (supported
188 on clusters 2.5 and greater); http: Bootstrap using the HTTP REST
189 protocol (supported on any cluster version); and both: First at‐
190 tempt bootstrap over the Memcached protocol, and use the HTTP pro‐
191 tocol if Memcached bootstrap fails. The default is both
192
193 • enable_tracing=true/false: Activate/deactivate end-to-end tracing.
194
195 • tracing_orphaned_queue_flush_interval=SECONDS: Flush interval for
196 orphaned spans queue in default tracer. This is the time the tracer
197 will wait between repeated attempts to flush most recent orphaned
198 spans. Default value is 10 seconds.
199
200 • tracing_orphaned_queue_size=NUMBER: Size of orphaned spans queue in
201 default tracer. Queues in default tracer has fixed size, and it
202 will remove information about older spans, when the limit will be
203 reached before flushing time. Default value is 128.
204
205 • tracing_threshold_queue_flush_interval=SECONDS: Flush interval for
206 spans with total time over threshold in default tracer. This is the
207 time the tracer will wait between repeated attempts to flush
208 threshold queue. Default value is 10 seconds.
209
210 • tracing_threshold_queue_size=NUMBER: Size of threshold queue in de‐
211 fault tracer. Queues in default tracer has fixed size, and it will
212 remove information about older spans, when the limit will be
213 reached before flushing time. Default value is 128.
214
215 • tracing_threshold_kv=SECONDS: Minimum time for the tracing span of
216 KV service to be considered by threshold tracer. Default value is
217 0.5 seconds.
218
219 • tracing_threshold_query=SECONDS: Minimum time for the tracing span
220 of QUERY service to be considered by threshold tracer. Default
221 value is 1 second.
222
223 • tracing_threshold_view=SECONDS: Minimum time for the tracing span
224 of VIEW service to be considered by threshold tracer. Default value
225 is 1 second.
226
227 • tracing_threshold_search=SECONDS: Minimum time for the tracing span
228 of SEARCH service to be considered by threshold tracer. Default
229 value is 1 second.
230
231 • tracing_threshold_analytics=SECONDS: Minimum time for the tracing
232 span of ANALYTICS service to be considered by threshold tracer. De‐
233 fault value is 1 second.
234
235
236
238 The following commands are supported by cbc. Unless otherwise speci‐
239 fied, each command supports all of the options above.
240
241 cat
242 Write the value of keys to standard output.
243
244 This command requires that at least one key may be passed to it, but
245 may accept multiple keys. The keys should be specified as positional
246 arguments after the command.
247
248 In addition to the options in the OPTIONS section, the following op‐
249 tions are supported:
250
251 r, --replica=all|INDEX
252 Read the value from a replica server. The value for this option
253 can either be the string all which will cause the client to re‐
254 quest the value from each replica, or INDEX where INDEX is a
255 0-based replica index.
256
257 e, --expiry=EXPIRATION
258 Specify that this operation should be a get-and-touch operation
259 in which the key´s expiry time is updated along with retrieving
260 the item.
261
262 create
263 cp
264 Create a new item in the cluster, or update the value of an existing
265 item. By default this command will read the value from standard input
266 unless the --value option is specified.
267
268 The cp command functions the same, except it operates on a list of
269 files. Each file is stored in the cluster under the name specified on
270 the command line.
271
272 In addition to the options in the OPTIONS section, the following op‐
273 tions are supported:
274
275 -V, --value=VALUE
276 The value to store in the cluster. If omitted, the value is read
277 from standard input. This option is valid only for the create
278 command.
279
280 f, --flags=ITEMFLAGS
281 A 32 bit unsigned integer to be stored alongside the value. This
282 number is returned when the item is retrieved again. Other
283 clients commonly use this value to determine the type of item
284 being stored.
285
286 e, --expiry=EXPIRATION
287 The number of time in seconds from now at which the item should
288 expire.
289
290 M, --mode=upsert|insert|replace
291 Specify the storage mode. Mode can be one of insert (store item
292 if it does not yet exist), replace (only store item if key al‐
293 ready exists), or upsert (unconditionally store item)
294
295 d, --durability=LEVEL
296 Specify durability level for mutation operations. Known values
297 are: "none", "majority", "majority_and_persist_to_active", "per‐
298 sist_to_majority".
299
300 p, --persist-to=NUMNODES
301 Wait until the item has been persisted to at least NUMNODES
302 nodes´ disk. If NUMNODES is 1 then wait until only the master
303 node has persisted the item for this key. You may not specify a
304 number greater than the number of nodes actually in the cluster.
305
306 r --replicate-to=NREPLICAS
307 Wait until the item has been replicated to at least NREPLICAS
308 replica nodes. The bucket must be configured with at least one
309 replica, and at least NREPLICAS replica nodes must be online.
310
311 observe
312 Retrieve persistence and replication information for items.
313
314 This command will print the status of each key to standard error.
315
316 See the OPTIONS for accepted options
317
318 incr
319 decr
320 These commands increment or decrement a counter item in the cluster. A
321 counter is a value stored as an ASCII string which is readable as a
322 number, thus for example 42.
323
324 These commands will by default refuse to operate on an item which does
325 not exist in the cluster.
326
327 The incr and decr command differ with how they treat the --delta argu‐
328 ment. The incr command will treat the value as a positive offset and
329 increment the current value by the amount specified, whereas the decr
330 command will treat the value as a negative offset and decrement the
331 value by the amount specified.
332
333 In addition to OPTIONS, the following options are supported:
334
335 --initial=_DEFAULT_
336 Set the initial value for the item if it does not exist in the
337 cluster. The value should be an unsigned 64 bit integer. If this
338 option is not specified and the item does not exist, the opera‐
339 tion will fail. If the item does exist, this option is ignored.
340
341 --delta=DELTA
342 Set the absolute delta by which the value should change. If the
343 command is incr then the value will be incremented by this
344 amount. If the command is decr then the value will be decre‐
345 mented by this amount. The default value for this option is 1.
346
347 -e, --expiry=EXPIRATION
348 Set the expiration time for the key, in terms of seconds from
349 now.
350
351 hash
352 Display mapping information for a key.
353
354 This command diplays mapping information about a key. The mapping in‐
355 formation indicates which vBucket the key is mapped to, and which
356 server is currently the master node for the given vBucket.
357
358 See the OPTIONS for accepted options
359
360 lock
361 Lock an item in the cluster.
362
363 This will retrieve and lock an item in the cluster, making it inacces‐
364 sible for modification until it is unlocked (see unlock).
365
366 In addition to the common options (OPTIONS), this command accepts the
367 following options:
368
369 e, --expiry=LOCKTIME
370 Specify the amount of time the lock should be held for. If not
371 specified, it will default to the server side maximum of 15 sec‐
372 onds.
373
374 unlock
375 Unlock a previously locked item.
376
377 This command accepts two mandatory positional arguments which are the
378 key and CAS value. The CAS value should be specified as printed from
379 the lock command (i.e. with the leading 0x hexadecimal prefix).
380
381 See the OPTIONS for accepted options
382
383 rm
384 Remove an item from the cluster.
385
386 This command will remove an item from the cluster. If the item does not
387 exist, the operation will fail.
388
389 See the OPTIONS for accepted options
390
391 stats
392 Retrieve a list of cluster statistics. If positional arguments are
393 passed to this command, only the statistics classified under those keys
394 will be retrieved. See the server documentation for a full list of pos‐
395 sible statistics categories.
396
397 This command will contact each server in the cluster and retrieve that
398 node´s own set of statistics.
399
400 The statistics are printed to standard output in the form of SERVER
401 STATISTIC VALUE where SERVER is the host:port representation of the
402 node from which has provided this statistic, STATISTIC is the name of
403 the current statistical key, and VALUE is the value for this statistic.
404
405 See the OPTIONS for accepted options
406
407 watch
408 Retrieve a list of cluster statistics, select specified sub-keys and
409 aggregate values across the cluster. Then continuously poll the stats
410 and display the difference with the previous values. If the list of
411 stat sub-keys not specified, the command will use cmd_total_ops,
412 cmd_total_gets, cmd_total_sets.
413
414 In addition to the options in the OPTIONS section, the following op‐
415 tions are supported: * -n, --interval=VALUE: Update interval in seconds
416 (default 1 second).
417
418 keygen
419 Output list of keys that equally distribute amongst every vbucket.
420
421 In addition to the options in the OPTIONS section, the following op‐
422 tions are supported: * --keys-per-vbucket=VALUE: Number of keys to gen‐
423 erate per vBucket (default 1).
424
425 write-config
426 Write the configuration file based on arguments passed.
427
428 strerror
429 Decode library error code
430
431 version
432 Display information about the underlying version of libcouchbase to
433 which the cbc binary is linked.
434
435 verbosity
436 Set the memcached logging versbosity on the cluster. This affects how
437 the memcached processes write their logs. This command accepts a single
438 positional argument which is a string describing the verbosity level to
439 be set. The options are detail, debug info, and warning.
440
441 ping
442 Sends NOOP-like request to every service on each cluster node, and re‐
443 port time it took to response.
444
445 --details
446 Provide more details about status of the service.
447
448 -t, --table
449 Render results as a table.
450
451 view
452 Execute an HTTP request against the server´s view (CAPI) interface.
453
454 The request may be one to create a design document, view a design docu‐
455 ment, or query a view.
456
457 To create a design document, the definition of the document (in JSON)
458 should be piped to the command on standard input.
459
460 This command accepts one positional argument which is the path (rela‐
461 tive to the bucket) to execute. Thus to query the brewery_beers view in
462 the beer design document within the beer-sample bucket one would do:
463 cbc view -U couchbase://localhost/beer-sample design/beer/view/brew‐
464 ery_beers
465
466 In addition to the OPTIONS specified above, the following options are
467 recognized:
468
469 -X, --method=GET|PUT|POST|DELETE
470 Specify the HTTP method to use for the specific request. The de‐
471 fault method is GET to query a view. To delete an existing de‐
472 sign document, specify DELETE, and to create a new design docu‐
473 ment, specify PUT.
474
475 query
476 Execute a N1QL Query. The cluster must have at least one query node en‐
477 abled.
478
479 The query itself is passed as a positional argument on the commandline.
480 The query may contain named placeholders (in the format of $param),
481 whose values may be supplied later on using the --qarg=´$param=value´
482 syntax.
483
484 It is recommended to place the statement in single quotes to avoid
485 shell expansion.
486
487 In addition to the OPTIONS specified above, the following options are
488 recognized:
489
490 -Q, --qopt=SETTING=VALUE
491 Specify additional options controlling the execution of the
492 query. This can be used for example, to set the scan_consistency
493 of the query.
494
495 -A, --qarg=PLACEHOLDER=VALUE
496 Supply values for placeholders found in the query string. The
497 placeholders must evaluate to valid JSON values.
498
499 --prepare
500 Prepare query before issuing. Default is FALSE.
501
502 --analytics
503 Perform query to analytics service. Default is FALSE.
504
505 admin
506 Execute an administrative request against the management REST API. Note
507 that in order to perform an administrative API you will need to provide
508 administrative credentials to cbc admin. This means the username and
509 password used to log into the administration console.
510
511 This command accepts a single positional argument which is the REST API
512 endpoint (i.e. HTTP path) to execute.
513
514 If the request requires a body, it should be supplied via standard in‐
515 put
516
517 In addition to the OPTIONS specified above, the following options are
518 recognized:
519
520 -X, --method=GET|PUT|POST|DELETE
521 Specify the HTTP method to use for the specific request. The de‐
522 fault method is GET.
523
524 bucket-create
525 Create a bucket in the cluster.
526
527 This command will create a bucket with the name specified as the lone
528 positional argument on the command line.
529
530 As this is an administrative command, the --username and --password op‐
531 tions should be supplied administrative credentials.
532
533 In addition to the OPTIONS specified above, the following options are
534 recognized:
535
536 --bucket-type=couchbase|memcached
537 Specify the type of bucket to create. A couchbase bucket has
538 persistence to disk and replication. A memached bucket is
539 in-memory only and does not replicate.
540
541 --ram-quota=QUOTA
542 Specify the maximum amount of memory the bucket should occupy
543 (per node) in megabytes. If not specified, the default is 512.
544
545 --bucket-password=PASSWORD
546 Specify the password to secure this bucket. If passed, this
547 password will be required by all clients attempting to connect
548 to the bucket. If ommitted, this bucket may be accessible to ev‐
549 eryone for both read and write access.
550
551 --num-replicas=REPLICAS
552 Specify the amount of replicas the bucket should have. This will
553 set the number of nodes each item will be replicated to. If not
554 specified the default is 1.
555
556 bucket-flush
557 This command will flush the bucket with the name specified as the lone
558 positional argument on the command line.
559
560 This command does not require administrative level credentials, however
561 it does require that flush be enabled for the bucket.
562
563 See the OPTIONS for accepted options
564
565 role-list
566 List accessible RBAC user roles in the cluster.
567
568 In addition to the OPTIONS specified above, the following options are
569 recognized:
570
571 -r, --raw
572 Print unformatted server response in JSON form.
573
574 user-list
575 List users in the cluster.
576
577 In addition to the OPTIONS specified above, the following options are
578 recognized:
579
580 -r, --raw
581 Print unformatted server response in JSON form.
582
583 user-upsert
584 Create or update a user in the cluster. Takes user ID as an argument.
585
586 In addition to the OPTIONS specified above, the following options are
587 recognized:
588
589 --domain=local|remote
590 The domain, where user account defined. If not specified, the
591 default is local.
592
593 --full-name=FULL_NAME
594 The user´s fullname. If not specified, the default is empty
595 string.
596
597 --role=ROLE
598 The role associated with user (can be specified multiple times
599 if needed).
600
601 --user-password=PASSWORD
602 The password for the user.
603
604 user-delete
605 Delete a user in the cluster. Takes user ID as an argument.
606
607 In addition to the OPTIONS specified above, the following options are
608 recognized:
609
610 --domain=local|remote
611 The domain, where user account defined. If not specified, the
612 default is local.
613
614 connstr
615 This command will parse a connection string into its constituent parts
616 and display them on the screen. The command takes a single positional
617 argument which is the string to parse.
618
620 CONNECTION EXAMPLES
621 The following shows how to connect to various types of buckets. These
622 examples all show how to retrieve the key key. See OPERATION EXAMPLES
623 for more information on specific sub-commands.
624
625 Connect to a bucket (a_bucket) on a cluster on a remote host (for
626 servers version 5.x+). It uses account ´myname´ and asks password in‐
627 teractively:
628
629
630
631 cbc cat key -U couchbase://192.168.33.101/a_bucket -u myname -P-
632
633
634
635 Run against a password-less bucket (a_bucket) on a cluster on a remote
636 host (for servers older than 5.x):
637
638
639
640 cbc cat key -U couchbase://192.168.33.101/a_bucket
641
642
643
644 Connect to an SSL cluster at secure.net. The certificate for the clus‐
645 ter is stored locally at /home/couchbase/couchbase_cert.pem:
646
647
648
649 cbc cat key -U couchbases://secure.net/topsecret_bucket?certpath=/home/couchbase/couchbase_cert.pem
650
651
652
653 Connect to an SSL cluster at secure.net, ignoring certificate verifica‐
654 tion. This is insecure but handy for testing:
655
656
657
658 cbc cat key -U couchbases://secure.net/topsecret_bucket?ssl=no_verify
659
660
661
662 Connect to a password protected bucket (protected) on a remote host
663 (for servers older than 5.x):
664
665
666
667 cbc cat key -U couchbase://remote.host.net/protected -P-
668 Bucket password:
669
670
671
672 Connect to a password protected bucket (for servers older than 5.x),
673 specifying the password on the command line (INSECURE, but useful for
674 testing dummy environments)
675
676
677
678 cbc cat key -U couchbase://remote.host.net/protected -P t0ps3cr3t
679
680
681
682 Connect to a bucket running on a cluster with a custom REST API port
683
684
685
686 cbc cat key -U http://localhost:9000/default
687
688
689
690 Connec to bucket running on a cluster with a custom memcached port
691
692
693
694 cbc cat key -U couchbase://localhost:12000/default
695
696
697
698 Connect to a memcached (http://memcached.org) cluster using the binary
699 protocol. A vanilla memcached cluster is not the same as a memcached
700 bucket residing within a couchbase cluster (use the normal couchbase://
701 scheme for that):
702
703
704
705 cbc cat key -U memcached://host1,host2,host3,host4
706
707
708
709 Connect to a cluster using the HTTP protocol for bootstrap, and set the
710 operation timeout to 5 seconds
711
712
713
714 cbc cat key -U couchbase://host/bucket -Dbootstrap_on=http -Doperation_timeout=5
715
716
717
718 OPERATION EXAMPLES
719 Store a file to the cluster:
720
721
722
723 $ cbc cp mystuff.txt
724 mystuff.txt Stored. CAS=0xe15dbe22efc1e00
725
726
727
728 Retrieve persistence/replication information about an item (note that
729 Status is a set of bits):
730
731
732
733 $ cbc observe mystuff.txt
734 mystuff [Master] Status=0x80, CAS=0x0
735
736
737
738 Display mapping information about keys:
739
740
741
742 $cbc hash foo bar baz
743 foo: [vBucket=115, Index=3] Server: cbnode3:11210, CouchAPI: http://cbnode3:8092/default
744 bar: [vBucket=767, Index=0] Server: cbnode1:11210, CouchAPI: http://cbnode1:8092/default
745 baz: [vBucket=36, Index=2] Server: cbnode2:11210, CouchAPI: http://cbnode2:8092/default
746
747
748
749 Create a bucket:
750
751
752
753 $ cbc bucket-create --bucket-type=memcached --ram-quota=100 --password=letmein -u Administrator -P 123456 mybucket
754 Requesting /pools/default/buckets
755 202
756 Cache-Control: no-cache
757 Content-Length: 0
758 Date: Sun, 22 Jun 2014 22:43:56 GMT
759 Location: /pools/default/buckets/mybucket
760 Pragma: no-cache
761 Server: Couchbase Server
762
763
764
765 Flush a bucket:
766
767
768
769 $ cbc bucket-flush default
770 Requesting /pools/default/buckets/default/controller/doFlush
771
772
773 200
774 Cache-Control: no-cache
775 Content-Length: 0
776 Date: Sun, 22 Jun 2014 22:53:44 GMT
777 Pragma: no-cache
778 Server: Couchbase Server
779
780
781
782 Delete a bucket:
783
784
785
786 $ cbc bucket-delete mybucket -P123456
787 Requesting /pools/default/buckets/mybucket
788 200
789 Cache-Control: no-cache
790 Content-Length: 0
791 Date: Sun, 22 Jun 2014 22:55:58 GMT
792 Pragma: no-cache
793 Server: Couchbase Server
794
795
796
797 Use cbc stats to determine the minimum and maximum timeouts for a lock
798 operation:
799
800
801
802 $ cbc stats | grep ep_getl
803 localhost:11210 ep_getl_default_timeout 15
804 localhost:11210 ep_getl_max_timeout 30
805
806
807
808 Create a design document:
809
810
811
812 $ echo ´{"views":{"all":{"map":"function(doc,meta){emit(meta.id,null)}"}}}´ | cbc view -X PUT _design/blog
813 201
814 Cache-Control: must-revalidate
815 Content-Length: 32
816 Content-Type: application/json
817 Date: Sun, 22 Jun 2014 23:03:40 GMT
818 Location: http://localhost:8092/default/_design/blog
819 Server: MochiWeb/1.0 (Any of you quaids got a smint?)
820 {"ok":true,"id":"_design/blog"}
821
822
823
824 Query a view:
825
826
827
828 $ cbc view _design/blog/_view/all?limit=5
829 200
830 Cache-Control: must-revalidate
831 Content-Type: application/json
832 Date: Sun, 22 Jun 2014 23:06:09 GMT
833 Server: MochiWeb/1.0 (Any of you quaids got a smint?)
834 Transfer-Encoding: chunked
835 {"total_rows":20,"rows":[
836 {"id":"bin","key":"bin","value":null},
837 {"id":"check-all-libev-unit-tests.log","key":"check-all-libev-unit-tests.log","value":null},
838 {"id":"check-all-libevent-unit-tests.log","key":"check-all-libevent-unit-tests.log","value":null},
839 {"id":"check-all-select-unit-tests.log","key":"check-all-select-unit-tests.log","value":null},
840 {"id":"cmake_install.cmake","key":"cmake_install.cmake","value":null}
841 ]
842 }
843
844
845
846 Issue a N1QL query:
847
848
849
850 $ cbc query ´SELECT * FROM `travel-sample` WHERE type="airport" AND city=$city´ -Qscan_consistency=request_plus -A´$city=\"Reno\"´
851
852
853
854 Ping cluster services:
855
856
857
858 $ cbc ping --details -Ucouchbase://192.168.1.101
859 {
860 "version" : 1,
861 "config_rev" : 54,
862 "id" : "0x1d67af0",
863 "sdk" : "libcouchbase/2.8.4",
864 "services" : {
865 "fts" : [
866 {
867 "id" : "0x1d75e90",
868 "latency_us" : 1500,
869 "local" : "192.168.1.12:35232",
870 "remote" : "192.168.1.101:8094",
871 "status" : "ok"
872 },
873 {
874 "id" : "0x1da6800",
875 "latency_us" : 2301,
876 "local" : "192.168.1.12:40344",
877 "remote" : "192.168.1.103:8094",
878 "status" : "ok"
879 },
880 {
881 "id" : "0x1da3270",
882 "latency_us" : 2820,
883 "local" : "192.168.1.12:42730",
884 "remote" : "192.168.1.102:8094",
885 "status" : "ok"
886 },
887 {
888 "details" : "LCB_ENETUNREACH (0x31): The remote host was unreachable - is your network OK?",
889 "latency_us" : 3071733,
890 "remote" : "192.168.1.104:8094",
891 "status" : "error"
892 }
893 ],
894 "kv" : [
895 {
896 "id" : "0x1d6bde0",
897 "latency_us" : 3700,
898 "local" : "192.168.1.12:42006",
899 "remote" : "192.168.1.101:11210",
900 "scope" : "default",
901 "status" : "ok"
902 },
903 {
904 "id" : "0x1dadcf0",
905 "latency_us" : 5509,
906 "local" : "192.168.1.12:39936",
907 "remote" : "192.168.1.103:11210",
908 "scope" : "default",
909 "status" : "ok"
910 },
911 {
912 "id" : "0x1dac500",
913 "latency_us" : 5594,
914 "local" : "192.168.1.12:33868",
915 "remote" : "192.168.1.102:11210",
916 "scope" : "default",
917 "status" : "ok"
918 },
919 {
920 "latency_us" : 2501688,
921 "remote" : "192.168.1.104:11210",
922 "scope" : "default",
923 "status" : "timeout"
924 }
925 ],
926 "n1ql" : [
927 {
928 "id" : "0x1d7f280",
929 "latency_us" : 3235,
930 "local" : "192.168.1.12:54210",
931 "remote" : "192.168.1.101:8093",
932 "status" : "ok"
933 },
934 {
935 "id" : "0x1d76f20",
936 "latency_us" : 4625,
937 "local" : "192.168.1.12:58454",
938 "remote" : "192.168.1.102:8093",
939 "status" : "ok"
940 },
941 {
942 "id" : "0x1da44b0",
943 "latency_us" : 4477,
944 "local" : "192.168.1.12:36678",
945 "remote" : "192.168.1.103:8093",
946 "status" : "ok"
947 },
948 {
949 "details" : "LCB_ENETUNREACH (0x31): The remote host was unreachable - is your network OK?",
950 "latency_us" : 3071843,
951 "remote" : "192.168.1.104:8093",
952 "status" : "error"
953 }
954 ],
955 "views" : [
956 {
957 "id" : "0x1da55c0",
958 "latency_us" : 1762,
959 "local" : "192.168.1.12:52166",
960 "remote" : "192.168.1.103:8092",
961 "status" : "ok"
962 },
963 {
964 "id" : "0x1da20d0",
965 "latency_us" : 2016,
966 "local" : "192.168.1.12:59420",
967 "remote" : "192.168.1.102:8092",
968 "status" : "ok"
969 },
970 {
971 "id" : "0x1d6a740",
972 "latency_us" : 2567,
973 "local" : "192.168.1.12:38614",
974 "remote" : "192.168.1.101:8092",
975 "status" : "ok"
976 },
977 {
978 "details" : "LCB_ENETUNREACH (0x31): The remote host was unreachable - is your network OK?",
979 "latency_us" : 3071798,
980 "remote" : "192.168.1.104:8092",
981 "status" : "error"
982 }
983 ]
984 }
985 }
986
987
988
990 cbc(1) and cbc-pillowfight(1) may also read options from cbcrc(4). The
991 default path for cbcrc is $HOME/.cbcrc, but may be overridden by set‐
992 ting the CBC_CONFIG evironment variable to an alternate path.
993
995 The options in this utility and their behavior are subject to change.
996 This script should be used for experiemntation only and not inside pro‐
997 duction scripts.
998
1000 cbc-pillowfight(1), cbcrc(4)
1001
1003 The cbc command first appeared in version 0.3.0 of the library. It was
1004 significantly rewritten in version 2.4.0
1005
1006
1007
1008 December 2020 CBC(1)