0
0
MongoDBquery~10 mins

Chunks and balancer concept 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 list all chunks in a sharded collection.

MongoDB
db.getSiblingDB('config').chunks.find({ 'ns': [1] })
Drag options to blanks, or click blank then click option'
A'chunks'
B'mydb'
C'mydb.mycollection'
D'config.chunks'
Attempts:
3 left
💡 Hint
Common Mistakes
Using only the database name instead of the full namespace.
Using the collection name alone without the database prefix.
2fill in blank
medium

Complete the command to enable the balancer in MongoDB.

MongoDB
sh.setBalancerState([1])
Drag options to blanks, or click blank then click option'
A0
Btrue
C1
Dfalse
Attempts:
3 left
💡 Hint
Common Mistakes
Passing 1 or 0 instead of true or false.
Using quotes around true or false.
3fill in blank
hard

Fix the error in the command to get the current balancer status.

MongoDB
sh.[1]()
Drag options to blanks, or click blank then click option'
AgetBalancerState
BbalancerStatus
CgetBalancerStatus
DbalancerState
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'balancerStatus' or 'getBalancerStatus' which are not valid methods.
Using 'balancerState' without 'get'.
4fill in blank
hard

Fill both blanks to create a query that finds chunks with a max key greater than 100.

MongoDB
db.getSiblingDB('config').chunks.find({ 'max.[1]': { [2]: 100 } })
Drag options to blanks, or click blank then click option'
AshardKey
B$gt
C$lt
DminKey
Attempts:
3 left
💡 Hint
Common Mistakes
Using '$lt' instead of '$gt' for greater than.
Using 'minKey' instead of the shard key field.
5fill in blank
hard

Fill all four blanks to create a command that moves a chunk to a specific shard.

MongoDB
sh.moveChunk('[1]', { '[2]': [3] }, '[4]')
Drag options to blanks, or click blank then click option'
Amydb.mycollection
BshardKey
C100
Dshard0001
Attempts:
3 left
💡 Hint
Common Mistakes
Using only the collection name for namespace.
Using the wrong shard key field name.
Using a string instead of a number for the shard key value.