Navigation
This version of the documentation is archived and no longer supported.

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 with rs.conf(), modify the configuration as needed and then use rs.reconfig() to submit the modified configuration object.

rs.reconfig() provides a wrapper around the “replSetReconfigdatabase command.

Examples

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 is not connected to the current member, or you are 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 a rs.reconfig() can lead to rollback situations and other difficult to recover from situations. Exercise caution when using this option.

←   rs.initiate() rs.remove()  →