教土豆学计算机
MongoDB’s replication facility, provides
automatic fail-over
data redundancy
A replica set is a group of mongod instances that maintain the same data set.
Replica sets rely on two basic mechanisms: an oplog and a heartbeat.
The oplog enables the replication of data, and
the heartbeat monitor health and triggers fail-over.
The oplog is a capped collection that lives in a database called local on every replicating node and records all changes to the data.
Each oplog entry is identified with a BSON timestamp, and all secondaries use the timestamp to keep track of the latest entry they’ve applied.
Replica sets use elections to determine which set member will become primary. Elections occur after initiating a replica set, and also any time the primary become unavailable.
The primary is the only member in the set that can accept write operations.