0
0
MongoDBquery~20 mins

Replica set architecture mental model in MongoDB - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Replica Set Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Primary role in a MongoDB replica set
In a MongoDB replica set, what is the main responsibility of the primary node?
AIt handles all write operations and replicates data to secondaries.
BIt monitors network traffic but does not store data.
CIt serves read requests exclusively and never accepts writes.
DIt only stores backups and does not handle any client requests.
Attempts:
2 left
💡 Hint
Think about which node accepts changes from users.
query_result
intermediate
2:00remaining
Output of rs.status() command
What key information does the rs.status() command provide in a MongoDB replica set?
AIt displays the network configuration of the replica set members.
BIt shows the current state of each member, including primary or secondary roles.
CIt lists all databases and their sizes on the primary node.
DIt returns the user access permissions for the replica set.
Attempts:
2 left
💡 Hint
Think about what status means for nodes in a set.
📝 Syntax
advanced
2:00remaining
Correct syntax to initiate a replica set
Which of the following commands correctly initiates a MongoDB replica set named 'rs0' with one member?
MongoDB
rs.initiate({ _id: 'rs0', members: [{ _id: 0, host: 'localhost:27017' }] })
AreplicaSet.initiate({ name: 'rs0', members: ['localhost:27017'] })
Brs.start({ id: 'rs0', nodes: [{ id: 0, address: 'localhost:27017' }] })
Crs.create({ _id: 'rs0', members: [{ _id: 0, host: 'localhost:27017' }] })
Drs.initiate({ _id: 'rs0', members: [{ _id: 0, host: 'localhost:27017' }] })
Attempts:
2 left
💡 Hint
Look for the official MongoDB command to start a replica set.
optimization
advanced
2:00remaining
Improving read availability in a replica set
To improve read availability and reduce load on the primary, which configuration is best in a MongoDB replica set?
AEnable read preference to 'secondary' so reads can be served by secondary nodes.
BDisable replication to secondaries to reduce network traffic.
CSet all nodes as primary to allow writes everywhere.
DUse only one node to avoid replication lag.
Attempts:
2 left
💡 Hint
Think about how to distribute read requests safely.
🔧 Debug
expert
3:00remaining
Diagnosing replica set member state
A secondary member in a MongoDB replica set is stuck in the 'RECOVERING' state and not becoming 'SECONDARY'. What is the most likely cause?
AThe secondary has network issues and cannot connect to the client.
BThe primary node is down, so the secondary cannot become primary.
CThe secondary is still syncing data from the primary and has not caught up yet.
DThe replica set name is incorrect on the secondary configuration.
Attempts:
2 left
💡 Hint
Consider what 'RECOVERING' means for a secondary node.