MongoDB Questions and Answers – Sharded Cluster Data Management – 1

«
»

This set of MongoDB Multiple Choice Questions & Answers (MCQs) focuses on “Shared Cluster Data Management – 1”.

1. _______ runs a database command against the admin database of a mongos instance.
a) sh._checkFullName()
b) sh._adminCommand()
c) sh.getBalancerLockDetails()
d) all of the mentioned
View Answer

Answer: b
Explanation: sh._adminCommand() runs a database command against the admin database, like db.runCommand(), but can confirm that it is issued against a mongos.

2. Point out the correct statement.
a) The unique constraint on indexes ensures that only one document can have a value for a field in a collection
b) MongoDB support creating new unique indexes in sharded collections
c) If you use a compound shard key, you cannot enforce uniqueness on the combination of component keys in the shard key
d) All of the mentioned
View Answer

Answer: a
Explanation: For sharded collections these unique indexes cannot enforce uniqueness because insert and indexing operations are local to each shard.

advertisement

3. ________ tests to see if the mongo shell is connected to a mongos instance.
a) sh._checkMongos()
b) sh.addShard()
c) sh._lastMigration()
d) all of the mentioned
View Answer

Answer: a
Explanation: The sh._checkMongos() method throws an error message if the mongo shell is not connected to a mongos instance.

4. _______ reports on the active balancer lock, if it exists.
a) sh._checkFullName()
b) sh._adminCommand()
c) sh.getBalancerLockDetails()
d) all of the mentioned
View Answer

Answer: c
Explanation: sh._checkFullName() tests a namespace to determine if its well formed.

advertisement
advertisement

5. Point out the wrong statement.
a) The best way to ensure a field has unique values is to generate universally unique identifiers (UUID,) such as MongoDB’s ‘ObjectId values
b) Most deployments will not need to shard the files collection
c) The files collection is typically small, and only contains metadata
d) None of the mentioned
View Answer

Answer: d
Explanation: None of the required keys for GridFS lend themselves to an even distribution in a sharded situation.

6. _________ reports on the last chunk migration.
a) sh._checkMongos()
b) sh.addShard()
c) sh._lastMigration()
d) all of the mentioned
View Answer

Answer: c
Explanation: The sh._lastMigration() method returns a document with details about the last migration performed on the database or collection.

advertisement

7. _________ removes an association between a range shard keys and a shard tag.
a) sh.removeTagRange()
b) sh._checkMongos()
c) sh.disableBalancing()
d) none of the mentioned
View Answer

Answer: a
Explanation: Use sh.removeShardTag() to ensure that unused or out of date ranges are removed and hence chunks are balanced as required.

8. _________ disable balancing on a single collection in a sharded database.
a) sh.removeTagRange()
b) sh._checkMongos()
c) sh.disableBalancing()
d) none of the mentioned
View Answer

Answer: c
Explanation: sh.disableBalancing() does not affect balancing of other collections in a sharded cluster.

advertisement

9. _______ activates the sharded collection balancer process if previously disabled using sh.disableBalancing().
a) sh.getBalancerHost()
b) sh.enableBalancing()
c) sh.enableSharding()
d) all of the mentioned
View Answer

Answer: a
Explanation: sh.enableSharding() enables sharding on a specific database.

10. ________ returns a boolean to report if the balancer is currently enabled.
a) sh.getBalancerHost()
b) sh.enableBalancing()
c) sh.getBalancerState()
d) none of the mentioned
View Answer

Answer: c
Explanation: sh.getBalancerState() returns true when the balancer is enabled and false if the balancer is disabled.

advertisement

Sanfoundry Global Education & Learning Series – MongoDB.

Here’s the list of Best Reference Books in MongoDB.

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!
advertisement
advertisement
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn | Youtube | Instagram | Facebook | Twitter