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