0
0
MongoDBquery~20 mins

Replica set configuration basics 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!
query_result
intermediate
2:00remaining
Check the primary member of a replica set
Given the following command run on a MongoDB replica set, what is the output field that indicates the current primary member's name?
MongoDB
rs.status()
AThe field 'members' with a subfield 'stateStr' equal to 'PRIMARY' shows the primary member's name.
BThe field 'config' contains the primary member's name.
CThe field 'set' contains the primary member's name.
DThe field 'primary' directly contains the hostname of the primary member.
Attempts:
2 left
💡 Hint
Look for a field that directly names the primary member in the replica set status output.
🧠 Conceptual
intermediate
2:00remaining
Understanding voting members in a replica set
In a MongoDB replica set configuration, what is the maximum number of voting members allowed to ensure proper election and fault tolerance?
A3 voting members maximum
B5 voting members maximum
C7 voting members maximum
D9 voting members maximum
Attempts:
2 left
💡 Hint
MongoDB limits voting members to a certain number to maintain election stability.
📝 Syntax
advanced
2:00remaining
Identify the correct syntax to add a new member to a replica set
Which of the following commands correctly adds a new member with hostname 'mongo3.example.net:27017' to an existing replica set configuration?
MongoDB
var cfg = rs.conf();
cfg.members.push({ _id: 2, host: 'mongo3.example.net:27017' });
rs.reconfig(cfg);
Avar cfg = rs.conf(); cfg.members.push({ _id: 2, host: 'mongo3.example.net:27017' }); rs.reconfig(cfg);
Bvar cfg = rs.status(); cfg.members.push({ _id: 2, host: 'mongo3.example.net:27017' }); rs.reconfig(cfg);
Cvar cfg = rs.conf(); cfg.members.add({ _id: 2, host: 'mongo3.example.net:27017' }); rs.reconfig(cfg);
Dvar cfg = rs.conf(); cfg.push({ _id: 2, host: 'mongo3.example.net:27017' }); rs.reconfig(cfg);
Attempts:
2 left
💡 Hint
Check the method used to get the current config and how to add a member to the members array.
🔧 Debug
advanced
2:00remaining
Diagnose the error when reconfiguring a replica set
A user runs the following commands to add a new member but gets an error: 'reconfig failed: new configuration must have a unique _id for each member'. What is the likely cause?
MongoDB
var cfg = rs.conf();
cfg.members.push({ _id: 1, host: 'mongo3.example.net:27017' });
rs.reconfig(cfg);
AThe rs.reconfig() command must be run with force:true option.
BThe host field is incorrect and must include the replica set name.
CThe configuration object must be cloned before modification.
DThe _id 1 is already used by an existing member, causing a duplicate _id error.
Attempts:
2 left
💡 Hint
Check the uniqueness of the _id field for each member in the config.
🧠 Conceptual
expert
2:00remaining
Understanding priority and elections in replica sets
In a MongoDB replica set, what effect does setting a member's priority to 0 have on elections?
AThe member cannot vote or become primary.
BThe member cannot become primary but can vote in elections.
CThe member becomes the highest priority for primary election.
DThe member is removed from the replica set.
Attempts:
2 left
💡 Hint
Priority controls eligibility to become primary, voting controls election votes.