- Reference >
mongo
Shell Methods >- Replication Methods >
- rs.reconfig()
rs.reconfig()¶
On this page
Definition¶
-
rs.
reconfig
(configuration, force)¶ Initializes a new replica set configuration. Disconnects the shell briefly and forces a reconnection as the replica set renegotiates which member will be primary. As a result, the shell will display an error even if this command succeeds.
Parameter Type Description configuration
document A document that specifies the configuration of a replica set. force
document Optional. “If set as { force: true }
, this forces the replica set to accept the new configuration even if a majority of the members are not accessible. Use with caution, as this can lead to term:rollback situations.”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.rs.reconfig()
provides a wrapper around the “replSetReconfig
” database command.
Examples¶
To reconfigure a replica set, use the following sequence of operations:
If you want to force the reconfiguration if a majority of the set is not connected to the current member, or you are issuing the command against a secondary, use the following form:
Warning
Forcing a rs.reconfig()
can lead to rollback
situations and other difficult to recover from situations. Exercise
caution when using this option.
See also