A MongoDB replica set is a group of mongod processes that maintain the same data set, providing redundancy and high availability.
Click to reveal answer
beginner
What role does the primary node play in a replica set?
The primary node receives all write operations and replicates data to secondary nodes. It is the main point for data changes.
Click to reveal answer
beginner
How do secondary nodes function in a replica set?
Secondary nodes replicate data from the primary node and can serve read operations if configured. They provide data redundancy.
Click to reveal answer
intermediate
What happens during a primary node failure in a replica set?
The replica set automatically holds an election to select a new primary from the secondary nodes to maintain availability.
Click to reveal answer
intermediate
Why is an arbiter used in a replica set?
An arbiter participates in elections to help choose a primary but does not store data, saving resources while maintaining voting balance.
Click to reveal answer
What is the main responsibility of the primary node in a MongoDB replica set?
AHandle all write operations
BStore backup data only
CServe read operations exclusively
DParticipate in elections without storing data
✗ Incorrect
The primary node handles all write operations and replicates data to secondary nodes.
What does a secondary node do in a replica set?
AOnly votes in elections
BHandles all write operations
CReplicates data from the primary node
DDoes not participate in the replica set
✗ Incorrect
Secondary nodes replicate data from the primary to maintain redundancy.
What triggers an election in a MongoDB replica set?
AManual user command only
BSecondary node failure
CArbiter shutdown
DPrimary node failure
✗ Incorrect
An election is triggered automatically when the primary node fails to select a new primary.
What is the purpose of an arbiter in a replica set?
AParticipate in elections without storing data
BStore data backups
CServe read and write operations
DReplace the primary node
✗ Incorrect
Arbiters help maintain voting balance during elections but do not store data.
Which of the following is NOT true about replica sets?
AThey provide data redundancy
BThey require manual intervention to elect a primary
CThey allow automatic failover
DThey consist of primary and secondary nodes
✗ Incorrect
Replica sets automatically elect a primary without manual intervention.
Explain the roles of primary, secondary, and arbiter nodes in a MongoDB replica set.
Think about who writes data, who copies it, and who helps decide leadership.
You got /3 concepts.
Describe what happens in a replica set when the primary node fails.
Focus on the failover process and how the system stays online.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of a MongoDB replica set?
easy
A. To backup data manually every hour
B. To keep copies of data on multiple servers for safety and availability
C. To store data in different formats on the same server
D. To speed up queries by using multiple CPUs on one server
Solution
Step 1: Understand replica set function
A replica set keeps copies of data on multiple servers to protect against failure.
Step 2: Compare options
Only To keep copies of data on multiple servers for safety and availability describes this purpose correctly; others describe unrelated tasks.
Final Answer:
To keep copies of data on multiple servers for safety and availability -> Option B
Quick Check:
Replica set = data copies on servers [OK]
Hint: Replica sets = multiple copies for safety [OK]
Common Mistakes:
Confusing replica sets with sharding
Thinking replica sets speed up CPU usage
Believing backups are manual in replica sets
2. Which of the following is the correct way MongoDB decides the primary in a replica set?
easy
A. MongoDB automatically elects a primary among members
B. The server with the most data becomes primary
C. The oldest server is always primary
D. The user manually sets the primary server
Solution
Step 1: Recall primary election process
MongoDB automatically elects one server as primary to manage writes.
Step 2: Eliminate incorrect options
Primary is not chosen by data size, age, or manual setting.
Final Answer:
MongoDB automatically elects a primary among members -> Option A
Quick Check:
Primary election = automatic [OK]
Hint: Primary is chosen automatically, not manually [OK]
Common Mistakes:
Assuming user sets primary manually
Thinking data size decides primary
Believing oldest server is primary
3. Consider a replica set with one primary and two secondaries. If the primary goes down, what happens next?
medium
A. All secondaries become primary at the same time
B. The replica set stops working until the original primary returns
C. One of the secondaries is automatically elected as the new primary
D. The data is lost because there is no primary
Solution
Step 1: Understand failover in replica sets
If the primary fails, MongoDB elects a new primary from secondaries automatically.
Step 2: Check other options
Replica sets do not stop working, do not have multiple primaries, and do not lose data immediately.
Final Answer:
One of the secondaries is automatically elected as the new primary -> Option C
Quick Check:
Failover = automatic new primary [OK]
Hint: Primary failure triggers automatic new primary election [OK]
Common Mistakes:
Thinking replica set stops on primary failure
Believing multiple primaries exist simultaneously
Assuming data loss happens immediately
4. You set up a replica set but notice writes are failing. Which of these could be the cause?
medium
A. All members are healthy and synced
B. The replica set has only one member
C. Secondary nodes are accepting writes
D. No primary is elected in the replica set
Solution
Step 1: Identify write requirements in replica sets
Writes must go to the primary; if no primary exists, writes fail.
Step 2: Analyze options
Healthy members or single member replica sets usually allow writes; secondaries do not accept writes.
Final Answer:
No primary is elected in the replica set -> Option D
Quick Check:
Writes need primary elected [OK]
Hint: Writes fail if no primary exists [OK]
Common Mistakes:
Thinking secondaries accept writes
Assuming single member replica set blocks writes
Ignoring primary election status
5. You want to ensure your MongoDB replica set remains available even if two servers fail. What is the minimum number of members you should have in your replica set?
hard
A. 5 members
B. 4 members
C. 3 members
D. 6 members
Solution
Step 1: Understand majority voting in replica sets
Replica sets use majority votes to elect primary; to tolerate 2 failures, majority must be > half of total members.
Step 2: Calculate minimum members
With 5 members, majority is 3; losing 2 still leaves 3 members to form majority and keep primary.
Final Answer:
5 members -> Option A
Quick Check:
To survive 2 failures, need 5 members [OK]
Hint: Majority = more than half; 5 members survive 2 failures [OK]
Common Mistakes:
Choosing 3 or 4 members which can't tolerate 2 failures
Not considering majority voting
Assuming even number members are better
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.