4.2. Node Management — Apache CouchDB® 3.2 Documentation

# 4.2. Node Management

## 4.2.1. Adding a node

Go to `http://server1:5984/_membership` to see the name of the node and all the nodes it is connected to and knows about.

    curl -X GET "http://xxx.xxx.xxx.xxx:5984/_membership" --user admin-user

    {
        "all_nodes":[
            "node1@xxx.xxx.xxx.xxx"],
        "cluster_nodes":[
            "node1@xxx.xxx.xxx.xxx"]
    }

- `all_nodes` are all the nodes thats this node knows about.
- `cluster_nodes` are the nodes that are connected to this node.

To add a node simply do:

    curl -X PUT "http://xxx.xxx.xxx.xxx/_node/_local/_nodes/node2@yyy.yyy.yyy.yyy" -d {}

Now look at `http://server1:5984/_membership` again.

    {
        "all_nodes":[
            "node1@xxx.xxx.xxx.xxx",
            "node2@yyy.yyy.yyy.yyy"
        ],
        "cluster_nodes":[
            "node1@xxx.xxx.xxx.xxx",
            "node2@yyy.yyy.yyy.yyy"
        ]
    }

And you have a 2 node cluster :)

`http://yyy.yyy.yyy.yyy:5984/_membership` will show the same thing, so you only have to add a node once.

## 4.2.2. Removing a node

Before you remove a node, make sure that you have moved all shards away from that node.

To remove `node2` from server `yyy.yyy.yyy.yyy`, you need to first know the revision of the document that signifies that node’s existence:

    curl "http://xxx.xxx.xxx.xxx/_node/_local/_nodes/node2@yyy.yyy.yyy.yyy"
    {"_id":"node2@yyy.yyy.yyy.yyy","_rev":"1-967a00dff5e02add41820138abb3284d"}

With that `_rev`, you can now proceed to delete the node document:

    curl -X DELETE "http://xxx.xxx.xxx.xxx/_node/_local/_nodes/node2@yyy.yyy.yyy.yyy?rev=1-967a00dff5e02add41820138abb3284d"