content_image/732772.jpg
## 9.1.2 Replication in MongoDB 

A replica set is a group of mongod instances that host the same data set. One mongod , the primary, receives all write operations. All other instances, secondaries, apply operations from the primary so that they have the same data set. 

The primary (page 564) accepts all write operations from clients. A replica set can have only one primary. 1 To support replication, the primary records all changes to its data sets in its oplog (page 593). For more information on primary node operation, see Replica Set Primary (page 564). 

<img src='content_image/732772.jpg'>

The secondaries (page 567) replicate the primary’s oplog and apply the operations to their data sets such that the secondaries’ data sets reflect the primary’s data set. If the primary is unavailable, the replica set will elect a secondary to be primary. For more information on secondary members, see Replica Set Secondary Members (page 567). 

You may add an extra mongod instance to a replica set as an arbiter (page 571). Arbiters do not maintain a data set. The purpose of an arbiter is to maintain a quorum in a replica set by responding to heartbeat and election requests by other replica set members. Because they do not store a data set, arbiters can be a good way to provide replica set quorum functionality with a cheaper resource cost than a fully functional replica set member with a data set. If your 

