Parameters: |
|
---|
Initializes a newreplica setconfiguration. This function will disconnect the shell briefly and forces a reconnection as the replica set renegotiates which node will beprimary. As a result, the shell will display an error even if this command succeeds.
rs.reconfig()provides a wrapper around the “replSetReconfig”database command.
rs.reconfig()overwrites the existing replica set configuration. Retrieve the current configuration object withrs.conf(), modify the configuration as needed and then users.reconfig()to submit the modified configuration object.
To reconfigure a replica set, use the following sequence of operations:
conf = rs.conf()
// modify conf to change configuration
rs.reconfig(conf)
If you want to force the reconfiguration if a majority of the set isn’t connected to the current member, or you’re issuing the command against a secondary, use the following form:
conf = rs.conf()
// modify conf to change configuration
rs.reconfig(conf, { force: true } )
Warning
Forcing ars.reconfig()can lead torollbacksituations and other difficult to recover from situations. Exercise caution when using this option.这里遇到rollback情况,可能会导致fatal状态,那么replica set就等于失效了,可以拷贝local数据文件,或者所有数据文件进行重建