- Reference >
- JavaScript Methods >
- rs.reconfig()
rs.reconfig()¶
-
rs.
reconfig
(configuration[, force])¶ Parameters: - configuration – A document that specifies the configuration of a replica set.
- force – Optional. Specify
{ force: true }
as the force parameter to force 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 rollback situations.
Initializes a new replica set configuration. 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.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:
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:
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
“Replica Set Configuration” and “Replica Set Operation and Management”.