Replica Set Members: Primary, Secondary, Arbiter
Learners will describe the role of each replica set member and trace how writes flow from the primary to secondaries via the oplog.
What Is a Replica Set?
A replica set is a group of MongoDB servers that all hold the same data, providing high availability and redundancy. If one server fails, another automatically takes over. A typical replica set has three or more members: at least one primary, one or more secondaries, and optionally an arbiter.
The Primary: Source of Truth
The primary is the only member that accepts write operations. All clients send inserts, updates, and deletes to the primary. It records every write operation in a special log called the oplog (operations log), which secondaries then read to stay in sync.
// Check which member is primary in mongosh
rs.isMaster()
// or
rs.status()All lessons in this course
- Replica Set Members: Primary, Secondary, Arbiter
- Elections and Automatic Failover
- Write Concerns and Acknowledged Durability
- Read Preferences: Distributing Read Load