发布于 2015-09-14 14:58:09 | 238 次阅读 | 评论: 0 | 来源: 网络整理
Specify one of the following forms:
参数: |
|
---|
Provides a simple method to add a member to an existing replica set. You can specify new hosts in one of two ways:
This function will disconnect the shell briefly and forces a reconnection as the replica set renegotiates which node will be primary. As a result, the shell will display an error even if this command succeeds.
rs.add() provides a wrapper around some of the functionality of the “replSetReconfig” database command and the corresponding shell helper rs.reconfig(). See the 副本集配置 document for full documentation of all replica set configuration options.
Example
To add a mongod accessible on the default port 27017 running on the host mongodb3.example.net, use the following rs.add() invocation:
rs.add('mongodb3.example.net:27017')
If mongodb3.example.net is an arbiter, use the following form:
rs.add('mongodb3.example.net:27017', true)
To add mongodb3.example.net as a secondary-only member of set, use the following form of rs.add():
rs.add( { "host": "mongodbd3.example.net:27017", "priority": 0 } )