ਇੱਕ replica set MongoDB servers ਦਾ ਇੱਕ ਗਰੁੱਪ ਹੈ ਜੋ ਇੱਕੋ ਜਿਹਾ ਡਾਟਾ ਨੂੰ ਬਰਕਰਾਰ ਰੱਖਦਾ ਹੈ — high availability (automatic failover) ਅਤੇ redundancy ਪ੍ਰਦਾਨ ਕਰਦਾ ਹੈ। ਇੱਕ ਨੋਡ primary ਹੁੰਦਾ ਹੈ (writes ਨੂੰ ਹੈਂਡਲ ਕਰਦਾ ਹੈ), ਬਾਕੀ secondaries ਹੁੰਦੇ ਹਨ (primary ਦੇ ਡਾਟੇ ਨੂੰ replicate ਕਰਦੇ ਹਨ ਅਤੇ reads serve ਕਰ ਸਕਦੇ ਹਨ)। ਇਹ reliability ਲਈ MongoDB ਦਾ standard mechanism ਹੈ।
The replica set structure
PRIMARY (1) → receives all WRITES; replicates changes to secondaries
SECONDARIES (2+) → copy the primary's data (via the oplog); can serve READS
ARBITER (optional) → votes in elections but holds no data (for odd vote counts)
Write → Primary → replicated to Secondaries (via the operations log "oplog")
