MongoDB Questions and Answers – Replication Processes – 1

This set of MongoDB Multiple Choice Questions & Answers (MCQs) focuses on “Replication Processes – 1”.

1. Which of the following ddds an arbiter to a replica set?
a) rs.addArb()
b) rs.addArbiter()
c) rs.addtoArb()
d) all of the mentioned
View Answer

Answer: a
Explanation: rs.addArb() adds a new arbiter to an existing replica set.

2. Point out the wrong statement.
a) The rs.status() method is a wrapper that runs the replSetGetStatus database command
b) rs.freeze() provides a wrapper around the database command replSetFreeze
c) rs.init() initializes a new replica set
d) None of the mentioned
View Answer

Answer: c
Explanation: rs.init() initializes a new replica set.

3. _________ prevents the current member from seeking election as primary for a period of time.
a) rs.freeze()
b) rs.conf()
c) rs.printReplicationInfo()
d) secondary
View Answer

Answer: a
Explanation: rs.freeze() makes the current replica set member ineligible to become primary for the period specified.

4. _________ returns the replica set configuration document.
a) rs.freeze()
b) rs.conf()
c) rs.printReplicationInfo()
d) none of the mentioned
View Answer

Answer: b
Explanation: rs.conf() returns a document that contains the current replica set configuration.

advertisement
advertisement

5. Point out the correct statement.
a) rs.printinfo() prints a formatted report of the replica set member’s oplog
b) The output of rs.printReplicationInfo() is identical to that of db.printReplicationInfo()
c) rs.printReplicationInfo() formats and prints the data returned by db.allReplicationInfo()
d) none of the mentioned
View Answer

Answer: b
Explanation: The rs.printReplicationInfo() in the mongo shell does not return JSON.

6. ________ prints a report of the status of the replica set from the perspective of the primary.
a) rs.freeze()
b) rs.printconf()
c) rs.printReplicationInfo()
d) secondary
View Answer

Answer: c
Explanation: Typically you will use db.fsyncUnlock() following a database backup operation.

7. _________ re-configures a replica set by applying a new replica set configuration object.
a) rs.reconfig()
b) rs.remove()
c) rs.stepDown()
d) none of the mentioned
View Answer

Answer: a
Explanation: To reconfigure an existing replica set, first retrieve the current configuration with rs.conf(), modify the configuration document as needed, and then pass the modified document to rs.reconfig().

8. __________ sets the member that this replica set member will sync from, overriding the default sync target selection logic.
a) rs.reconfig()
b) rs.remove()
c) rs.stepDown()
d) rs.syncFrom()
View Answer

Answer: d
Explanation: rs.syncFrom() provides a wrapper around the replSetSyncFrom, which allows administrators to configure the member of a replica set that the current member will pull data from.

advertisement

9. rs.reconfig() provides a wrapper around the ___________ command.
a) replSetfinalReconfig
b) replSetReconfig
c) replSetReconfiguration
d) none of the mentioned
View Answer

Answer: b
Explanation: The force parameter in reconfig method allows a reconfiguration command to be issued to a non-primary node.

10. ________ sets the slaveOk property for the current connection.
a) rs.reconfig()
b) rs.slaveOk()
c) rs.stepDown()
d) rs.slave()
View Answer

Answer: b
Explanation: Use readPref() and Mongo.setReadPref() to set read preference.

advertisement

Sanfoundry Global Education & Learning Series – MongoDB.

Here’s the list of Best Books in MongoDB.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.