Performing a rebalance

Rebalancing a cluster involves marking nodes to be added or removed from the cluster and performing the rebalance operation..

A rebalance moves the data around the cluster so that the data is distributed across the entire cluster, removing and adding data to different nodes in the process.

Important: Until you complete a rebalance, avoid using the failover functionality since it may result in loss of data that has not yet been replicated.

In the event of a failover situation, a rebalance is required to bring the cluster back to a healthy state and re-enable the configured replicas.

Rebalancing via UI

To rebalance the cluster, click Rebalance.

The Couchbase web console indicates when the cluster requires a rebalance because the structure of the cluster has been changed, either through adding a node, removing a node, or due to a failover. The notification is through the count of the number of servers that require a rebalance. The following figure shows the Manage Server Nodes page.

If Couchbase Server identifies that a rebalance is required, either through explicit addition or removal, or through a failover, then the cluster is in a Pending Rebalance state. This does not affect the cluster operation, it merely indicates that a rebalance operation is required to move the cluster into its configured state. To start a rebalance:

Rebalancing via CLI

To initiate a rebalance using the couchbase-cli and the rebalance command:


> couchbase-cli rebalance -c 127.0.0.1:8091 -u Administrator -p Password
  INFO: rebalancing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  . . . . . . . . . . .
  SUCCESS: rebalanced cluster

You can also use this method to add and remove nodes and initiate the rebalance operation using a single command. You can specify nodes to be added using the --server-add option, and nodes to be removed using the --server-remove. You can use multiple options of each type. For example, to add two nodes, and remove two nodes, and immediately initiate a rebalance operation:


> couchbase-cli rebalance -c 127.0.0.1:8091 \
          -u Administrator -p Password \
          --server-add=192.168.0.72 \
          --server-add=192.168.0.73 \
          --server-remove=192.168.0.70 \
          --server-remove=192.168.0.69

The command-line provides an active view of the progress and will only return once the rebalance operation has either completed successfully, or in the event of a failure. The time taken for a rebalance operation depends on the number of servers, quantity of data, cluster performance and any existing cluster activity, and is therefore difficult to accurately predict or estimate. Throughout any rebalance operation, monitor the process to ensure that it completes successfully.

Stop the rebalance operation by using the stop-rebalance command to couchbase-cli.