One, using Rs.reconfig, to add, delete nodes
1, add nodes
repmore:primary> config = {_id: "Repmore", Members:[{_id:0,host: ' 127.0.0.1:27017 ', Priority:2},{_id:1,host: ' 127.0.0.1:27018 ', priority:1}]}; Add node
repmore:primary> rs.reconfig (config); Make configuration effective
repmore:primary> rs.status (); View node Status
Node added successfully.
Note: The Replset of the new node will be the same as the other nodes
2, delete the node
repmore:primary> config = {_id: "Repmore", Members:[{_id:0,host: ' 127.0.0.1:27017 ', Priority:2}]}; Delete node
repmore:primary> rs.reconfig (config); Make configuration effective
repmore:primary> rs.status (); View node Status
Second, use Rs.add and rs.remove to add delete nodes
Repmore:primary> Rs.add ("127.0.0.1:27018"); Add node
repmore:primary> rs.remove ("127.0.0.1:27018");//Delete section
Note: Using Rs.add and Rs.remove is not a rs.reconfig to use the configuration to take effect.