Replica Set Primary Member :
- In replica set Primary is the only member that receives write operations.
- In replica set secondary member is to log and apply the operations to their data.
- MongoDB applies write operations and records the operation on primary’s oplog.
- The primary member accepts all write operations in the following three-members replica set.
- The secondary member replicates the primary’s oplog to apply their data sets.
- In replica sets all members can accept to read captions.
- In replica sets, read preference describes how MongoDB clients route read operations to the members.
- An election determines the new primary, If the current primary becomes unavailable.
- Replica setsuse elections to determine which set member will become primary.
- The primary becomes unavailable, in the following 3-member replica set.
- This triggers an election which selects one of the remaining secondaries as the new primary.
Replica set Secondary Member:
- In replica sets secondary maintains a copy of the primary’s data set.
- A secondary applies operations from the primary’s oplog to its own data set in an asynchronous process, to replicate data.
- A replica set can have one or more secondaries.
- In replica sets, the following three-member has two secondary members.
- The secondaries replicate the primary’s oplog and apply the operations to their data sets.
- In replica set client cannot write data, but they can read data from secondary members.
- A secondary can become a primary.
- The replica set holds an election to choose which of the secondaries becomes the new primary, If the current primary becomes unavailable.