Performing a rebalance

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

The Couchbase Web Console indicates when a cluster requires rebalance. This happens when the structure of the cluster has been changed, either through adding a node, removing a node, or due to a failover. The notification is carried through the servers that require a rebalance. The following figure shows the Manage Server Nodes page.

If Couchbase Server identifies that a rebalance is required (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 and merely indicates that a rebalance operation is required to move the cluster into its configured state. To start a rebalance, click 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.

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

CLI provides an active view of the progress and will 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. It is, therefore, difficult to accurately predict or estimate the duration.

Note: Throughout any rebalance operation, monitor the process to ensure that it completes successfully.

Stop the rebalance operation by using the CLI command stop-rebalance .