MongoDB University - PreExamDBA

Download as pdf or txt
Download as pdf or txt
You are on page 1of 64

28/10/2019 MongoDB University

Practice Certification Exam


Your Grade
MongoDB DBA Exam
PASS/FAIL
Submitted

Exam Overview

SECTION CORRECT INCORRECT TOTAL

Philosophy & Features 0 3 3

CRUD 0 5 5

Indexes 0 11 11

Server Administration 0 11 11

Application Administration 0 10 10

Replication 0 10 10

Sharding 0 10 10

Philosophy & Features

Question 1

Problem: Incorrect Answer Hide Details

How would you represent the comments collection in the reviews database?

db.reviews

comments.db

{"comments" : "reviews"}
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 1/64
28/10/2019 MongoDB University

reviews.comments

comments.reviews

Detailed Answer

Correct Answer

reviews.comments is how you can reference the comments collection in


the reviews database using dot notation.

Question 2

Problem: Incorrect Answer Hide Details

Select the valid shell commands that will establish a connection with the bears
database using a username and password authentication method via the admin
database.

mongo
"mongodb://example.mongodb.net:27017/bears" --
authenticationDatabase admin --ssl --username
user --password ******

mongo "mongodb://example.mongodb.net:27017" --
db bears --authenticationDatabase admin --ssl
--username user --password ******

mongo
"mongodb://example.mongodb.net:27017/admin?
db=bears" --ssl --username user --password
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 2/64
28/10/2019 MongoDB University

******

Detailed Answer

You can specify the database that you are trying to connect with either in the
connection string or as a command line argument like in the correct choices

below.

COPY

mongo "mongodb://example.mongodb.net:27017/bears" --
authenticationDatabase admin --ssl --username user --
password ******

mongo "mongodb://example.mongodb.net:27017" --db bears


--authenticationDatabase admin --ssl --username user -
-password ******

In the following choice the connection string is specifying to connect to the


admin database, and is then using an invalid connection string parameter to
specify another database to connect to. Since the parameter is invalid and you
can not connect to two databases at the same time, this answer is incorrect.

mongo "mongodb://example.mongodb.net:27017/a
COPY

Question 3

Problem: Incorrect Answer Hide Details

Consider the following aggregation pipeline:

COPY

use services

db.restaurants.aggregate([
{
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 3/64
28/10/2019 MongoDB University
{
"$project": {
"avgRating": { "$sum": "$reviews.rating" }
}
},
{
"$out": "restaurants"

}
])
If this pipeline is executed on a sharded cluster, where can the merge stage be
performed?

On the primary shard

On a random shard

On the mongos

Detailed Answer

The correct answer is the primary shard. This is because the $out stage requires
to be run on the primary shard. All other answers are incorrect.

CRUD

Question 1

Problem: Incorrect Answer Hide Details

Select all statements that accurately describe how the updateOne command
works in conjunction with the $unset operator.

if the field does not exist, $unset does nothing

the specified value in the $unset expression does not impact the
ti
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 4/64
28/10/2019 MongoDB University
operation

the $unset operator deletes a particular field

Detailed Answer

Correct Answers:

All choices are correct.

$unset operator deletes the field specified in the expression if it is present in


the document regardless of the value that is used in the $unset expression.

For additional description, such as using $unset with array fields see the
relevant documentation page.

Question 2

Problem: Incorrect 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",
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 5/64
28/10/2019 MongoDB University

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",
last: "Doe"
}

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

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

{
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 6/64
28/10/2019 MongoDB University
{
_id: 4,
name: "Walter",
last: "Doe"
}

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

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
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 7/64
28/10/2019 MongoDB University

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.

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
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 8/64
28/10/2019 MongoDB University

Problem: Incorrect Answer Hide Details

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


which document will be deleted from the collection?

a random document that matches the filter parameter

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

the first document that matches the filter

the last document that matches the filter

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

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.

Question 4

Problem: Incorrect Answer Hide Details

Consider the following operation:

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


COPY

https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 9/64
28/10/2019 MongoDB University

Which fields should we expect to exist in result documents?

_id

genre

year

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: Incorrect Answer Hide Details

Which of the following statements is true of the insertMany command?

It takes an array of documents to be inserted.

In case of duplicate key error, all document field values are replaced
except for the _id.

https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 10/64
28/10/2019 MongoDB University

insertMany cannot insert any documents if one of the documents


results in an error.

Documents passed to insertMany are required to have _id field


defined.

Always inserts documents in the array defined order.

Detailed Answer

Correct Answers

It takes an array of documents to be inserted.

insertMany takes an array of documents and inserts them in the


specified collection.

Incorrect Answers

Documents passed to insertMany are required to have _id field defined.

The _id field behavior is the same for any insert command. If the
documents in the insertMany input array do not have the _id field
defined, the MongoDB server or the client driver will set the field using an
ObjectId value.

insertMany cannot insert any documents if one of the documents results


in an error.

insertMany will insert all documents until an error is detected in the case
of ordered inserts. In the case of unordered insert, insertMany will
attempt to insert all documents, and the resulting errors are collected and
reported back to the client.

Always inserts documents in the array defined order.

insertMany will insert by default the documents in order, however it can


be executed in unordered mode.

In case of duplicate key error, all document field values are replaced except
for the _id.

I t i th fd li t k th i fli ti d
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b
t f il t 11/64
28/10/2019 MongoDB University
Incorrect, in the case of duplicate key error, the inflicting document fails to
insert and the error is reported to the client.

Indexes

Question 1

Problem: Incorrect Answer Hide Details

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

this command is invalid

r3 will be run as a standalone node

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

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

r3 will become the primary node of the replica set

Detailed Answer

https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 12/64
28/10/2019 MongoDB University
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 2

Problem: Incorrect Answer Hide Details

Having a good compound shard key on a collection:

helps avoid potential un-splittable jumbo chunks

there will be fewer shards required for the collection

allows for even distribution of the collection

Detailed Answer

Correct Answer

helps avoid potential un-splittable jumbo chunks

In the case where a chunk's upper bound is equal to its lower bound, it can
not be split, which hinders the benefits of horizontal scaling. Creating a
compound key mitigates that, by adding an additional criteria for chunk
upper an lower bounds. This allows chunks with identical value on one field
to be split by the values of another field in the shard key.

allows for even distribution of the collection

Having a good compound shard key can only improve the collection
distribution because it adds a parameter for the distribution criteria.

Incorrect Answer

there will be fewer shards required for the collection

Thi i i t i h dk d td t i th
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b
b f 13/64
28/10/2019 MongoDB University
This is incorrect, since your shard key does not determine the number of
shards in your cluster, and that decision is made at an earlier step of the
collection sharding process.

Question 3

Problem: Incorrect Answer Hide Details

You have the following index on the products collection:

{ rating: 1, price: 1 } COPY

Which of the following choices would be a covered query?

db.products.find(
{ "rating": { "$gt": 7 } },
{ "_id": 0, "price": 1 }
)

db.products.find(
{ "rating": { "$gte": 7 } },
{ "price": 1 }
)

db.products.find(
{ "price": { "$lt": 7 } },
{ "_id": 0, "price": 1 }
)

db.products.find(
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 14/64
28/10/2019
p ( MongoDB University
{ "price": { "$lt": 7 }, "rating": 7 },
{ "_id": 0 }
)

db.products.find(
{ "price": { "$lt": 7 } },
{ "_id": 0, "price": 1, "rating": 1 }
)

Detailed Answer

The correct answer is

COPY

db.products.find(
{ "rating": { "$gt": 7 } },
{ "_id": 0, "price": 1 }
)

This is because it's using the prefix rating, and projecting away all fields that
aren't in the index. That only one key of the two is specified to be kept doesn't
impact the query itself.

Question 4

Problem: Incorrect Answer Hide Details

When creating an index on an array field, what type of index is created?

geospatial index

single field index

https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 15/64
28/10/2019 MongoDB University

multikey index

hashed index

text index

Detailed Answer

The correct answer is:

multikey index

All other answers are incorrect because:

single field index is defined on a single field that is not an array field
geospatial index is used to support efficient queries of geospatial data,
using 2d indexes and 2dsphere indexes to return results
text index is supports searching for string content in a collection
hashed index is created to support hashed based sharding

Question 5

Problem: Incorrect Answer Hide Details

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

Indexes are part of the database "working set"

Indexes are data structures that require additional resources as they


grow

Indexes should be taken into consideration for sizing and maintenance

https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 16/64
28/10/2019 MongoDB University

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 6

Problem: Incorrect 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 the locale "fr"

mongod will throw an error

matching documents using the locale "en"

https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 17/64
28/10/2019 MongoDB University

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

matching documents using no locale

Detailed Answer

Correct Option:

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 7

Problem: Incorrect Answer Hide Details


https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 18/64
28/10/2019 MongoDB University

Given a member of a replica set that has a priority 0 and is hidden. For which
operations on that member would it be acceptable and useful to have a different
set of indexes?

running large batch inserts

doing text searches

running analytic queries

Detailed Answer

Correct Options:

running analytic queries

Some queries used for analytics may be the only ones with a given set of
fields to search on. In that situation, it may make sense to only create the
appropriate indexes to support those queries on that hidden secondary
member.

doing text searches

If those text searches are not performed on the Primary, it may make sense
to build the required text indexes only on the isolated members, as those
text indexes may be take a lot of space.

Correct Options:

running large batch inserts

Because we are on a member with a priority of 0 and hidden, we know that


this member can not be a Primary, but only a Secondary. For that reason,
we can't perform writes on the member.

Question 8

Problem: Incorrect Answer Hide Details

https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 19/64
28/10/2019 MongoDB University

Consider the following operation:

db.employees.createIndex( { firstname: 1, la
COPY

Which of the following are true about this operation?

mongod will throw an error.

It builds two indexes.

It builds one index.

Detailed Answer

Correct Answers:

It builds one index.

This answer is correct. This operation will build a single index, on the
firstname and lastname fields.

Incorrect Answers:

mongod will throw an error.

mongod will not throw an error. It will start the index build.

It builds two indexes.

This answer is incorrect - only one index will be built by this


operation.

Question 9

Problem: Incorrect Answer Hide Details

Given the following index:


https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 20/64
28/10/2019 MongoDB University

db.books.createIndex({ "genre": 1, "chapters


COPY

what will the query plan look like for the following query?

COPY

db.books.find(
{ "genre": "fiction", "chapters": {"$gt": "20" } }
).sort(
{ "rating": -1 }
)

IXSCAN -> SORT -> FETCH

SORT -> IXSCAN -> FETCH

IXSCAN -> FETCH

FETCH -> SORT

IXSCAN -> FETCH -> SORT

Detailed Answer

Correct Answer:

IXSCAN -> FETCH -> SORT

Incorrect Answers

IXSCAN -> FETCH


SORT -> IXSCAN -> FETCH
FETCH -> SORT
IXSCAN -> SORT -> FETCH

https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 21/64
28/10/2019 MongoDB University

Given that the index supports this query, the first stage would be IXSCAN.
Therefore, any option that does not start with that needs to be discarded.

Since the existing index supports the fetching of documents, it will be used
before the documents are fetched. The query is also looking to get a sorted
response on a field that is not indexed, so the last step will be to do the sorting.

Question 10

Problem: Incorrect Answer Hide Details

Given the following query:

COPY

db.songs.find(
{ "seconds": { "$lt": 400 }, "genre": "rock" }
).sort(
{ "rating": 1 }
)

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

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

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

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

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

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

Detailed Answer
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 22/64
28/10/2019 MongoDB University

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 11

Problem: Incorrect Answer Hide Details

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( { price: { $lt: 1500 } } )


.sort( { memoryGB: -1 } )

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


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

https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 23/64
28/10/2019 MongoDB University

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 } )

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.

Server Administration

Question 1

Problem: Incorrect Answer Hide Details

Consider a write operation that takes 150 milliseconds, and a database profiler
th t th d f lt l f l
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 24/64
28/10/2019 MongoDB University
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 2

Problem: Incorrect Answer Hide Details

You are attempting to run a mongod with the following options in your terminal.
Assume the directory paths and permissions are correctly set.

mongod port 35000 dbpath /home/user/mong


https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 25/64
28/10/2019 MongoDB University
mongod --port 35000 --dbpath /home/user/mong
COPY

The mongod is not starting. Which of the following is the most likely cause?

the port must be 27017

--config is not specified

--logpath is not specified

--bind_ip_all is not specified

the directory /home/user/mongodb/data is empty

Detailed Answer

Correct Answer:

--logpath is not specified.

When running mongod with the --fork option, --logpath must be specified.

Question 3

Problem: Incorrect Answer Hide Details

What information does the following command provide?

COPY

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

https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 26/64
28/10/2019 MongoDB University

Roles that dbOwner role inherits

List of privileges dbOwner role grants to users

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: Incorrect Answer Hide Details

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

mongodump

mongoexport

mongostat

https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 27/64
28/10/2019 MongoDB University

mongoimport

mongorestore

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: Incorrect Answer Hide Details

Which of the following is a reason to use --


wiredTigerDirectoryForIndexes or --directoryperdb?

To parallelize IO throughput using symlinks

To allow for easy backup and restore of the db path

To scale writes across your cluster

Detailed Answer

Correct answer:

To parallelize IO throughput using symlinks

You can use --directoryperdb and --


wiredTigerDirectoryForIndexes and symlink those directories
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 28/64
28/10/2019 MongoDB University

to separate volumes to horizontally scale IO.

Incorrect answers:

To allow for easy backup and restore of the db path.

This is not a correct answer. Having individual directories in the db


path will not help backup and restores. When restoring a set of files

from a backup, you need all the files together to have a consistant
state.

To scale writes across your cluster

Using these options will not scale writes across a cluster. Sharding is
used for scaling writes as opposed to any storage level options such
as --directoryperdb or --wiredTigerDirectoryForIndexes.

Question 6

Problem: Incorrect Answer Hide Details

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.

https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 29/64
28/10/2019 MongoDB University

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 7

Problem: Incorrect Answer Hide Details

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

COPY

security:
authorization: enabled

Which of the following statements apply?

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

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

Detailed Answer

https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 30/64
28/10/2019 MongoDB University

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.

Question 8

Problem: Incorrect Answer Hide Details

What is the correct way to report a vulnerability to MongoDB?

file a ticket in our security Jira project

post on the forums in MongoDB University

calling our support hotline

Detailed Answer

The correct answer is:

file a ticket in our security Jira project

When you believe you have discovered a vulnerability you should file a ticket in
our security Jira project including as much information as possible, such as
contact details

Question 9

Problem: Incorrect Answer Hide Details


https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 31/64
28/10/2019 MongoDB University

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

Any user logging on from localhost bypasses authentication

You can create the first user when connecting to a newly configured

mongod from localhost.

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

Users connecting from localhost are audited in the audit log.

Localhost connections are blacklisted by default.

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 10

Problem: Incorrect Answer Hide Details

What authentication mechanisms are available in the community version of


MongoDB?

LDAP

https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 32/64
28/10/2019 MongoDB University

SCRAM

X.509

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

Question 11

Problem: Incorrect Answer Hide Details

Consider the following command:

$ mongod --enableEncryption --kmipServerName


COPY

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
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 33/64
28/10/2019 MongoDB University

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.

Application Administration

Question 1

Problem: Incorrect 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?

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


"dropCollection" ]}}

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

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

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


"dropCollection"}]}

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

Detailed Answer

https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 34/64
28/10/2019 MongoDB University

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: Incorrect Answer Hide Details

Which command generates the following audit message?

COPY

{
"atype" : "createUser",
"ts" : { "$date" : "2019-02-01T14:20:22.864-0500" },
"local" : { "ip" : "127.0.0.1", "port" : 30000 },
"remote" : { "ip" : "127.0.0.1", "port" : 64942 },
"users" : [],
"roles" : [],
"param" : { "user" : "god", "db" : "admin", "roles"
: [ { "role" : "root", "db" : "admin" } ] },
"result" : 0
}

db.auth("root", "yes")

db.auth("user1", "passwordOk")

db.createUser({"user": "god", "pwd": "yes", "roles":


["root"]})

https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 35/64
28/10/2019 MongoDB University

db.createUser({"user": "god", "pwd": "yes", "roles":


["role": "readWrite", "db": "admin"]})

db.createUser({"user": "user1", "pwd": "yes", "roles":


["root"]})

Detailed Answer

Correct Option:

db.createUser({user: 'god', pwd: 'yes', roles: ["root"]})

The audit message action type states the event was triggered by a successful
createUser command. The param field determines that the user name is root
and that the role granted is root. The above option is the only that matches all
of these criteria.

All other options are would generate a different audit message.

Question 3

Problem: Incorrect Answer Hide Details

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

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

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.

Detailed Answer

Correct answers
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 36/64
28/10/2019 MongoDB University

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.

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

You need to create a user "harry" which will use LDAP authentication. This user
exists on your LDAP server. Which command would you use in the mongo shell
to create this user?

db.getSiblingDB(
"admin".createUser(
{
user: 'harry',
roles: [{role: 'root', db: 'admin'}]
}
)

db.getSiblingDB(
"$external".createUser(
{
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 37/64
28/10/2019 MongoDB University
{
user: 'harry',
roles: [{role: 'root', db: 'admin'}]
}
)

use admin
db.createUser(
{
user: "harry",
pwd: "password",
roles: ['LDAP' ]
}
)

use ldap
db.createUser(
{
user: "harry",
pwd: "password",
roles: [ "readWrite", "dbAdmin" ]
}
)

Detailed Answer

Correct Option

COPY

db.getSiblingDB(
"$external".createUser(
{
user: 'harry',
roles: [{role: 'root', db: 'admin'}]
}
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 38/64
28/10/2019 MongoDB University
}
)

This command will create a user in the $external database which is used for
external authentication mechanisms such as LDAP.

Question 5

Problem: Incorrect Answer Hide Details

Which of the following actions is a user with the clusterManager built-in role
able to perform?

Add nodes from a replica set

Resync a replica node

Remove shards

Detailed Answer

All of the above are actions that users with the clusterManager built-in role are
able to perform.

Question 6

Problem: Incorrect Answer Hide Details

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

{ "collection": "products" }

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


https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 39/64
28/10/2019 MongoDB University

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

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

{ "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 7

Problem: Incorrect Answer Hide Details

Database users created with the built-in role readWriteAnyDatabase are


allowed to:
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 40/64
28/10/2019 MongoDB University

update documents in all databases except admin

add nodes to a replica set

create documents in any database

change log level in any database

grant permissions to other users in any database

Detailed Answer

Incorrect Options:

add nodes to a replica set

readWriteAnyDatabase does not grant cluster administration


privileges like changing replica set topology.

change log level in any database

Changing the log level is system administration privilege not granted


by this role.

update documents in all databases except admin

The admin database is not excluded, although we highly discourage


update state in the admin database.

grant permissions to other users in any database

Grant permissions to users is a user management privilege not


granted by readWriteAnyDatabase.

Correct Option

create documents in any database

readWriteAnyDatabase allows reads and writes against any


https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 41/64
28/10/2019 MongoDB University
readWriteAnyDatabase allows reads and writes against any
database.

Question 8

Problem: Incorrect Answer Hide Details

Consider the following command:

COPY

db.revokePrivilegesFromRole(
"customRole",
[{ resource: { db: "stores", collection: "" },
actions: [ "find" ] }]
)

Which of the following privileges does this command remove from the
"customRole" role?

Run find commands on any collection in the stores database

Run aggregation commands on any collection named stores

Run find commands on any collection named stores

Detailed Answer

Correct Option:

Run find commands on any collection in the stores database

This command does remove the privilege of customRole to run find


commands on any collection of stores database.

Incorrect Options:

Run find commands on any collection named stores

The command does not apply to collections named store.


https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 42/64
28/10/2019 MongoDB University
pp y

Run aggregation commands on any collection named stores

The removed privilege only applies to find commands. The ability to run
aggregation commands is not affected by revoking this privilege.

Question 9

Problem: Incorrect Answer Hide Details

Which shell command allows to view the contents of the server.pem x509
certificate file in a readable format?

cat server.pem

$ openssl x509 -in server.pem

$ openssl x509 -in server.pem -text

$ cat x509 server.pem

$ openssl x509 server.pem

Detailed Answer

Correct Answer:

$ openssl x509 -in server.pem -text

All other answers are incorrect. For more information on working with encrypted
files visit the openssl documentation page.

Question 10

https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 43/64
28/10/2019 MongoDB University

Problem: Incorrect Answer Hide Details

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.

Replication

Question 1

Problem: Incorrect Answer Hide Details

Which of the following commands can be used to retrieve the size of the oplog in
a MongoDB replica set?

db.startup_log.stats()

https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 44/64
28/10/2019 MongoDB University

db.oplog.rs.stats()

rs.printReplicationInfo()

Detailed Answer

Correct Answers

rs.printReplicationInfo()

This will return the size of the oplog in both gigabytes and minutes.

db.oplog.rs.stats()

This will return all available stats on the oplog.rs collection.

Incorrect Answer

db.startup_log.stats()

This will return all available stats on the startup_log collection,


which does not tell us about the oplog.

Question 2

Problem: Incorrect Answer Hide Details

Which are valid read concerns in MongoDB?

majority

linearizable

local

Detailed Answer
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 45/64
28/10/2019 MongoDB University

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

Question 3

Problem: Incorrect 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,
"host" : "acmecorp:27018"
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 46/64
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.

Member 2 is more likely than member 0 to become primary

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

Member 1 can never become the primary

Detailed Answer

The correct answers are:

https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 47/64
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.

Question 4

Problem: Incorrect Answer Hide Details

In a 3-node replica set, which of the following write concerns is more durable
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
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 48/64
28/10/2019 MongoDB University
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 5

Problem: Incorrect 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

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.

https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 49/64
28/10/2019 MongoDB University

Question 6

Problem: Incorrect Answer Hide Details

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


MongoDB replica set?

startup_log

system.replSet

oplog.rs

Detailed Answer

Correct Answer

oplog.rs

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 7

Problem: Incorrect Answer Hide Details


https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 50/64
28/10/2019 MongoDB University

You need to set up a replica set. Which command(s) do you need to run to set up
the replica set and add 2 other nodes?

rs.add(node2); rs.add(node3); rs.initiate()

rs.initiate(); rs.add(node2); rs.reconfig()

rs.initiate(); rs.add(node2); rs.add(node3);

Detailed Answer

The correct answer is:

rs.initiate(); rs.add(node2); rs.add(node3)

rs.initiate() must be run first in order to initialize the replica set, and
rs.reconfig() should only be run if you are modifying the replica
configuration file directly.

Question 8

Problem: Incorrect 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.adminCommand({listDatabases: 1})

db.isMaster()

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

Detailed Answer
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 51/64
28/10/2019 MongoDB University
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 9

Problem: Incorrect 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:

more likely to take longer

more likely to block other operations in the application

less likely to be rolled back

https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 52/64
28/10/2019 MongoDB University
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 10

Problem: Incorrect 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.slaveOk()

rs.stepDown()

rs.reconfig()

rs.freeze()

rs.remove()

Detailed Answer

https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 53/64
28/10/2019 MongoDB University

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.

Sharding
Question 1

Problem: Incorrect Answer Hide Details

What is sharding?

a method to ensure data availability

a method of distributing data across multiple machines

a way to vertically scale

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 2
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 54/64
28/10/2019 MongoDB University
Question 2

Problem: Incorrect Answer Hide Details

In order to store data in a sharded cluster in MongoDB, you must have:

a mongos process

at least one shard

config servers

Detailed Answer

All three of these options are true.

In order to start a sharded cluster in MongoDB, you must have config servers,
which will store chunk metadata and user information, a mongos process to
route requests to the correct shards, and at least one shard to store data.

Question 3

Problem: Incorrect 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
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 55/64
28/10/2019 MongoDB University
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


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.


https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 56/64
28/10/2019 MongoDB University

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.

Question 4

Problem: Incorrect Answer Hide Details

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

shard key that is not increasing/decreasing monotically

using more than one field for the shard key

knowledge of the read and write workloads of the application

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

knowledge of the approximate size of the collection to shard

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,
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 57/64
28/10/2019 MongoDB University
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

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 5

Problem: Incorrect Answer Hide Details

When is it most beneficial to use a hashed shard key?

for fast sorts using the shard key

for geographically zoned sharding

for monotonically decreasing or increasing shard key values

https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 58/64
28/10/2019 MongoDB University
Detailed Answer

The correct answer is:

for a monotonically changing shard key

All other answers are incorrect since a hashed shard key will not be able to
support either geographically zoned sharding or fast sorts on the shard key.

Question 6

Problem: Incorrect Answer Hide Details

The config database in a sharded cluster contains information such as:

The distribution of chunks and chunk boundaries

The primary shard for a database

Hints to improve the performance of sharded queries

Detailed Answer

The config database contains a lot of information, including which shard is the
primary shard for a database and how information on chunk distribution and
boundaries.

It does not include performance hints.

Question 7

Problem: Incorrect Answer Hide Details

You have sharded the collection users with the following command:

COPY

sh shardCollection(
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 59/64
28/10/2019 MongoDB University
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)

{"isActive": true}

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


}

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

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


} }

{"name": <String>, "last_login": {"$lt": <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.

https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 60/64
28/10/2019 MongoDB University

Question 8

Problem: Incorrect Answer Hide Details

Where do all non-sharded collections get stored in a sharded cluster?

Primary shard

In all secondaries shard nodes

Config server

In all primary shard nodes

mongos

Detailed Answer

Correct Option:

Primary shard

All non-sharded collections will be stored in the database primary shard.

Incorrect Options:

Config server

The config servers do not hold any application data. Just shard metadata
information.

In all primary shard nodes

Sharded collections documents will be distributed across all shards. Non-


sharded are kept in the primary shard

In all secondaries shard nodes


https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 61/64
28/10/2019 MongoDB University

Sharded collections documents will be distributed across all shards. Non-


sharded are kept in the primary shard

mongos

The mongos does not hold any data.

Question 9

Problem: Incorrect Answer Hide Details

Given the following query:

COPY

{
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, 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

route sort by shard limit by shard sort by mongos


https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 62/64
28/10/2019 MongoDB University
route, sort_by_shard, 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, limit_by_shard, sort_by_mongos, limit_by_mongos,


skip_by_mongos

Detailed Answer

Correct Answer:

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 10

Problem: Incorrect 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

drop all data from the collection


https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 63/64
28/10/2019 p MongoDB University

load data into the collection

rename the collection

remove all shard key duplicates

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/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 64/64

You might also like