Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to find the primary node in a MongoDB replica set.
MongoDB
rs.status().members.find(member => member.[1] === 'PRIMARY')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'name' instead of 'stateStr' to identify the primary node.
Confusing 'health' with node role.
✗ Incorrect
The 'stateStr' field indicates the node state, such as 'PRIMARY' or 'SECONDARY'.
2fill in blank
mediumComplete the command to step down the primary node in a MongoDB replica set.
MongoDB
rs.[1]() Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'reconfig' which changes the replica set configuration.
Using 'freeze' which prevents elections temporarily.
✗ Incorrect
The 'stepDown()' command forces the primary to step down and triggers an election.
3fill in blank
hardFix the error in the command to add a secondary node to the replica set.
MongoDB
rs.add('[1]')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Providing only hostname without port.
Providing only port number.
✗ Incorrect
The 'add()' method requires the hostname and port in 'host:port' format.
4fill in blank
hardFill both blanks to create a query that finds all secondary nodes in the replica set.
MongoDB
rs.status().members.filter(member => member.[1] === '[2]')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'name' instead of 'stateStr' for filtering.
Filtering for 'PRIMARY' instead of 'SECONDARY'.
✗ Incorrect
Filtering by 'stateStr' equal to 'SECONDARY' returns all secondary nodes.
5fill in blank
hardFill all three blanks to configure a member as a hidden secondary node in the replica set configuration.
MongoDB
{ _id: [1], host: '[2]', hidden: [3] } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Setting 'hidden' to false for a hidden member.
Omitting the port in the host string.
✗ Incorrect
The member id is 2, host is 'localhost:27019', and 'hidden' must be true to hide the secondary.