Docs HomeMongoDB Manual

Replication Reference

Replication Methods in mongosh

NameDescription
rs.add()Adds a member to a replica set.
rs.addArb()Adds an arbiter to a replica set.
rs.conf()Returns the replica set configuration document.
rs.freeze()Prevents the current member from seeking election as primary for a period of time.
rs.help()Returns basic help text for replica set functions.
rs.initiate()Initializes a new replica set.
rs.printReplicationInfo()Prints a formatted report of the replica set status from the perspective of the primary.
rs.printSecondaryReplicationInfo()Prints a formatted report of the replica set status from the perspective of the secondaries.
rs.printSlaveReplicationInfo()Deprecated since version 4.4.1: Use rs.printSecondaryReplicationInfo() instead.
rs.reconfig()Re-configures a replica set by applying a new replica set configuration object.
rs.remove()Remove a member from a replica set.
rs.status()Returns a document with information about the state of the replica set.
rs.stepDown()Causes the current primary to become a secondary which forces an election.
rs.syncFrom()Sets the member that this replica set member will sync from, overriding the default sync target selection logic.

Replication Database Commands

NameDescription
applyOpsInternal command that applies oplog entries to the current data set.
helloDisplays information about this member's role in the replica set, including whether it is the primary.
replSetAbortPrimaryCatchUpForces the elected primary to abort sync (catch up) then complete the transition to primary.
replSetFreezePrevents the current member from seeking election as primary for a period of time.
replSetGetConfigReturns the replica set's configuration object.
replSetGetStatusReturns a document that reports on the status of the replica set.
replSetInitiateInitializes a new replica set.
replSetMaintenanceEnables or disables a maintenance mode, which puts a secondary node in a RECOVERING state.
replSetReconfigApplies a new configuration to an existing replica set.
replSetResizeOplogDynamically resizes the oplog for a replica set member. Available for WiredTiger storage engine only.
replSetStepDownForces the current primary to step down and become a secondary, forcing an election.
replSetSyncFromExplicitly override the default logic for selecting a member to replicate from.

Replica Set Reference Documentation

Replica Set Configuration
Complete documentation of the replica set configuration object returned by rs.conf().
Replica Set Protocol Version
Reference on the replica set protocol version.
Troubleshoot Replica Sets
Replica set trouble shooting guide.
The local Database
Complete documentation of the content of the local database that mongod instances use to support replication.
Replica Set Member States
Reference for the replica set member states.