0% found this document useful (0 votes)
40 views65 pages

MongoDB University - PreExamDBA3

Uploaded by

A Nguyen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views65 pages

MongoDB University - PreExamDBA3

Uploaded by

A Nguyen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 65

28/10/2019 MongoDB University

Practice Certification Exam


Your Grade
MongoDB DBA Exam
PASS/FAIL
Submitted

Exam Overview

SECTION CORRECT INCORRECT TOTAL

Philosophy & Features 2 1 3

CRUD 4 1 5

Indexes 8 3 11

Server Administration 10 1 11

Application Administration 8 2 10

Replication 9 1 10

Sharding 9 1 10

Philosophy & Features

Question 1

Problem: Incorrect Answer Hide Details

Which of the following improves read performance in MongoDB?

Using keyfile authentication

Indexes

A write concern of w: 2
https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 1/65
28/10/2019 MongoDB University

Detailed Answer

Incorrect Options:

A write concern of w: 2

A write concern of w: 2 only impacts the acknowledgement of a write sent


back to the client. It has no impact on read or write performance.

Using keyfile authentication

This secures the network between replica set nodes, but will not improve
read performance.

Correct Option:

Indexes

Indexes are special data structures in MongoDB that allow ordered


access of data and prevent collection scans, thus improving read
performance.

Question 2

Problem: Correct Answer Hide Details

What information can be obtained from running rs.serverStatus()['repl']


on a secondary replica set node?

whether the node is a primary or a secondary

the name, port and IP of the primary node

replica set name

Detailed Answer

https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 2/65
28/10/2019 MongoDB University

All answers are correct.

rs.serverStatus()['repl'] provides information aboout the categories


listed and more, such as the status of the replica set and its members. This
particular command's output is almost identical to the rs.isMaster command
except that it includes the rbid field.

Question 3

Problem: Correct Answer Hide Details

Consider the following aggregation pipeline:

COPY

use services

db.restaurants.aggregate([
{
"$sort" : {"rating" : -1}
},
{
"$match": {
"reviews": { "$gte": 5 }
}
}
])

What optimizations will the optimizer make to the stages?

the sort order will be reversed to the direction of the shard key

the $match stage will be moved to before the $sort stage

the result set will be limited to reduce network latency

Detailed Answer
https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 3/65
28/10/2019 MongoDB University

The optimizer will re-order the match stage to before the sort.

CRUD

Question 1

Problem: Correct Answer Hide Details

The $geoWithin operator finds:

documents that partially overlap with a GeoJson Polygon

documents that completely overlap with a GeoJson Polygon

documents within a GeoJson Polygon

Detailed Answer

Incorrect Answer:

finds document that partially overlap a GeoJson Polygon

This option is incorrect. The $geoWithin returns documents within a


GeoJson Polygon, or Multi-Polygon, therefore all documents need to be
within the boundaries defined by the given GeoJson.

Correct Answers:

finds documents within a GeoJson Polygon

finds documents that completely overlap a GeoJson Polygon

All document coordinates are required to be within the defined GeoJson


Polygon or Multi-Polygon therefore all documents need to completely
overlap in their defined geometry.

$geoWithin

https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 4/65
28/10/2019 MongoDB University

Question 2

Problem: Correct Answer Hide Details

Consider the following documents in collection employees:

COPY

db.employees.find().sort({ "$natural": 1 }).pretty()

{
_id: 1,
name: "Joe",
last: "Doe"
}
{
_id: 2,
name: "Jane",
last: "Doe"
}
{
_id: 3,
name: "Jeff",
last: "Doe"
}

Which of the following documents will be replaced as result of this replaceOne


operation:

COPY

db.employees.replaceOne(
{ "last": "Doe" },
{ "_id": 10, "name": { "first": "Walter", "last":
"Doe" } }
)

{
_id: 1,
name: "Joe",
https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 5/65
28/10/2019 MongoDB University
name: Joe ,
last: "Doe"
}

{
_id: 2,
name: "Jane",
last: "Doe"
}

{
_id: 3,
name: "Jeff",
last: "Doe"
}

{
_id: 4,
name: "Walter",
last: "Doe"
}

{
_id: 10,
name: "Walter",
last: "Doe"
}

https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 6/65
28/10/2019 MongoDB University

Detailed Answer

Incorrect Answers:

COPY

{
_id: 2,

name: "Jane",
last: "Doe"
}

This document will not be replaced because it is the second document to be


found by in the server. replaceOne will replace the first document found that
matches the query selector. Sorting the results by $natural provides the order
by which documents are selected without an explicit sort order.

COPY

{
_id: 3,
name: "Jeff",
last: "Doe"
}

This document will not be replaced because this is the third document to be
found by in the server. replaceOne will replace the first document found that
matches the query selector. Sorting the results by $natural provides the order
by which documents are selected without an explicit sort order.

COPY

{
_id: 4,
name: "Walter",
last: "Doe"
}

This document will not be replaced because it would not be found in the server
when executing replaceOne.

CO
https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 7/65
28/10/2019 MongoDB University
COPY

{
_id: 10,
name: "Walter",
last: "Doe"
}

This document will not be replaced because it would not be found in the server
when executing replaceOne.

Correct Answer:

COPY

{
_id: 1,
name: "Joe",
last: "Doe"
}

This would be the first document to be returned by the query filter {last:
"Doe"} therefore the document to be replaced.

Question 3

Problem: Incorrect Answer Hide Details

Consider the following statement:

COPY

db.employees.update({
"employee_id": 1244
}, {
$set: {
"employee_id": 1244,
"name": "Brad Pitt",
"salary_USD": 1200000
}
} {
https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 8/65
28/10/2019 MongoDB University
}, {
upsert: true
})

Assume that none of the documents in the employees collection have an


employee_id of 1244. What is the outcome of this operation?

The operation will return an error because there is no matching


document.

The operation will return an error because of a syntax error.

The operation will insert a new document with _id equal to 1244.

The operation will not return an error, but the data in employees will
not change.

The operation will insert a new document with an auto-generated _id.

Detailed Answer

Correct Answer

The operation will insert a new document with a new ``_id``*.*

This operation used the flag { upsert: true }, which performs an insert if
the matching document is not found. Because no document exists matching {
employee_id: 1244 }, the entire newEmployee document will be inserted as
a new document.

This document has a new _id, because there was no _id in the document
specified in the $set expression (employee_id does not count as _id).

Question 4

Problem: Correct Answer Hide Details


https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 9/65
28/10/2019 MongoDB University
Problem: Correct Answer Hide Details

Consider the following operation:

db.movies.find( { genre: "Action" }, { year:


COPY

Which fields should we expect to exist in result documents?

year

genre

_id

Detailed Answer

Correct Answers

year, _id

The year field was specified in the projection, and the _id field is returned by
default.

Incorrect Answers

genre

Because the field year was the only field specified in the projection, all other
fields (except _id) will be suppressed from result documents.

Question 5

Problem: Correct Answer Hide Details

When multiple documents match the filter used as an argument in deleteOne,


which document will be deleted from the collection?

https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 10/65
28/10/2019 MongoDB University

the first document that matches the filter in sorted order by ObjectId

a random document that matches the filter parameter

the last document that matches the filter in sorted order by ObjectId

the last document that matches the filter

the first document that matches the filter

Detailed Answer

When using deleteOne, the first document that matches the filter will be deleted.
If you want to delete the first document returned in the collection, you can
specify an empty document as a parameter.

The correct answer is

the first document that matches the filter

All other choices are incorrect.

Indexes

Question 1

Problem: Correct Answer Hide Details

Given the following query:

COPY

db.songs.find(
{ "seconds": { "$lt": 400 }, "genre": "rock" }
).sort(
{ "rating": 1 }
https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 11/65
28/10/2019 MongoDB University

Which index on the songs collection will be the most performant for the above
query?

{"genre": 1, "rating": 1, "seconds": 1}

{"genre": 1, "seconds": 1, "rating": 1}

{"seconds": 1, "genre": 1, "rating": 1}

{"rating": 1, "genre": 1, "seconds": 1}

{"rating": 1, "seconds": 1, "genre": 1}

Detailed Answer

The correct answer is

{"genre": 1, "rating": 1, "seconds": 1}

Making the following answers incorrect

{"genre": 1, "seconds": 1, "rating": 1}


{"rating": 1, "genre": 1, "seconds": 1}
{"rating": 1, "seconds": 1, "genre": 1}
{"seconds": 1, "genre": 1, "rating": 1}

The most efficient index for the given query should follow the equality, sort,
range rule, where the compound index is built in this order for a query that
employs equality, range and sort conditions in it. This rule helps to avoid
inefficient operations such as a full collection scan or in memory sort.

Question 2

Problem: Incorrect Answer Hide Details


https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 12/65
28/10/2019 MongoDB University

When creating an index on a field with values of varying data types, how will the
values be sorted in this index?

only ordered by data type

first ordered by data type, then by value

an index can not have different data types

first ordered by value then by data type

only ordered by value

Detailed Answer

Correct Answer:

first ordered by datatype, then by value

The indexed values are grouped based on the data type representation first, that
way if we are traversing the tree, we can go directly to that branch of the tree
and get results in a more streamlined fashion

Incorrect Answers:

first ordered by value then by datatype


only ordered by value
only ordered by datatype
the index is not stored as a b-tree

Question 3

Problem: Correct Answer Hide Details

https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 13/65
28/10/2019 MongoDB University

Given a replica set and the following set of commands run from the secondary
node (port 27003, node name: r3) of the replica set:

COPY

use admin
db.shutdownServer()

What will be the result of the following shell command?

mongod --port 27003 --dbpath /data/r3 --logp


COPY

r3 will get started and become part of the replica set again

r3 will become the primary node of the replica set

r3 will be run as a standalone node

this command is invalid

this will restart the replica set with an additional node called r3

Detailed Answer

The correct answer is

r3 will be run as a standalone node

This is because the command did not include the --replSet option, even
though all other configurations stayed the same. All other answers are incorrect.

Question 4

Problem: Correct Answer Hide Details


https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 14/65
28/10/2019 MongoDB University
ob e Co ect s e de eta s

Consider the following index in the computers collection:

{ processor: 1, price: 1, memoryGB: -1 } COPY

Which of the following queries could use this index for filtering and sorting?

db.computers.find( { processor: "i9", price: {


$lt: 2000 } } )
.sort( { memoryGB: -1 } )

db.computers.find( { price: { $lt: 1500 } } )


.sort( { memoryGB: -1 } )

db.computers.find( { processor: "i7" } )


.sort( { price: 1 } )

Detailed Answer

Correct Answers:

COPY

db.computers.find( { processor: "i9", price: { $lt:


2000 } } )
.sort( { memoryGB: -1 } )

This answer is correct because the processor, price, and memoryGB form an
index prefix.

COPY

db.computers.find( { processor: "i7" } )


.sort( { price: 1 } )
https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 15/65
28/10/2019 MongoDB University

This answer is correct because the processor and price form an index prefix.

Incorrect Answer:

COPY

db.computers.find( { price: { $lt: 1500 } } )

.sort( { memoryGB: -1 } )
This answer is incorrect because the price and memoryGB do NOT form an
index prefix.

Question 5

Problem: Correct Answer Hide Details

Given the following query:

COPY

db.animals.find(
{},
{ "_id": 0, "species": 1, "name": 1,
"number_of_chromosomes": 1 }
).sort(
{ "number_of_chromosomes": -1 }
)

and the following index:

{ "number_of_chromosomes": 1 } COPY

How will the data get retrieved, and why?

index scan in descending order without the need to sort

in-memory sort after the data is retrieved from the collection

https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 16/65
28/10/2019 MongoDB University

index scan followed by a sort, because the index is built in ascending


order

Detailed Answer

Correct answer:

index scan in descending order without the need to sort

This is because when we are sorting with a single field index, we can always sort
our documents either in ascending or descending order regardless of the
physical ordering of the index keys.

Question 6

Problem: Correct Answer Hide Details

Consider the following index in the plants collection:

{ climate: 1 } COPY

Which of the following queries could use this index?

db.plants.find({ type: { $in: [ "succulent", "moss" ]


} })

db.plants.find({ climate: { $in: [ "marsh", "swamp" ]


} })

db.plants.find({ type: "conifer", climate: "forest" })

Detailed Answer

Correct Answers:
https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 17/65
28/10/2019 MongoDB University

db.plants.find({ climate: { $in: [ "marsh", "swamp" ] } })

db.plants.find({ type: "conifer", climate: "forest" })

These queries can use the index, because the query selector filters on
the "climate" field.

Incorrect Answer:

db.plants.find({ type: { $in: [ "succulent", "moss" ] } })

These queries can NOT use the index, because the query selector
does not filter on the "climate" field.

Question 7

Problem: Correct Answer Hide Details

Select the appropriate option(s) below that should always be kept in mind
regarding indexes:

Indexes are data structures that require additional resources as they


grow

Indexes are part of the database "working set"

Indexes should be taken into consideration for sizing and maintenance

Detailed Answer

All answers are correct. Indexes are critical for increased performance, but they
aren't free and must be considered when determining disk and memory
requirements for a deployment machine.

Question 8

https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 18/65
28/10/2019 MongoDB University

Problem: Correct Answer Hide Details

Given the following commands run in the mongo shell:

COPY

db.createCollection(

"signs",
{ "collation": { "locale": "fr" } }
)

db.signs.createIndex(
{ "sign_text": 1 },
{ "collation": { "locale": "es" } }
)

db.signs.find(
{ "sign_text": "Bonjour Québec" },
{ "collation": { "locale": "en" } }
)

Which behavior are you going to observe?

matching documents using no locale

matching documents using the locales "fr" and "es"

matching documents using the locale "en"

mongod will throw an error

matching documents using the locale "fr"

Detailed Answer

Correct Option:
https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 19/65
28/10/2019 MongoDB University

mongod will throw an error

Because the locale asked is not available, the mongod process will thrown
an error.

The find command could have used "fr", "fr_CA" or no locale, however it
can not use a locale that is not associated with the collection or its indexes.

Incorrect Options:

matching documents using the locale "fr"

find would have had to be used { "collation": { "locale": "fr"


}

matching documents using the locale "fr_CA"

find would have had to be used { "collation": { "locale":


"fr_CA" }

matching documents using the locale "fr" and "fr_CA"

The server can not use 2 locales together for a given query, only one.

matching documents using no locale

Because there is a locale at the collection level, it will always be used as


the default locale if no explicit locale is specified.

Question 9

Problem: Correct Answer Hide Details

What is the default mode when using explain to analyze a query?

allPlansExecution

executionStats

queryPlanner

https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 20/65
28/10/2019 MongoDB University

Detailed Answer

The correct answer is queryPlanner. This is to allow immediate use on a server


that may already be under heavy load to help the administrator determine if a
query would have used an index without impacting other operations more heavily.

Question 10

Problem: Incorrect Answer Hide Details

Your company operates a very popular movie review and recommendation site.
Queries for movie recommendations are becoming unacceptably slow. 90% of
queries are for movies with a viewer rating above 7 on a 1-10 scale. What type of
index is most appropriate to help speed up these queries?

text

partial

hashed

sparse

multi-key

Detailed Answer

The correct answer is partial. Partial indexes are especially useful when we want
to index a subset of our data, typically the most accessed portion.

Question 11

Problem: Incorrect Answer Hide Details


https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 21/65
28/10/2019 MongoDB University

You issue the following query against our database:

db.inventory.find( { "qty": { "$gte": 20 } }


COPY

Which of the following commands will create an index that will cover the query?

db.records.createIndex( { "qty": "sorted" } )

db.records.createIndex( { "qty": 1 } )

db.records.createIndex( { "qty": "$range" } )

Detailed Answer

Correct Option

db.records.createIndex( { "qty": 1 } )

This will create an index on the "qty" field, which will cover the range
query.

Incorrect Options:

db.records.createIndex( { "qty": $range } )

You cannot specify an aggregation operator when creating an index. The


$range operator returns an array whose elements are a generated
sequence of numbers.

db.records.createIndex( { "qty": sorted } )

Sorted is not an option you can pass to an index. Indexes are already
sorted, you can specify the direction of the sort using 1 or -1 when
creating the index.

Server Administration
https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 22/65
Server Administration
28/10/2019 MongoDB University

Question 1

Problem: Incorrect Answer Hide Details

Which of the following would not be found in the combined results of explain()
commands run on every shard?

list of stages ran on the mongos

execution time of each stage on each shard

number of documents read on every shard

name of the index, or lack of it, chosen on each shard

the complete list of available indexes on each shard

Detailed Answer

Correct Option:

the complete list of available indexes on each shard

You may see 2 or 3 alternate plans for a given query, however the output is
not listing the whole list of available indexes, only those few that it thinks
may be the best match. Run getIndexes() on your collection to see the
complete list

Incorrect Options:

All other options are incorrect, as they are important information you should first
look for when reading an explain() output.

Question 2

https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 23/65
28/10/2019 MongoDB University

Problem: Correct Answer Hide Details

Consider a write operation that takes 150 milliseconds, and a database profiler
that uses the default value of slowms.

Which of the following profiler levels would cause the profiler to capture this
operation?

Detailed Answer

Correct Answers

This profiling level will record all operations that exceed the slowms
limit, which is 100ms by default.

This profiling level will record all operations, regardless of how long
they take.

Incorrect Answers

This profiling level will not record any events to the


system.profile collection.

Question 3

Problem: Correct Answer Hide Details

https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 24/65
28/10/2019 MongoDB University

What information does the following command provide?

COPY

db.runCommand({
rolesInfo: { role: "dbOwner", db: "admin" },
showPrivileges: true
})

List of privileges dbOwner role grants to users

Roles that dbOwner role inherits

List of roles granted that have privileges over the "admin" database

Detailed Answer

Correct Options:

Roles that dbOwner role inherits

List of privileges dbOwner role grants to users

The command db.runCommand( { rolesInfo: { role: "dbOwner",


db: "admin" }, showPrivileges: true} ) provides information
about roles and privileges the "dbOwner" role grants.

Incorrect Option

List of roles granted that have privileges over the "admin" database

Question 4

Problem: Correct Answer Hide Details

Given BSON collection data and access to a database, which command could
you use to import that collection into the database?

mongoexport
https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 25/65
28/10/2019 MongoDB University
o goe po t

mongorestore

mongostat

mongoimport

mongodump

Detailed Answer

The correct answer is:

mongorestore

All other answers are incorrect. - mongodump operates using data in BSON, but
it removes data, rather than adds it to the database. - mongoimport and
mongoexport operates using JSON and CSV, so neither will work in the given
scenario. - mongostat returns the statistics about the mongod server currently
running and thus will not aid in adding a collection to the database.

Question 5

Problem: Correct Answer Hide Details

What is the size limit of a journal file?

1GB

100MB

there is no limit

https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 26/65
28/10/2019 MongoDB University

Detailed Answer

The correct answer is:

100MB

Each journal file has a maximum size of 100MB, after which a new file is created.
When a new journal file is created, WiredTiger syncs the previous journal file.

Question 6

Problem: Correct Answer Hide Details

What authentication mechanisms are available in the community version of


MongoDB?

LDAP

X.509

SCRAM

Detailed Answer

The correct answers are SCRAM and X.509. LDAP, and Kerberos, are only
available in the Enterprise version of MongoDB.

Question 7

Problem: Correct Answer Hide Details

Consider the following command:

$ mongod --enableEncryption --kmipServerName


COPY

https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 27/65
28/10/2019 MongoDB University

This command enables:

the use of the KMIP server that is running on the local machine

storage encryption

starting the KMIP server

Detailed Answer

Correct Answers:

the use of the KMIP server that is running on the local machine

The --kmipServerName points to the mongod process to a currently running


KMIP server, which in this case is running locally, hence the name used is
localhost

storage encryption

The --enableEncryption option turns on storage encryption for a mongod


process.

Incorrect Answers:

starting the KMIP server

The KMIP server is a separate program that a mongod process can connect to,
but not start, hence this answer is incorrect.

Question 8

Problem: Correct Answer Hide Details

Which of the following statements is true with regard to the localhost exemption?

You need to use the mongod user to create additional users when
connecting to a mongod for the first time.

https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 28/65
28/10/2019 MongoDB University

You can create the first user when connecting to a newly configured
mongod from localhost.

Localhost connections are blacklisted by default.

Users connecting from localhost are audited in the audit log.

Any user logging on from localhost bypasses authentication

Detailed Answer

The correct answer is:

You can create the first user when connecting to a newly configured
mongod from localhost.

When you first connect to a newly configured mongod, you can create the first
user even if authentication is on. This user can then be used to create
subsequent users as needed.

Question 9

Problem: Correct Answer Hide Details

In the context of a role-based access control (RBAC), which of following apply to


the principle of least privilege (POLP)?

Grant read only roles to users by default

Limit root role to only one user

Allow for all users roles to perform root actions if needed

https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 29/65
28/10/2019 MongoDB University

Grant roles to users with minimal access required for their tasks

Grant roles to users where they can explore the cluster features

Detailed Answer

Correct Option:

Grant roles to users with minimal access required for their tasks

Users should be granted privileges limited to the scope of the operations


that they need. Most built-in roles have been designed with this principle in
mind, however, you may have to create your own database custom roles to
adequately provide users with the absolute necessary set of privileges they
need to perform their expected tasks.

Incorrect Options:

Grant roles to users where they can explore the cluster features

Allow for all users roles to perform root actions if needed

These two options are wrong because they imply the opposite of POLP.

Grant read only roles to users by default

Granting roles to users enforcing POLP does not imply restricting all
database users to read only mode. Quite the opposite, only read what they
need to read, and only write what the user needs to write.

Limit root role to only one user

Having a limited amount of users with root level access is a common sense
approach, but that should not be a strict rule. If you need to have more than
one user with a given role, either root or other roles, so be it. As long it is
absolutely necessary to have such role so the user can perform is expected
tasks.

Question 10

Problem: Correct Answer Hide Details


https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 30/65
28/10/2019 MongoDB University

Which is/are primarily authorization operation(s)?

Reading a document from the Mongo Shell

Creating a user in any database other than admin

Using a X.509 certificate

Detailed Answer

Correct Options:

Reading a document from the Mongo Shell

Before you can issue the query to read a document, you would have been
authenticated. Now the server would verify that you are authorized to
access this document.

Creating a user in any database other than admin

The operation of creating the user is also related to authorization. You will
be authorized to add this user, if you are granted the appropriate privileges
in this database.

Incorrect Option:

Using an X.509 certificate

You can use an X.509 certificate to authenticate a machine, or a user. In


both cases, the certificate helps identifying who you are, so it is an
authorization operation.

Question 11

Problem: Correct Answer Hide Details

You are setting up MongoDB and have enabled authorization with the following
setting in your configuration file

https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 31/65
28/10/2019 MongoDB University

COPY

security:
authorization: enabled

Which of the following statements apply?

Users will be forced to connect to MongoDB over SSL/TLS

Database users will have access to only those resources granted to


them through the role-based access control system

Authentication will now be enforced as turning on authorization


implicitly enables authentication

Detailed Answer

The correct answers are:

Authentication will now be enforced as turning on authorization implicitly


enables authentication
Database users will have access to only those resources granted to them
through the role-based access control system

The answer Users will be forced to connect to MongoDB over SSL/TLS is


incorrect. These settings are contained in the net.ssl section of the
configuration document.

Application Administration

Question 1

Problem: Correct Answer Hide Details

What is the correct audit filter document that will enable logging any time a
collection in a database is created or dropped?

https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 32/65
28/10/2019 MongoDB University

{"atype": { "createCollection", "dropCollection" }}

{"$in": ["createCollection", "dropCollection" ]}

{"$and": [{"atype": "createCollection"}, {"atype":

"dropCollection"}]}

{"atype": { "$in": [ "createCollection",


"dropCollection" ]}}

{"atype": [ "createCollection", "dropCollection" ]}

Detailed Answer

Correct Answer:

{"atype": { "$in": [ "createCollection", "dropCollection"


]}}

When creating an audit filter by action type, you have to use the "atype" field
using the "$in" operator to list the multiple operations that you are looking to
audit.

All other answers have incorrect syntax for this operation.

Question 2

Problem: Correct Answer Hide Details

Consider the following audit filter:

--auditFilter '{ "atype": { "$in": [ "create


"param.ns": "test.*"}' COPY

https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 33/65
28/10/2019 MongoDB University

Which of the following operations must appear in the audit log?

use production
db.createCollection("test")

use test
db.dropCollection("games")

use test
db.createCollection("games")

Detailed Answer

Correct Option:

COPY

use test
db.createCollection("games")

This instruction will be logged in the audit log because both the audit namespace
is test.games and the action type createCollection are defined in the
auditFilter.

Incorrect Options:

COPY

use production
db.createCollection("test")

This command namespace production.test is not included in the audit filter,


therefore the operation would not be logged.

COPY
https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 34/65
28/10/2019 MongoDB University
CO

use test
db.dropCollection("games")

In this case both the action dropCollection and the namespace test.games
are part of the audit filter. However, given the information that we have, we
cannot guarantee that the collection games exists in the test database,
therefore we cannot be sure that this command will be successful. The audit log
will only log successful operations, operations that complete. Given that we are
looking for operations that must be logged, we cannot tell for sure that this
would be a successful operation.

Question 3

Problem: Correct Answer Hide Details

When configuring a new replica set to use keyfile authentication, which of the
following applies?

The hostname in the keyfile for each node must match the hostname
for the host it is running on.

The same keyfile needs to be configured on each member.

After starting the first member with keyfile authentication enabled, the
first user must be created via the localhost exception.

Detailed Answer

Correct answers

After you have started the first member with keyfile authentication enabled, you
must create the first user via the localhost exception.

This is true as when you enable keyfile authentication, client


authentication is enabled by default.

You must create identical keyfiles for each member.

https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 35/65
28/10/2019 MongoDB University

Each keyfile for each node must match. If not, communication


between nodes will fail due to authentication errors.

Incorrect answers

The hostname in the keyfile for each node must match the hostname for the host
it is running on.

Keyfiles do not use hostnames as a means of verifying where a


connection is coming from. X.509 authentication does.

Question 4

Problem: Incorrect Answer Hide Details

Let's assume an administrator created a user account with the following


commands on a replica set with authorization turned on:

COPY

$ mongo
use foundation
db.createUser({user: "daneel.olivaw", pwd:
"etodemerzel", roles: ["readWrite"]})

Which of the following methods is not valid to authenticate this user?

$ mongo test --authenticationDatabase


foundation
> db.auth("daneel.olivaw", "etodemerzel")

$ mongo
> use foundation
> db.auth("daneel.olivaw", "etodemerzel")

https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 36/65
28/10/2019 MongoDB University

$ mongo test -u daneel.olivaw -p etodemerzel -


-authenticationDatabase foundation

$ mongo test
> use foundation
> db.auth("daneel.olivaw", "etodemerzel")

$ mongo foundation -u daneel.olivaw -p


etodemerzel

Detailed Answer

The correct answer is:

COPY

$ mongo test --authenticationDatabase foundation


> db.auth("daneel.olivaw", "etodemerzel")

This is the only commands that will not authenticate correctly. After the mongo
shell starts, it will land in the 'test' directory. The subsequent db.auth()
command will try to authenticate in this 'test' database, while it should do it in
'foundation' to succeed. The key thing to understand here is that --
authenticationDatabase only make sense if you are also providing the
credentials at the same time.

Question 5

Problem: Incorrect Answer Hide Details

Which of the following commands will successfully create the user braun and
give the user the appropriate privileges to import data in any collection of the
https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 37/65
28/10/2019 MongoDB University
give the user the appropriate privileges to import data in any collection of the
nasa database?

> use nasa


> db.createUser({"user":"braun", "pwd":
"rocketscientist", "roles": [{"role":
"readWrite", "db": "admin"}] })

> use admin


> db.createUser({"user":"braun", "pwd":
"rocketscientist", "roles": [{"role":
"readWrite", "db": "nasa"}] })

> use nasa


> db.createUser({"user":"braun", "pwd":
"rocketscientist", "roles": [{"role":
"readWrite", "db": "nasa"}] })

Detailed Answer

Correct Options:

COPY

> use admin


> db.createUser({"user":"braun", "pwd":
"rocketscientist", "roles": [{"role": "readWrite",
"db": "nasa"}] })

COPY

> use nasa


> db.createUser({"user":"braun", "pwd":
"rocketscientist", "roles": [{"role": "readWrite",
"db": "nasa"}] })
https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 38/65
28/10/2019 MongoDB University

These 2 sets of commands will create the user "braun" with the appropriate
privileges. However, those 2 users will have to authenticate against different
databases.

Incorrect Option:

COPY

> use nasa


> db.createUser({"user":"braun", "pwd":
"rocketscientist", "roles": [{"role": "readWrite",
"db": "admin"}] })

In this example, the user is created on the nasa database with privileges on the
admin database. This will not allow the user to import data into the nasa
database.

Question 6

Problem: Correct Answer Hide Details

You have a user "larry" who you would like to create a user defined role for. This
role needs to include privileges that apply to multiple databases. Where should
you create this role?

The local database

The database that will be primarily used by larry

The config database

The admin database

Detailed Answer

https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 39/65
28/10/2019 MongoDB University

The correct answer:

The admin database

A role created in the admin database can include privileges that apply to the
admin database, other databases or to the cluster resource, and can inherit from
roles in other databases as well as the admin database. For that reason, if you

would like to create a role for "larry" that can be applied to multiple databases, it
needs to be created in the admin database

Question 7

Problem: Correct Answer Hide Details

Which of the following properties must be specified when creating a user-


defined role?

Role name

Set of privileges

Inherited roles

Detailed Answer

All options are properties used in the definition of user-defined roles.

Question 8

Problem: Correct Answer Hide Details

Select the resource definition that best describes all collections named
products in any database.

{ "db": "", "collection": "" }


https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 40/65
28/10/2019 MongoDB University

{ "collection": "products" }

{ "db": "*", "collection": "products" }

{ "db": "products", "collection": "" }

{ "db": "", "collection": "products" }

Detailed Answer

Correct Option:

{ "db": "", "collection": "products" }

This resource definition document determines that any action over this resource
will be applied on all products collections created on any database.

Incorrect Options:

{ "db": "products", "collection": "" }

This resource describes any collection on the products database.

{ "db": "*", "collection": "products" }

This resource describes the products collection on the * database.

{ "collection": "products" }

This resource is incorrectly formatted.

{ "db": "", "collection": "" }

This resource definition describes all collections on all databases.

Question 9

Problem: Correct Answer Hide Details


https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 41/65
28/10/2019 MongoDB University

What security mechanisms will be enabled with the following command?

$ mongod --sslMode requireSSL --sslPEMKeyFile server.pem --


sslCAFile ca.pem

enable TLS/SSL connection

encrypt connection between client and server using the server.pem


file

verify the client identity when connecting to the server using the
ca.pem file

Detailed Answer

All answers are correct.

--ssl Enables TLS/SSL connection.

sslPEMKeyFile Specifies the .pem file that contains the mongo shell's
certificate and key to present to the mongod or mongos instance.

--sslCAFile Specifies the Certificate Authority (CA) .pem file for verification of
the certificate presented by the mongod or the mongos instance.

Question 10

Problem: Correct Answer Hide Details

Where does MongoDB use TLS 1.1+ encryption algorithms?

Transport layer

Encrypted storage engine

https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 42/65
28/10/2019 MongoDB University

Password salting

Detailed Answer

Transport layer

MongoDB uses TLS 1.1+ to encrypt client-server and intra-cluster network


transport layer communication.

Replication

Question 1

Problem: Correct Answer Hide Details

Which are valid read concerns in MongoDB?

majority

linearizable

local

Detailed Answer

Correct Options:

All choices are correct.

majority read concern reads data that was written to a majority of nodes.

local read concern reads data at least written to the primary. It is the default
read concern

linearizable read concern reads data written to a majority of nodes prior to the
read request, and unlike majority will wait for pending write operations to
complete that would modify the document(s) requested
https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 43/65
28/10/2019 MongoDB University
p y ( ) q

Question 2

Problem: Correct Answer Hide Details

What do binary and statement-based replication have in common?

They are both used in MongoDB.

They both provide availability in a database server.

They both work across different operating systems.

Detailed Answer

Correct Answer

They both provide availability in a database server.

Replicating data provides availability in a database server, because it


keeps multiple servers up-to-date and ready to serve database
requests.

Incorrect Answers

Both forms of replication are used in MongoDB.

MongoDB uses statement-based replication in replica sets. This


solution is agnostic of any machine-level dependencies.

Both forms of replication work across different operating systems.

Statement-based replication will work across platforms, because


MongoDB commands can be understood by any operating system or
software version.

Binary replication will not work across different platforms, because it


uses binary differences to replicate data, and any change to the
platform may affect these binary differences drastically.

https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 44/65
28/10/2019 MongoDB University

Question 3

Problem: Correct Answer Hide Details

You are required to perform a rolling upgrade on your running replica set. You
have upgraded the secondaries and are now ready to upgrade the primary. What

command should you run on the primary before restarting it?

rs.freeze()

rs.reconfig()

rs.slaveOk()

rs.stepDown()

rs.remove()

Detailed Answer

The correct answer is rs.stepDown(). This will insruct the primary that it
should step down. The primary will check there is an electable secondary and
wait if necessary for a secondary to catch up. It will then step down if safe to do
so.

Question 4

Problem: Correct Answer Hide Details

When connected to a replica set secondary node using the mongo shell, which of
the following set of commands will return successfully?

rs.setSlaveOk(); db.newcollection.insert({"name":
https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 45/65
28/10/2019 MongoDB University

"Nathan"})

rs.setSlaveOk(); db.adminCommand({listDatabases: 1})

db.isMaster()

Detailed Answer

Incorrect Option:

rs.setSlaveOk(); db.newcollection.insert({"name":
"Nathan"})

This command will fail since write operations cannot be performed in


secondary nodes of a replica set.

Correct Options:

rs.setSlaveOk(); db.adminCommand({listDatabases: 1})

Reads on secondary nodes need to be explicit. In the mongo shell we


enable reads on secondary nodes by preceding a read command with
rs.setSlaveOk(), therefore this
db.adminCommand({listDatabases: 1}) would return successfully.

db.isMaster()

The db.isMaster() returns a document that describes the role of the


mongod instance to which we are connected. This command can be run on
all nodes, regardless of the node current replica set role.

Question 5

Problem: Incorrect Answer Hide Details

Which command would you use to add an arbiter to an existing replica set on
host mongo2, running on port 27017?

rs.add("mongo2:27017, arb: true")

https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 46/65
28/10/2019 MongoDB University

rs.addArb("mongo2:27107")

rs.reconfig({"host": "mongo2", "port": 27017,


"arbiter": "true"})

Detailed Answer

Correct Option

rs.addArb("mongo2:27107") COPY

This command will add the arbiter on mongo2:27107.

Incorrect Options:

rs.add("mongo2:27017, arb: true") COPY

Is not a valid command.

rs.reconfig({"host": "mongo2", "port": 27017


COPY

Is not a valid command, you need to pass a full configuration document to


rs.reconfig().

Question 6

Problem: Correct Answer Hide Details

In a 3-node replica set, which of the following write concerns is more durable
than the default?
https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 47/65
28/10/2019 MongoDB University
than the default?

w: 0

w: 1

w: 2

Detailed Answer

Correct answers:

w: 2

The default write concern is w: 1, and waiting for 2 nodes to apply a write is
more durable than only waiting for 1 node to apply it.

Incorrect answers:

w: 1

This is already the default Write Concern in MongoDB, so it does not represent a
higher durability than the default.

w: 0

This will not wait for any nodes to apply a write before sending an
acknowledgement, so it is a less durable write than the default value of w: 1.

Question 7

Problem: Correct Answer Hide Details

Consider a write operation performed against a replica set with write concern w:
1.

After changing the write concern to w: "majority", this operation is:

less likely to be rolled back


https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 48/65
28/10/2019 MongoDB University

more likely to block other operations in the application

more likely to take longer

Detailed Answer

All three of these options are true.

The write operation is more likely to take longer because the server has to
wait for acknowledgement from a majority of nodes in the replica set. This
typically takes longer than waiting for only one acknowledgement.

It is also less likely to be rolled back, because even if the primary node shuts
down, there is at least one other node that's applied the write operation.

And finally, it is more likely to block other operations in the application,


because the write operation will take longer than the same operation issued with
write concern w: 1. However, this can be remedied by issuing a wtimeout that
satisfies the application's need for timely acknowledgement.

Question 8

Problem: Correct Answer Hide Details

You have an application that does not need to have the most up to date data,
however you want to ensure that network latency between your client application
and the member it is reading from is minimized. Which read preference should
you set to achieve this goal?

secondary

primaryPreferred

nearest

https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 49/65
28/10/2019 MongoDB University

Detailed Answer

Incorrect Options:

primaryPreferred

primaryPreferred Will read from a primary unless the primary is


unavailable for any reason.
In which case, the client will read from a secondary.

Secondary

Secondary Will always read from a secondary node.

Correct Option

nearest

nearest is the correct answer as it will read from the node with the lowest
network latency.

Question 9

Problem: Correct Answer Hide Details

Which collections in the local database are replicated by secondary nodes in a


MongoDB replica set?

oplog.rs

startup_log

system.replSet

Detailed Answer

Correct Answer

oplog.rs

https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 50/65
28/10/2019 MongoDB University

The oplog collection is replicated by secondary nodes to perform any


new operations. This is the only collection in the local database
that is replicated by secondary nodes.

Incorrect Answers

system.replSet

This collection stores information on the replica set, but it is not


replicated by secondaries.

startup_log

This collection contains the options used to start the mongod


process. It is not replicated by secondaries.

Question 10

Problem: Correct Answer Hide Details

You have the following information for the members field in your replicaset
configuration document

COPY

"members" : [
{
"_id" : 0,
"host" : "acmecorp:27017",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"tags" : {

},
"slaveDelay" : NumberLong(0),
"votes" : 1
},
{
"_id" : 1,
https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 51/65
28/10/2019 MongoDB University
_ ,
"host" : "acmecorp:27018",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : true,
"priority" : 0,
"tags" : {

},
"slaveDelay" : NumberLong(3600),
"votes" : 0
},
{
"_id" : 2,
"host" : "acmecorp:27019",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"tags" : {

},
"slaveDelay" : NumberLong(0),
"votes" : 1
}
],

Select the following true statements.

If member 0 or member 2 goes down, no new primary will be elected

Member 1 can never become the primary

Member 2 is more likely than member 0 to become primary

Detailed Answer

The correct answers are:

https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 52/65
28/10/2019 MongoDB University

If member 0 or member 2 goes down, no new primary will be elected


This is because of the hidden node, member 1! Since it cannot vote,
there would be no majority to elect a new primary if member 0 or
member 2 goes down. An important consideration to keep in mind.
Member 1 can never become the primary
Because member 1 has a slaveDelay, it can never become the
primary.

Sharding

Question 1

Problem: Correct Answer Hide Details

How can you increase the cardinality of the shard key?

Use a compound shard key.

Use multiple shard keys.

Increase the number of shards.

Increase the number of chunks.

Create an index on the shard key.

Detailed Answer

Correct Answer:

Use a compound shard key.

Using a compound shard key creates more possibilities for the value
of the shard key, by using each unique combination of all the fields in
the key.

https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 53/65
28/10/2019 MongoDB University

Incorrect Answers:

Use multiple shard keys.

You cannot shard on multiple keys in a collection.

Increase the number of shards.

Adding more shards will decrease the load on each shard, but this
will not increase the cardinality of the shard key.

Increase the number of chunks.

This will be a result of increasing the cardinality of the shard key, not
a cause.

Create an index on the shard key.

It is already a requirement that the shard key has an index, therefore


this will not increase the cardinality of the shard key.

Question 2

Problem: Incorrect Answer Hide Details

Consider the following chunk document:

COPY

use config
db.chunks.findOne()
{
"_id": "test.sessions-abc-yxz",
"ns": "test.sessions",
"min": {
"userId": 1,
"sessionId": "US00001"
},
"max": {
"userId": 10,
"sessionId": "US00001"
}
https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 54/65
28/10/2019 MongoDB University
},
"shard": "sh-1",
"lastmod": Timestamp(0,1),
"lastmodEpoch": ObjectId("ac78f355843b62a6d5a33a76")
}

Which of the following statements is true regarding the above chunk?

All documents in chunk "test.sessions-abc-yxz" are located in shard


"sh-1"

Documents with fields {"userId": 10, "sessionId": "US00001"


} are located part of chunk "test.sessions-abc-yxz"

The shard key defined for "sessions" collection is {userId: 1,


sessionId: 1}

Detailed Answer

Incorrect Options:

Documents with fields {"userId": 10, "sessionId": "US00001" }


are located part of chunk "test.sessions-abc-yxz"

This is incorrect because the documents defined with values {"userId":


10, "sessionId": "US00001" } match the upper bound of chunk
"test.sessions-abc-yxz" and therefore are excluded from this chunk. Upper
bound of a chunk is exclusive.

Correct Options:

The shard key defined for "sessions" collection is {userId: 1,


sessionId: 1}

All documents in chunk "test.sessions-abc-yxz" are located in shard "sh-1"

Both options are correct. All documents of chunk "test.sessions-abc-yxz"


are placed in the shard "sh-1" and the shard key of the collection is
{userId: 1, sessionId: 1}, given that these are the fields defined in
the sample chunk.

https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 55/65
28/10/2019 MongoDB University

Question 3

Problem: Correct Answer Hide Details

At which point does the balancer decide to start moving chunks from one shard
to another?

when some shards have too many chunks compared to others

zone sharding is used and some chunks are identified to be on the


wrong shard

there has been a request to drain a shard due to a removeShard


command

Detailed Answer

Correct Options:

when some shards have too many chunks compared to others


zone sharding is used and some chunks are identified to be on the wrong
shard
there has been a request to drain a shard due to a removeShard
command

All of these scenarios trigger a chunk migration.

Question 4

Problem: Correct Answer Hide Details

What is sharding?

a way to vertically scale

a method to ensure data availability


https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 56/65
28/10/2019 MongoDB University
a method to ensure data availability

a method of distributing data across multiple machines

Detailed Answer

The correct answer is:

a method of distributing data across multiple machines


a method to ensure data availability

Is an incorrect answer. Replication is used to ensure data availability.

a way to vertically scale

Is an incorrect answer.

Sharding is a way to horizontally scale when vertical scaling becomes


either too costly or you reach a data size where backups and restores will
become unmanagable for a single replica set. You can read more in the
Sharding section of MongoDB documentation.

Question 5

Problem: Correct Answer Hide Details

You have sharded the collection users with the following command:

COPY

sh.shardCollection(
"app.users",
{ "userId": 1, "last_login": 1, "isActive": 1 }
)

Now you are tasked to help a colleague define which query predicate they
should use to address a given critical, low latency feature of the application.
Which of the following query predicates should they use to implement the
feature? (All of the following options are valid to implement the feature)

https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 57/65
28/10/2019 MongoDB University

{"isActive": true}

{"name": <String>, "last_login": {"$lt": <ISODate>}}

{"last_login": {"$lt": <ISODate> }, "isActive": false


}

{"name": {$exists: 1} }

{"userId": <String>, "last_login": {"$gte": <ISODate>


} }

Detailed Answer

Correct Option:

{"userId": <String>, "last_login": {"$gte": <ISODate> } }

In case of equally fulfilling query predicates for the feature at hand,


developers should use the most optimized query possible. Given that we
are dealing with a sharded query, the choice should always fall on routed
queries, queries that can be serviced by the shard key, which in this case
can only be satisfied by this option

All other options would be scattered gathered queries, which are less
performant.

Question 6

Problem: Correct Answer Hide Details

Which is true of scatter gather queries?

scatter gather queries can be triggered by using your shard key in your
query predicates

https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 58/65
28/10/2019 MongoDB University

scatter gather queries are highly performant

the mongos has to go to each shard to check if the shard has the
requested documents

Detailed Answer

Incorrect Options:

scatter gather queries can be triggered by using your shard key in your query
predicates

Using the shard key in your query predicates prevents scatter gather
queries by routing the query to the correct shard. This is due to the config
server being aware of the distribution of the values across the cluster.

scatter gather queries are highly performant

Scatter gather queries are not performant as the mongos has to go to each
shard to check if the requested documents are present.

Correct Option

the mongos has to go to each shard to check if the shard has the requested
documents

Not querying on your shard key causes scatter gather queries. As a result,
the mongos has no way of checking which shard the data resides on. This
causes the mongos needs to route the query to each shard to gather the
result set.

Question 7

Problem: Correct Answer Hide Details

Given the following query:

COPY

{
https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 59/65
28/10/2019 MongoDB University
{
find({"cast": "Meryl
Streep"}).sort({"year":1}).skip(100).limit(20)
}

And the following steps for executing such query in a sharded cluster:

route - mongos send/route the query to the shards limit_by_shards -


each shard limits to 100+20 docs on their partial result set
limit_by_mongos - mongos limits to 20 docs skip_by_shards - each
shard skips 100 docs on their partial result set skip_by_mongos -
mongos skips of 100 docs sort_by_shards - each shard sorts their
partial result set sort_by_mongos - mongos does a merge sort on the
received documents

Which of the following has the right steps, and in the right order?

route, limit_by_shard, sort_by_mongos, limit_by_mongos,


skip_by_mongos

route, limit_by_shard, sort_by_mongos, skip_by_mongos,


limit_by_mongos

route, sort_by_shard, skip_by_shard, limit_by_shard, sort_by_mongos,


skip_by_mongos, limit_by_mongos

route, sort_by_shard, limit_by_shard, sort_by_mongos,


skip_by_mongos, limit_by_mongos

route, skip_by_shard, limit_by_shard, sort_by_shard, skip_by_mongos,


limit_by_mongos, sort_by_mongos

Detailed Answer

Correct Answer:

https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 60/65
28/10/2019 MongoDB University
route, sort_by_shard, limit_by_shard, sort_by_mongos, skip_by_mongos,
limit_by_mongos

Out of all the steps, the shards are not going to skip documents, because
skipping the first X documents only make sense on the final result set.

Remember the importance of having the shards responsible to sort their set,
because they likely have an index to produce the ordered set. The mongos, a

lighter process than the mongod, performs a merge sort, which is a rather
inexpensive operation compare to a complete sort.

The shards must limit to not only 20 documents, but also returned the potentially
skipped documents. For this reason, they will limit to the sum of the limit()
and skip() values.

Question 8

Problem: Correct Answer Hide Details

You have the following operational requirements and benchmarks within your
organization:

Full backup or restore times can never exceed 20 minutes


Client read and writes can never exceed 95 ms latency
The current machines are provisioned with 16GB of RAM and
4TB disk space
Backup and recovery times with 1.5TB took 15 minutes each,
respectively
The next available server size is 32GB RAM and 8TB disk
space with a monthly cost increase of 10% for double the
performance.

The application is expected to grow in users and resource consumption at a rate


of 7% monthly. Consider the following scenarios that represent different
applications:

Scenario A: Your replica set nodes are consuming 10% of


available RAM and your database is 200GB, and a new law
was passed in the EU requiring your organization to store
certain data about EU customers within the EU. 66% of your
users are location within the Americas with an average read
https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 61/65
28/10/2019 MongoDB University

and write response time of 90ms.


Scenario B: Your replica set nodes are consuming 90% of
available RAM and your database is 400GB
Scenario C: Your replica set nodes are consuming 60% of a
available RAM and your database is 2.8TB

Select the scenario(s) above where sharding should be considered.

Detailed Answer

The correct answers are scenarios A and C.

Scenario C: While the cost of vertically scaling is acceptable, we're already using
2.8TB of disk space. Considering we benchmarked a backup operation and
restore operation at 15 minutes each with 1.5TB of data, we're already beyond
our SLAs. Sharding should have already been considered much sooner.

Scenario A: This is a real world scenario that zone sharding was designed to
address, and depending on the type of information your organization stores you
may be subject to regulations requiring you to store data in a specific
geographical area. Considering the majority of users are located in the Americas
approaching SLA limits, sharding is more appropriate here than relocating all
data to the EU.

Let's discuss the incorrect answer.

In scenario B, we're consuming 10% of available disk (400GB) and 90% of


available RAM. This indicates quite an abundance of indexes for more
performant reads. Based on benchmarks, backup and restore times are within
acceptable SLAs and the cost to scale vertically is cheaper than the cost to
scale horizontally. Based on the information provided, sharding is not appropriate
in this scenario.

https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 62/65
28/10/2019 MongoDB University

Question 9

Problem: Correct Answer Hide Details

Which of the following is the most important factor in choosing a shard key?

using more than one field for the shard key

knowledge of the approximate size of the collection to shard

shard key that is not increasing/decreasing monotically

shard key for which the different values and their frequency are known

knowledge of the read and write workloads of the application

Detailed Answer

Correct Answer:

knowledge of the read and write workloads of the application

This is the most important criteria. There is often no perfect shard key, so
compromises may be needed.

If the workload is mostly writes, not using a monotonically increasing/decreasing


shard key and distributing the writes is crucial.

If the workload is mostly reads, you want to identify the most frequent queries,
and ensure those get distributed and localized. The queries not using the shard
key will be sent to all shards. Those non-targeted queries do not scale well,
meaning adding a new shard is not helping, so we want to minimize those.

Incorrect Answers:

knowledge of the approximate size of the collection to shard

https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 63/65
28/10/2019 MongoDB University

This will help you estimate the number of shards you may need, however not
help you identify the shard key.

shard key that is not increasing/decreasing monotically

This is true for a write intense workload, but may not be your priority in a read
intense workload.

shard key for which the different values and their frequency are known

You may not need to know the different values, however you need to have a
ballpark number on the cardinality of the values for your shard key.

using more than one field for the shard key

That helps increase the cardinality and reduce the frequency, however is is not
mandatory. You may have a single field that already has good cardinality and
frequency.

Question 10

Problem: Correct Answer Hide Details

Before sharding a collection, by running the sh.shardCollection command in


the mongo shell, which operation is required?

create an index on the shard key

rename the collection

drop all data from the collection

remove all shard key duplicates

load data into the collection

https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 64/65
28/10/2019 MongoDB University

Detailed Answer

Before sharding a collection using sh.shardCollection command, the


selected shard key needs to be supported by an index, therefore the correct
answer is:

create an index on the shard key

All other operations are not necessary, or desired, to enable sharding in a


collection.

https://university.mongodb.com/exam/practice/DBA/results/5db6a2f5eb8883418df190da 65/65

You might also like