| 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数据文件,或者所有数据文件进行重建
本文详细介绍了ReplicaSet的配置与管理方法,包括如何调整节点优先级、使用rs.reconfig函数进行重新配置,以及如何加入仲裁节点来增强系统的稳定性和可用性。通过实例演示了如何设置节点优先级、修改配置并验证配置是否正确应用。
5710

被折叠的 条评论
为什么被折叠?



