Buckets

Buckets are managed with the couchbase-cli tool and the bucket-* commands.

This section provides examples for listing, creating, modifying, flushing, and compacting buckets.

Listing bucketss

To list buckets in a cluster:


couchbase-cli bucket-list -c 192.168.0.1:8091

Creating buckets

To 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

To 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

To 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

Modifying buckets

To 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

Deleting buckets

To delete a bucket:


couchbase-cli bucket-delete -c 192.168.0.1:8091 \
       --bucket=test_bucket

Flushing buckets

Flushing buckets involves:

  1. Enable the flush buckets option.
  2. Flush the bucket.

To enable the flush bucket option:

When you want to flush a data bucket you must first enable this option then actually issue the command to flush the data bucket.

Note: We do not advise that you enable this option if your data bucket is in a production environment. Be aware that this is one of the preferred methods for enabling data bucket flush.

You can enable this option when you actually create the data bucket, or when you edit the bucket properties:


// To enable, set bucket flush to 1. Default:0
// To enable bucket flush when creating a bucket:

couchbase-cli bucket-create [bucket_name] [cluster_admin:pass] --enable-flush=[0|1]

// To enable bucket flush when editing the bucket properties:

couchbase-cli bucket-edit [bucket_name] [cluster_admin:pass] --enable-flush=[0|1]

After you enable this option, you can then flush the data bucket.

To flush a bucket:

After you explicitly enable data bucket flush, flush the data from the bucket. Flushing a bucket is data destructive. Client applications using this are advised to double check with the end user before sending such a request. You can control and limit the ability to flush individual buckets by setting the flushEnabled parameter on a bucket in Couchbase Web Console or via couchbase-cli as described in the previous section.

Syntax



> couchbase-cli bucket-flush [cluster_admin:pass] [bucket_name OPTIONS]

                        

By default, this command confirms whether or not you truly want to flush the data bucket. You can optionally call this command with the --force option to flush data without confirmation.

Example


couchbase-cli bucket-flush -c 192.168.0.1:8091 \
       --force

Compacting buckets

To compact a bucket for both data and view:


couchbase-cli bucket-compact -c 192.168.0.1:8091 \
        --bucket=test_bucket

To compact a bucket for data only:


couchbase-cli bucket-compact -c 192.168.0.1:8091 \
        --bucket=test_bucket \
        --data-only

To compact a bucket for view only:


couchbase-cli bucket-compact -c 192.168.0.1:8091 \
        --bucket=test_bucket \
        --view-only