= cbc(1) :doctype: manpage Trond Norbye NAME ---- cbc - Couchbase command line utility SYNOPSIS -------- *cbc help* *cbc cat* [common options] [-r ['VALUE']] 'key'... *cbc cp* [common options] [-p] [-r 'NUMBER'] [-m 'NUMBER'] [-j] 'filename'... *cbc create* [common options] [-f 'FLAGS'] [-e 'VALUE'] [-a] 'key' *cbc observe* [common options] 'key'... *cbc flush* [common options] *cbc hash* [common options] [-f 'FILENAME'] 'key'... *cbc lock* [common options] [-e 'VALUE'] 'key'... *cbc unlock* [common options] 'key' 'cas'... *cbc rm* [common options] 'key'... *cbc stats* [common options] ['stat group']... *cbc verify* [common options] 'filename'... *cbc version* [common options] *cbc verbosity* [common options] 'level' *cbc view* [common options] [-c] [-d 'DATA'] [-X 'METHOD'] 'query' *cbc admin* [common options] [-c] [-d 'DATA'] [-X 'METHOD'] 'query' *cbc bucket-create* [common options] [-B 'TYPE'] [-q 'QUOTA'] [-a 'AUTH'] [-s 'PASSWORD'] [-r 'NUMBER'] [-p 'PORT'] 'bucketname'... *cbc bucket-delete* [common options] 'bucket'... *cbc bucket-flush* [common options] 'bucket'... *cbc pillowfight* [-?] [-h 'HOST'] [-b 'BUCKET'] [-u 'USER'] [-P 'PASSWORD'] [-T] [-i 'ITERATIONS'] [-I 'ITEMS'] [-p 'PREFIX'] [-t 'THREADS'] [-Q 'INSTANCES'] [-l] [-s 'SEED'] [-r 'RATIO'] [-m 'MIN'] [-M 'MAX'] [-d] [-D] [-n] [-w 'WAITSECS'] DESCRIPTION ----------- cbc is a command line utility that allows you to communicate with your Couchbase Server cluster from the command line prompt. COMMON OPTIONS -------------- The following options are supported: *-?, --help*:: Display usage information and exit. *-h, --host*='HOST':: Specify the list of hosts to connect to (default: '127.0.0.1:8091'). *-b, --bucket*='BUCKET':: Specify the bucket to use (default: 'default'). *-u, --user*='USER':: Specify the username used for authentication to the cluster. *-P, --password*='PASSWORD':: Specify the password used for authentication to the cluster. *-T, --enable-timings*:: Enable the recording of the timing of commands and building histograms. *-t, --timeout*='TIMEOUT':: Specify timeout value in microseconds (default: 2500000) *-D, --dumb*:: Enable memcached compatibility mode. With this option set subcommands can be executed against regular memcached node. *-S, --sasl*='MECH':: Force SASL authentication mechanism (currently "PLAIN" or "CRAM-MD5"). *-C, --config-transport*='TRANSPORT':: Specify transport for bootstrapping the connection: "HTTP" (default) or "CCCP" SUBCOMMANDS ----------- The following subcommands are supported: *cbc help*:: Display usage information and exit. *cbc cat* [common options] [-r ['VALUE']] 'key'...:: Print the contents of the value for the key to standard output. *-r, --replicas*[='VALUE']:::: Read key(s) from replicas: (default: 'first')). Following strategies available: + |======================================= | 'first' | try all replica from first in a sequence until first successful response | 'all' | try all replicas in parallel | N, where 0 < N < number of replicas | read from selected replica only |======================================= *cbc cp* [common options] [-p] [-r 'NUMBER'] [-m 'NUMBER'] [-j] 'filename'...:: Store the content of a file under the specified key in the cluster. *-p, --persisted*:::: Ensure that key has been persisted to the primary node. *-r, --replicated*='NUMBER':::: Ensure that the key has been replicated and persisted to given 'NUMBER' of replicas. *-m, --max-tries*='NUMBER':::: The number of attempts for observing keys (default: 5). *-j, --json*:::: Treat the value as a JSON document (take key from '_id' attribute). This option is only valid if the libyajl2 is present. *cbc create* [common options] [-f 'FLAGS'] [-e 'VALUE'] [-a] 'key':: Create a key in the cluster by reading the the value from standard input. *-f, --flag*='FLAGS':::: The flags to associate with the key. *-e, --exptime*='VALUE':::: The expiration time for the key. Values larger than 30*24*60*60 seconds (30 days) are interpreted as absolute times (from the epoch). *-a*:::: Fail if an object exist in the database for that key. *cbc observe* [common options] 'key'...:: Observe a key in the cache. *cbc flush* [common options]:: Remove all keys from the cluster. The flush subcommand is only supported on memcached buckets. To flush a Couchbase bucket you need use bucket-flush. *cbc hash* [common options] [-v] [-f 'FILENAME'] 'key'...:: Hash key(s) and print out useful info. *-f, --config-file*='FILENAME':::: 'FILENAME' shall be a plain text file containing an alternative cluster configuration (in JSON) to use. *-v, --vbucket:::: Treat keys as vbucket IDs and skip hash calculation phase *cbc lock* [common options] [-e 'VALUE'] 'key'...:: Lock and retrieve the value for a key. The lock is held for the object until it expires (timing out) or from a manual unlock command. Consult your Couchbase documentation for more information about locking of objects. *-e, --exptime*='VALUE':::: The expiry time for the lock. *cbc unlock* [common options] 'key' 'cas'...:: Unlock the key previously locked with lock. You have to specify the same cas value as returned by the lock command in order to successfully unlock the keys. *cbc rm* [common options] 'key'...:: Remove a number of keys from the cluster. *cbc stats* [common options] ['stat group']...:: Retrieve various statistics from the cluster. *cbc verify* [common options] 'filename'...:: Verify the content for the key represented by the filename in the cache is the same as the file content. *cbc version* [common options]:: Print the version numbers for cbc and libcouchbase. *cbc verbosity* [common options] 'level':: Set verbosity level. The level may be one of the following: + |======================================= | 'detail' | This will cause the nodes to generate an insane amount of data. It shoud not be used unless you know what you're doing. | 'debug' | This will cause the nodes to generate a lot of data. It should not be used unless you know what you're doing. | 'info' | This will cause the nodes to generate lot of data (dumping each command being executed). You should avoid using this unless you're searching for a bug. It will affect your performance. | 'warning' | Only warnings will be reported. This is what you normally want! |======================================= *cbc view* [common options] [-c] [-d 'DATA'] [-X 'METHOD'] 'query':: Execute Couchbase view (aka map/reduce) request. *-c, --chunked*:::: Use chunked callback to stream the data *-d, --data*='DATA':::: HTTP body data for POST or PUT requests, e.g. '{"keys": ["key1", "key2"]}' *-X, --request*='METHOD':::: HTTP request method, possible values 'GET' (default), 'POST', 'PUT', 'DELETE'. *cbc admin* [common options] [-c] [-d 'DATA'] [-X 'METHOD'] 'query':: Execute request to management REST API. *-c, --chunked*:::: Use chunked callback to stream the data *-d, --data*='DATA':::: HTTP body data for POST or PUT requests, e.g. '{"keys": ["key1", "key2"]}' *-X, --request*='METHOD':::: HTTP request method, possible values 'GET' (default), 'POST', 'PUT', 'DELETE'. *cbc bucket-create* [common options] [-B 'TYPE'] [-q 'QUOTA'] [-a 'AUTH'] [-s 'PASSWORD'] [-r 'NUMBER'] [-p 'PORT'] 'bucketname'...:: Create a bucket in the cluster. *-B, --bucket-type*='TYPE':::: Specify the type of bucket to create. Type may be one of 'couchbase' (default), 'memcached'. *-q, --ram-quota*='QUOTA':::: RAM quota in megabytes (default: 100). *-a, --auth-type*='AUTH':::: Type of bucket authentication, type may be one of 'none' or 'sasl' (default). *-s, --sasl-password*='PASSWORD':::: Password used for SASL authentication (default ""). *-r, --replica-number*='NUMBER':::: The number of replicas to create for each key. The value should be in the range [0-3] (default 1). *-p, --proxy-port*='PORT':::: The port number the proxy should provide access to this bucket (default: 11211). *cbc bucket-delete* [common options] 'bucket'...:: Delete the named buckets from the cluster. *cbc bucket-flush* [common options] 'bucket'...:: Flush (remove all data) from the named buckets. Please note that you need to have flush enabled on the specified bucket to use this command successfully. *cbc pillowfight* [-?] [-h 'HOST'] [-b 'BUCKET'] [-u 'USER'] [-P 'PASSWORD'] [-T] [-i 'ITERATIONS'] [-I 'ITEMS'] [-p 'PREFIX'] [-t 'THREADS'] [-Q 'INSTANCES'] [-l] [-s 'SEED'] [-r 'RATIO'] [-m 'MIN'] [-M 'MAX'] [-d] [-D] [-n] [-w 'WAITSECS']:: Generate test load for the cluster. Currently only one workload type available: mixed SET and GET operations (see '--ratio' option below). *-?, --help*:::: Display usage information and exit. *-h, --host*='HOST':::: Specify the list of hosts to connect to (default: '127.0.0.1:8091'). *-b, --bucket*='BUCKET':::: Specify the bucket to use (default: 'default'). *-u, --user*='USER':::: Specify the username used for authentication to the cluster. *-P, --password*='PASSWORD':::: Specify the password used for authentication to the cluster. *-T, --enable-timings*:::: Enable the recording of the timing of commands and building histograms. *-i, --iterations*='ITERATIONS':::: Number of iterations to run (???) (default: 1000) *-I, --num-items*='ITEMS':::: Number of items to operate on (default: 1000) *-p, --key-prefix*='PREFIX':::: Use the following prefix for keys (default: "") *-t, --num-threads*='THREADS':::: The number of threads to use (default: 1) *-Q, --num-instances*='INSTANCES':::: The number of connection instances to put into the shared connection pool (default 1) *-l, --loop*:::: Run load in an infinite loop. Could be terminated by SIGINT (Ctrl-C). *-s, --random-seed*='SEED':::: Specify random seed (default 0) *-r, --ratio*='RATIO':::: Specify SET/GET command ratio (default: 33, i.e. 33% SETs and 67% GETs) *-m, --min-size*='MIN':::: Specify minimum size of payload, i.e. document body (default: 50) *-n, --no-population*:::: Skip populating *-M, --max-size*='MAX':::: Specify maximum size of payload (default: 5120) *-d, --dumb*:::: Behave like legacy memcached client (default: false). Useful to check moxi for example, or other memcached implementations. *-S, --sasl*='MECH':: Force SASL authentication mechanism (currently "PLAIN" or "CRAM-MD5"). *-C, --config-transport*='TRANSPORT':: Specify transport for bootstrapping the connection: "HTTP" (default) or "CCCP" *-D, --data-greater-than-memory*:::: Specify if testing with data greater than memory size *-w, --wait-time-for-op*='WAITSECS':: Specify time to wait for store operations if data greater than memory (default 10) EXAMPLES -------- Example 1. Copy a file into the cluster. The following command copies the file mynote.txt located in the current directory into the cluster: shell> cbc cp mynote.txt Stored "mynote.txt" CAS:d8062155b1100000 Example 2. Observe a key in the cluster. The following command retrieves information about the key named mynote.txt: shell> cbc observe mynote.txt PERSISTED "mynote.txt" CAS:313e468316000000 IsMaster:true TimeToPersist:0 TimeToReplicate:0 Example 3. The following command shows you how to use cbc hash: shell> cbc hash key1 key2 key3 "key1" vBucket:92 Server:"127.0.0.1:12000" CouchAPI:"http://127.0.0.1:9500/default" Replicas:"127.0.0.1:12000" "key2" vBucket:341 Server:"127.0.0.1:12000" CouchAPI:"http://127.0.0.1:9500/default" Replicas:"127.0.0.1:12000" "key3" vBucket:594 Server:"127.0.0.1:12000" CouchAPI:"http://127.0.0.1:9500/default" Replicas:"127.0.0.1:12000" Example 4. Create a bucket. The following command shows you how to create a bucket in the cache. This is a privileged operation so you need to authenticate to the cluster: shell> cbc bucket-create -u Administrator -P secret --bucket-type=memcached --ram-quota=64 --auth-type=sasl --sasl-password=secret --replica-number=0 --proxy-port=11211 mybucket Server: Couchbase Server 2.0.0r_521_g67b4898 Pragma: no-cache Location: /pools/default/buckets/mybucket Date: Tue, 06 Nov 2012 11:04:40 GMT Content-Length: 0 Cache-Control: no-cache "/pools/default/buckets": OK Size:0 Example 5. Flush a bucket. The following command shows you how to flush (remove all items) in the bucket named "mybucket": shell> cbc bucket-flush mybucket Server: Couchbase Server 2.0.0r_521_g67b4898 Pragma: no-cache Date: Tue, 06 Nov 2012 11:12:33 GMT Content-Length: 0 Cache-Control: no-cache "/pools/default/buckets/mybucket/controller/doFlush": OK Size:0 Example 6. Delete a bucket. The following command shows you delete the bucket named "mybucket". This is a privileged operation so you need to authenticate to the cluster: shell> cbc bucket-delete -u Administrator -P secret --timeout=10000000 mybucket Server: Couchbase Server 2.0.0r_521_g67b4898 Pragma: no-cache Date: Tue, 06 Nov 2012 11:25:57 GMT Content-Length: 0 Cache-Control: no-cache "/pools/default/buckets/mybucket": OK Size:0 Example 7. Fetch stats. The following command shows how to determine default and maximum values for GETL operation: shell> cbc stats | grep ep_getl localhost:11210 ep_getl_default_timeout 15 localhost:11210 ep_getl_max_timeout 30 Example 8. Fetch stats. The following command shows how to get memory statistics for each node in the cluster using stats group 'memory': shell> cbc stats memory localhost:11210 bytes 16949680 localhost:11210 mem_used 16949680 localhost:11210 ep_kv_size 8396 localhost:11210 ep_value_size 7996 localhost:11210 ep_overhead 13838896 localhost:11210 ep_max_data_size 104857600 localhost:11210 ep_mem_low_wat 78643200 localhost:11210 ep_mem_high_wat 89128959 localhost:11210 ep_oom_errors 0 localhost:11210 ep_tmp_oom_errors 0 localhost:11210 ep_mem_tracker_enabled true localhost:11210 tcmalloc_current_thread_cache_bytes 1063496 localhost:11210 tcmalloc_max_thread_cache_bytes 4194304 localhost:11210 tcmalloc_unmapped_bytes 0 localhost:11210 total_allocated_bytes 67322792 localhost:11210 total_fragmentation_bytes 2710616 localhost:11210 total_free_bytes 221184 localhost:11210 total_heap_bytes 70254592 Example 9. Create design document. The following command shows how to save new design document into the bucket. shell> cbc view -XPUT -d'{"views":{"all":{"map":"function(doc,meta){emit(meta.id,null)}"}}}' _design/blog Server: MochiWeb/1.0 (Any of you quaids got a smint?) Location: http://localhost:8092/default/_design/blog Date: Thu, 01 Aug 2013 13:13:57 GMT Content-Type: application/json Content-Length: 32 Cache-Control: must-revalidate "_design/blog": OK Size:32 {"ok":true,"id":"_design/blog"} Example 10. Fetch views. The following command shows how to fetch a view from the cluster. shell> cbc view _design/blog/_view/all Transfer-Encoding: chunked Server: MochiWeb/1.0 (Any of you quaids got a smint?) Date: Thu, 01 Aug 2013 13:19:32 GMT Content-Type: application/json Cache-Control: must-revalidate "_design/blog/_view/all": OK Size:174 {"total_rows":3,"rows":[ {"id":".gitignore","key":".gitignore","value":null}, {"id":"foo","key":"foo","value":null}, {"id":"pool_foo","key":"pool_foo","value":null} ] } FILES ----- *~/.cbcrc*:: Default values used by cbc. See cbcrc(4) for more information ENVIRONMENT VARIABLES --------------------- The following environment variables may be used to specify configuration values. If specified they override the value specified in '~/.cbcrc' (but options specified on the command line will override environment variables). *COUCHBASE_CLUSTER_URI*:: This is a list separated by semicolon of hostnames (with an optional port) to your cluster. *COUCHBASE_CLUSTER_USER*:: This is the username used during authentication to your cluster. *COUCHBASE_CLUSTER_PASSWORD*:: This is the password used during authentication to your cluster. *COUCHBASE_CLUSTER_BUCKET*:: This is the name of the bucket you would like to use. *LIBCOUCHBASE_EVENT_PLUGIN_NAME*:: Override type of the IO backend. The value should be either the name or path to the IO plugin. When it is a path to custom IO plugin, the symbol name is also required, see 'LIBCOUCHBASE_EVENT_PLUGIN_SYMBOL' below. See list of known plugins and more details about IO subsystem in lcb_create_io_ops(3couchbase) page. *LIBCOUCHBASE_EVENT_PLUGIN_SYMBOL*:: Symbol which should be accessible in the plugin. The library will use the function, associated with the symbol to create new instances of the IO object. ATTRIBUTES ---------- See lcb_attributes(5) for descriptions of the following attributes: [options="header"] |======================================= | ATTRIBUTE TYPE | ATTRIBUTE VALUE | Interface Stability | Volatile |======================================= COPYRIGHT --------- Copyright 2010-2013 Couchbase, Inc. SEE ALSO -------- Learn more at . cbcrc(4), lcb_attributes(5)