In a MongoDB replica set, what is the main responsibility of the primary node?
Think about which node accepts changes and shares them with others.
The primary node is the only node that accepts write operations. It then replicates these changes to secondary nodes to keep data consistent.
Given the output of rs.status() command in MongoDB, which field indicates the primary node?
rs.status()
Look for the status string that explicitly says which node is primary.
The stateStr field shows the role of each member. The primary node is marked with "PRIMARY".
Which MongoDB shell command correctly forces the current primary node to step down and triggers an election?
Check the exact spelling and camel case of the command.
The correct command is rs.stepDown() with capital D and no underscores.
You want to distribute read operations to secondary nodes to reduce load on the primary. Which read preference setting achieves this in MongoDB?
Think about a setting that prefers secondaries but falls back to primary if needed.
The "secondaryPreferred" read preference directs reads to secondary nodes but uses primary if no secondary is available.
A MongoDB replica set has three nodes: one primary and two secondaries. Suddenly, the primary becomes unreachable. However, no new primary is elected. What is the most likely cause?
Consider how MongoDB decides to elect a new primary based on node availability.
MongoDB requires a majority of nodes to be available to elect a new primary. If the primary is down and only one secondary is reachable, no majority exists, so no election occurs.