12.2. Node Management

12.2.1. Adding a node

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

  1. curl -X GET "http://xxx.xxx.xxx.xxx:5984/_membership" --user admin-user
  1. {
  2. "all_nodes":[
  3. "node1@xxx.xxx.xxx.xxx"],
  4. "cluster_nodes":[
  5. "node1@xxx.xxx.xxx.xxx"]
  6. }
  • 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:
  1. curl -X PUT "http://xxx.xxx.xxx.xxx:5986/_nodes/node2@yyy.yyy.yyy.yyy" -d {}

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

  1. {
  2. "all_nodes":[
  3. "node1@xxx.xxx.xxx.xxx",
  4. "node2@yyy.yyy.yyy.yyy"
  5. ],
  6. "cluster_nodes":[
  7. "node1@xxx.xxx.xxx.xxx",
  8. "node2@yyy.yyy.yyy.yyy"
  9. ]
  10. }

And you have a 2 node cluster :)

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

12.2.2. Removing a node

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

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

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

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

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

原文: http://docs.couchdb.org/en/stable/cluster/nodes.html