rebalance

rebalance

Rebalances data across nodes in a cluster

SYNTAX

couchbase-cli rebalance [--cluster <url>] [--username <user>] [--password <password>] [--server-remove <servers>] [--no-progress-bar] [--no-wait]

DESCRIPTION

Rebalances data across all servers in the cluster. This command should be used after servers are added, removed, or failed over from the cluster in order to ensure that each node in the cluster has a similar "balanced" amount of data.

To add servers use the couchbase-server-add1 subcommand. To remove servers specify the list of servers to remove using the --server-remove option in the rebalance subcommand. To failover servers see the couchbase-failover1 subcommand. After running the couchbase-server-add1 or couchbase-failover1 subcommands ensure that you run the rebalance command to ensure data is balance dacross the cluster.

OPTIONS

-c
--cluster

Specfies the hostname of a node in the cluster. See the HOST FORMATS section for more information on specifying a hostname.

-u
--user <username>

Specifies the username of the user executing the command. If you do not have a user account with permision to execute the command then it will fail with an unauthorized error.

-p
--password <password>

Specifies the password of the user executing the command. If you do not have a user account with permision to execute the command then it will fail with an unauthorized error. If this argument is specified, but no password is given then the command will prompt the user for a password through non-echoed stdin. You may also specify your password by using the environment variable CB_REST_PASSWORD.

--server-remove <servers> A comma separated list of servers to remove from the cluster. The each server in the list should correspond to the hostname or IP address of that server.

--no-progress-bar

Disables showing the progress bar which tracks the progress of the rebalance. This command will still wait for rebalance completion even if this flag is specified, but the progress bar will not be shown.

--no-wait

Specifies that this command should not wait for the completion of rebalance before exiting.

HOST FORMATS

When specifying a host for the couchbase-cli command the following formats are expected:

  • couchbase://<addr>

  • <addr>:<port>

  • http://<addr>:<port>

It is recommended to use the couchbase://<addr> format for standard installations. The other two formats allow an option to take a port number which is needed for non-default installations where the admin port has been set up on a port other that 8091.

EXAMPLES

When to rebalance a new node into the cluster we would first add a server using the couchbase-server-add1 command and the we would start the balance with the rebalance command.

$ couchbase-cli server-add -c 192.168.1.5:8091 --username Administrator \
 --password password --server-add 192.168.1.6:8091 \
 --server-add-username Administrator --server-add-password password
$ couchbase-cli rebalance -c 192.168.1.5:8091 --username Administrator \
 --password password

If we just want to remove a server from the cluster and start a rebalance we would just need to run the rebalance command.

$ couchbase-cli rebalance -c 192.168.1.5:8091 --username Administrator \
 --password password --server-remove 192.168.1.6:8091

We could also remove multiple servers at once and run the rebalance with the command below. Note that rebalance will be faster removing multiple servers as once as opposed to removing them one at a time.

$ couchbase-cli rebalance -c 192.168.1.5:8091 --username Administrator \
 --password password --server-remove 192.168.1.6:8091,192.168.1.7:8091

To add a server and remove another server we would again need to invoke the couchbase-server-add1 command before starting the rebalance as shown below.

$ couchbase-cli server-add -c 192.168.1.5:8091 --username Administrator \
 --password password --server-add 192.168.1.6:8091 \
 --server-add-username Administrator --server-add-password password
$ couchbase-cli rebalance -c 192.168.1.5:8091 --username Administrator \
 --password password --server-remove 192.168.1.7:8091

If you add one server to the cluster and remove a server during the same rebalance Couchbase will do a "swap rebalance". This means data from the node being removed is moved to the one being added. This means the rebalance will only occur between two nodes in the cluster as opposed to shifting data around the entire cluster.

ENVIRONMENT AND CONFIGURATION VARIABLES

CB_REST_PASSWORD Specifies the password of the user executing the command. This environment variable allows you to specify a default argument for the -p/--password argument on the command line. It also allows the user to ensure that their password are not cached in their command line history.

CB_REST_PASSWORD Specifies the password of the user executing the command. This environment variable allows you to specify a default argument for the -p/--password argument on the command line.