Search:

Search all manuals
Search this manual
Manual
Couchbase Server Manual 1.8
Additional Resources
Community Wiki
Community Forums
Couchbase SDKs
Parent Section
5.3 Rebalancing (Expanding and Shrinking your Cluster)
Chapter Sections
Chapters

5.3.2. Performing a Rebalance

5.3.2.1. Adding a Node to a Cluster
5.3.2.2. Removing a Node from a Cluster
5.3.2.3. Starting a Rebalance

Rebalancing a cluster involves marking nodes to be added or removed from the cluster, and then starting the rebalance operation so that the data is moved around the cluster to reflect the new structure.

The Couchbase Admin Web Console will indicate 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. You can see a sample of this in the figure below, here shown on the Manage Server Nodes page

Figure 5.1. Rebalancing — Servers Pending Rebalance

Rebalancing — Servers Pending Rebalance

To rebalance the cluster, you must initiate the rebalance process, detailed in Section 5.3.2.3, “Starting a Rebalance”.

5.3.2.1. Adding a Node to a Cluster

There are a number of methods available for adding a node to a cluster. The result is the same in each case, the node is marked to be added to the cluster, but the node is not an active member until you have performed a rebalance operation.

The methods are:

  • Web Console — During Installation

    When you are performing the Setup of a new Couchbase Server installation (see Section 2.4, “Setting up Couchbase Server”), you have the option of joining the new node to an existing cluster.

    During the first step, you can select the Join a cluster now radio button, as shown in the figure below:

    Figure 5.2. Rebalancing — Adding new node during setup

    Rebalancing — Adding new node during setup

    You are prompted for three pieces of information:

    • IP Address

      The IP address of any existing node within the cluster you want to join.

    • Username

      The username of the administrator of the target cluster.

    • Password

      The password of the administrator of the target cluster.

    The node will be created as a new cluster, but the pending status of the node within the new cluster will be indicated on the Cluster Overview page, as seen in the example below:

    Figure 5.3. Rebalancing — Node added during setup

    Rebalancing — Node added during setup

  • Web Console — After Installation

    You can add a new node to an existing cluster after installation by clicking the Add Server button within the Manage Server Nodes area of the Admin Console. You can see the button in the figure below.

    Figure 5.4. Rebalancing — Adding new node using the Web Console

    Rebalancing — Adding new node using the Web Console

    You will be presented with a dialog box, as shown below. Couchbase Server should be installed, and should have been configured as per the normal setup procedures. You can also add a server that has previously been part of this or another cluster using this method. The Couchbase Server must be running.

    Figure 5.5. Rebalancing — Adding a new node dialog

    Rebalancing — Adding new node dialog

    You need to fill in the requested information:

    • Server IP Address

      The IP address of the server that you want to add.

    • Username

      The username of the administrator of the target node.

    • Password

      The password of the administrator of the target node.

    You will be provided with a warning notifying you that the operation is destructive on the destination server. Any data currently stored on the server will be deleted, and if the server is currently part of another cluster, it will be removed and marked as failed over in that cluster.

    Once the information has been entered successfully, the node will be marked as ready to added to the cluster, and the servers pending rebalance count will be updated.

  • Using the REST API

    Using the REST API, you can add nodes to the cluster by providing the IP address, administrator username and password as part of the data payload. For example, using curl you could add a new node:

    shell> curl -u cluster-username:cluster-password\
        localhost:8091/controller/addNode \
        -d "hostname=192.168.0.68&user=node-username&password=node-password"

    For more information, see Section 8.8.3, “Adding a Node to a Cluster”.

  • Using the Command-line

    You can use the couchbase-cli command-line tool to add one or more nodes to an existing cluster. The new nodes must have Couchbase Server installed, and Couchbase Server must be running on each node.

    To add, run the command:

    shell> couchbase-cli server-add \
          --cluster=localhost:8091 \
          -u cluster-username -p cluster-password \
          --server-add=192.168.0.72:8091 \
          --server-add-username=node-username \
          --server-add-password=node-password

    Where:

    ParameterDescription
    --clusterThe IP address of a node in the existing cluster.
    -uThe username for the existing cluster.
    -pThe password for the existing cluster.
    --server-addThe IP address of the node to be added to the cluster.
    --server-add-usernameThe username of the node to be added.
    --server-add-passwordThe password of the node to be added.

    If the add process is successful, you will see the following response:

    SUCCESS: server-add 192.168.0.72:8091

    If you receive a failure message, you will be notified of the type of failure.

    Tip

    You can add multiple nodes in one command by supplying multiple --server-add command-line options to the command.

Once a server has been successfully added, the Couchbase Server cluster will indicate that a rebalance is required to complete the operation.

Note

You can cancel the addition of a node to a cluster without having to perform a rebalance operation. Canceling the operation will remove the server from the cluster without having transferred or exchanged any data, since no rebalance operation took place. You can cancel the operation through the web interface.

5.3.2.2. Removing a Node from a Cluster

Removing a node marks the node for removal from the cluster, and will completely disable the node from serving any requests across the cluster. Once removed, a node is no longer part of the cluster in any way and can be switched off, or can be updated or upgraded.

Like adding nodes, there are a number of solutions for removing a node:

  • Web Console

    You can remove a node from the cluster from within the Manage Server Nodes section of the Web Console, as shown in the figure below.

    To remove a node, click the Remove Server button next to the node you want to remove. You will be provided with a warning to confirm that you want to remove the node. Click Remove to mark the node for removal.

  • Using the Command-line

    You cannot mark a node for removal from the command-line without also initiating a rebalance operation. The rebalance command accepts one or more --server-add and/or --server-remove options. This adds or removes the server from the cluster, and immediately initiates a rebalance operation.

    For example, to remove a node during a rebalance operation:

    shell> couchbase-cli rebalance --cluster=127.0.0.1:8091 \
              -u Administrator -p Password \
              --server-remove=192.168.0.73

    For more information on the rebalance operation, see Section 5.3.2.3, “Starting a Rebalance”.

Removing a node does not stop the node from servicing requests. Instead, it only marks the node ready for removal from the cluster. You must perform a rebalance operation to complete the removal process.

5.3.2.3. Starting a Rebalance

Once you have configured the nodes that you want to add or remove from your cluster, you must perform a rebalance operation. This 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.

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 initiate a rebalance operation:

  • Using the Web Console

    Within the Manage Server Nodes area of the Couchbase Administration Web Console, a cluster pending a rebalance operation will have enabled the Rebalance button.

    Figure 5.6. Rebalancing — Starting a Rebalance

    Rebalancing — Starting a Rebalance

    Clicking this button will immediately initiate a rebalance operation. You can monitor the progress of the rebalance operation through the web console. The progress of the movement of vBuckets is provided for each server by showing the movement progress as a percentage.

    Figure 5.7. Rebalancing — Monitoring a Rebalance

    Rebalancing — Monitoring a Rebalance

    You can monitor the progress by viewing the Active vBuckets statistics. This should show the number of active vBuckets on nodes being added increased and the number of vBucketson nodes being removed reducing.

    You can monitor this through the UI by selecting the vBuckets statistic in the Monitoring section of the Administration Web Console.

    Statistics Monitoring during a Rebalance

    You can stop a rebalance operation at any time during the process by clicking the Stop Rebalance button. This only stops the rebalance operation, it does not cancel the operation. You should complete the rebalance operation.

  • Using the Command-line

    You can initiate a rebalance using the couchbase-cli and the rebalance command:

    shell> 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:

    shell> 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.

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

The time taken for a rebalance operation is entirely dependent on the number of servers, quantity of data, cluster performance and any existing cluster activity, and is therefore impossible to accurately predict or estimate.

Throughout any rebalance operation you should monitor the process to ensure that it completes successfully, see Section 5.3.4, “Monitoring During Rebalance”.