Docs Menu
Docs Home
/
MongoDB Manual
/ / /

Self-Managed Chained Replication

On this page

  • Disable Chained Replication
  • Re-enable Chained Replication

Starting in version 2.0, MongoDB supports chained replication. A chained replication occurs when a secondary member replicates from another secondary member instead of from the primary. This might be the case, for example, if a secondary selects its replication target based on ping time and if the closest member is another secondary.

Chained replication can reduce load on the primary. But chained replication can also result in increased replication lag, depending on the topology of the network.

You can use the settings.chainingAllowed setting in Self-Managed Replica Set Configuration to disable chained replication for situations where chained replication is causing lag.

MongoDB enables chained replication by default. This procedure describes how to disable it and how to re-enable it.

Note

If chained replication is disabled, you still can use replSetSyncFrom to specify that a secondary replicates from another secondary. But that configuration will last only until the secondary recalculates which member to sync from.

To disable chained replication, set the settings.chainingAllowed field in Self-Managed Replica Set Configuration to false.

You can use the following sequence of commands to set settings.chainingAllowed to false:

  1. Copy the configuration settings into the cfg object:

    cfg = rs.config()
  2. Take note of whether the current configuration settings contain the settings embedded document. If they do, skip this step.

    Warning

    To avoid data loss, skip this step if the configuration settings contain the settings embedded document.

    If the current configuration settings do not contain the settings embedded document, create the embedded document by issuing the following command:

    cfg.settings = { }
  3. Issue the following sequence of commands to set settings.chainingAllowed to false:

    cfg.settings.chainingAllowed = false
    rs.reconfig(cfg)

To re-enable chained replication, set settings.chainingAllowed to true. You can use the following sequence of commands:

cfg = rs.config()
cfg.settings.chainingAllowed = true
rs.reconfig(cfg)

Back

Configure Unavailable Members