A follower node is a secondary member of a MongoDB replica set. The primary accepts writes; a secondary keeps a replica of the data and can serve configured read operations. A secondary is also eligible to vote in a primary election. Unlike a secondary, an arbiter can vote but does not store a data replica. section 9.1.1
Replication runs through the oplog, an ordered history of logical writes. The primary records successful, data-changing operations and streams them to secondaries. Each secondary applies those operations asynchronously and maintains its own copy of local.oplog.rs. Because application is asynchronous, check replication lag rather than assuming a secondary is current. section 9.1.3
Inspect a secondary in mongosh:
- Run rs.status() or db.adminCommand("replSetGetStatus") to identify members whose state is SECONDARY. State 2 means the member is replicating; states such as STARTUP2 and ROLLBACK indicate different conditions. section 9.1.1
- Run db.printSecondaryReplicationInfo() to inspect each reported member’s syncedTo time and replLag relative to the primary. section 9.1.3
- For member configuration, use rs.config() or db.adminCommand("replSetGetConfig") to inspect fields such as hidden, priority, and votes. The latter command is noted as available only on M10 clusters and larger. section 9.1.1
Listing 9.1 Output of the replSetGetStatus command
db.adminCommand("replSetGetStatus").members.map((m) =>
➥({ _id: m._id, name: m.name, state: m.state, stateStr: m.stateStr }))
[
{
_id: 0,
name: 'ac-5dhjxpf-shard-00-00.fpomkke.mongodb.net:27017'
state: 2,
stateStr: 'SECONDARY'
},
{
_id: 1,
name: 'ac-5dhjxpf-shard-00-01.fpomkke.mongodb.net:27017'
state: 1,
stateStr: 'PRIMARY'
},
{
_id: 2,
name: 'ac-5dhjxpf-shard-00-02.fpomkke.mongodb.net:27017'
state: 2,
stateStr: 'SECONDARY'
}
]
The status output shows one PRIMARY and two members in state 2, SECONDARY; use the state alongside the member name to identify each follower. section 9.1.1
Listing 9.6 Output of the db.printSecondaryReplicationInfo() command
db.printSecondaryReplicationInfo()
source: ac-5dhjxpf-shard-00-00.fpomkke.mongodb.net:27017
{
syncedTo: 'Wed Mar 27 2024 18:21:52 GMT+0000
➥(Coordinated Universal Time)',
replLag: '0 secs (0 hrs) behind the primary '
}
---
source: ac-5dhjxpf-shard-00-01.fpomkke.mongodb.net:27017
{
syncedTo: 'Wed Mar 27 2024 18:21:53 GMT+0000
➥(Coordinated Universal Time)',
replLag: '10 secs (0 hrs) behind the primary '
}
The replication report shows syncedTo timestamps and lag values, including a member reported as 10 seconds behind the primary. section 9.1.3


