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
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
Explanation: For sharded collections these unique indexes cannot enforce uniqueness because insert and indexing operations are local to each shard.
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
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
Explanation: sh._checkFullName() tests a namespace to determine if its well formed.
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
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
Explanation: The sh._lastMigration() method returns a document with details about the last migration performed on the database or collection.
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
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
Explanation: sh.disableBalancing() does not affect balancing of other collections in a sharded cluster.
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
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
Explanation: sh.getBalancerState() returns true when the balancer is enabled and false if the balancer is disabled.
Sanfoundry Global Education & Learning Series – MongoDB.
Here’s the list of Best Books in MongoDB.
- Practice Programming MCQs
- Apply for Programming Internship
- Check MongoDB Books
- Check Information Technology Books