0
0
MongoDBquery~10 mins

Replica set configuration basics in MongoDB - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to initiate a replica set with the name 'rs0'.

MongoDB
rs.initiate({ _id: [1], members: [{ _id: 0, host: "localhost:27017" }] })
Drag options to blanks, or click blank then click option'
A"rs0"
B0
C"replicaSet"
Drs0
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to put quotes around the replica set name.
Using a number instead of a string for the replica set name.
2fill in blank
medium

Complete the code to add a second member to the replica set with host 'localhost:27018'.

MongoDB
rs.initiate({ _id: "rs0", members: [{ _id: 0, host: "localhost:27017" }, { _id: [1], host: "localhost:27018" }] })
Drag options to blanks, or click blank then click option'
A1
B"1"
C2
D"2"
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string instead of an integer for _id.
Using a duplicate _id value.
3fill in blank
hard

Fix the error in the code to correctly configure the priority of the first member to 2.

MongoDB
rs.initiate({ _id: "rs0", members: [{ _id: 0, host: "localhost:27017", priority: [1] }] })
Drag options to blanks, or click blank then click option'
A"2"
Bpriority: 2
Ctrue
D2
Attempts:
3 left
💡 Hint
Common Mistakes
Putting quotes around the priority number.
Including the key 'priority:' inside the blank.
4fill in blank
hard

Fill both blanks to configure a hidden member with _id 2 and host 'localhost:27019'.

MongoDB
rs.initiate({ _id: "rs0", members: [{ _id: 0, host: "localhost:27017" }, { _id: 1, host: "localhost:27018" }, { _id: [1], host: [2], hidden: true }] })
Drag options to blanks, or click blank then click option'
A2
B"localhost:27019"
C"localhost:27020"
D3
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong _id number.
Using the wrong host string.
5fill in blank
hard

Fill all three blanks to configure an arbiter with _id 3, host 'localhost:27020', and votes set to 1.

MongoDB
rs.initiate({ _id: "rs0", members: [{ _id: 0, host: "localhost:27017" }, { _id: 1, host: "localhost:27018" }, { _id: 2, host: "localhost:27019", hidden: true }, { _id: [1], host: [2], arbiterOnly: true, votes: [3] }] })
Drag options to blanks, or click blank then click option'
A2
B"localhost:27020"
C1
D3
Attempts:
3 left
💡 Hint
Common Mistakes
Using duplicate _id values.
Setting votes to 0 or forgetting to set votes.