Adding nodes

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. Nodes can be added to a cluster via the UI, CLI, or REST API.

When you are performing the Setup of a new Couchbase Server installation, 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:

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:

Adding nodes via UI

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.

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.

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 be added to the cluster, and the servers pending rebalance count will be updated.

Adding nodes via REST

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


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

Adding nodes via CLI

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:

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

Parameter Description
--cluster The IP address of a node in the existing cluster.
-u The username for the existing cluster.
-p The password for the existing cluster.
--server-add The IP address of the node to be added to the cluster.
--server-add-username The username of the node to be added.
--server-add-password The 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.

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

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

You can cancel the addition of a node to a cluster without having to perform a rebalance operation. Canceling the operation removes 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.