MongoDB University - PreExamDBA
MongoDB University - PreExamDBA
MongoDB University - PreExamDBA
Exam Overview
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
Question 1
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
Question 2
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/a
COPY
Question 3
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 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
Select all statements that accurately describe how the updateOne command
works in conjunction with the $unset operator.
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
Detailed Answer
Correct Answers:
For additional description, such as using $unset with array fields see the
relevant documentation page.
Question 2
COPY
{
_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"
}
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"
}
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
the last document that matches the filter in sorted order by ObjectId
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.
Question 4
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 9/64
28/10/2019 MongoDB University
_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
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
Detailed Answer
Correct Answers
Incorrect Answers
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 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.
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
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()
this will restart the replica set with an additional node called r3
r3 will get started and become part of the replica set again
Detailed Answer
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 12/64
28/10/2019 MongoDB University
The correct answer is
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
Detailed Answer
Correct Answer
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.
Having a good compound shard key can only improve the collection
distribution because it adds a parameter for the distribution criteria.
Incorrect Answer
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
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
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
geospatial 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
multikey index
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
Select the appropriate option(s) below that should always be kept in mind
regarding indexes:
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
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" } }
)
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 17/64
28/10/2019 MongoDB University
Detailed Answer
Correct Option:
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:
The server can not use 2 locales together for a given query, only one.
Question 7
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?
Detailed Answer
Correct Options:
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.
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:
Question 8
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 19/64
28/10/2019 MongoDB University
db.employees.createIndex( { firstname: 1, la
COPY
Detailed Answer
Correct Answers:
This answer is correct. This operation will build a single index, on the
firstname and lastname fields.
Incorrect Answers:
mongod will not throw an error. It will start the index build.
Question 9
what will the query plan look like for the following query?
COPY
db.books.find(
{ "genre": "fiction", "chapters": {"$gt": "20" } }
).sort(
{ "rating": -1 }
)
Detailed Answer
Correct Answer:
Incorrect Answers
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
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?
Detailed Answer
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 22/64
28/10/2019 MongoDB University
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
Which of the following queries could use this index for filtering and sorting?
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 23/64
28/10/2019 MongoDB University
Detailed Answer
Correct Answers:
COPY
This answer is correct because the processor, price, and memoryGB form an
index prefix.
COPY
This answer is correct because the processor and price form an index prefix.
Incorrect Answer:
COPY
This answer is incorrect because the price and memoryGB do NOT form an
index prefix.
Server Administration
Question 1
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
Question 2
You are attempting to run a mongod with the following options in your terminal.
Assume the directory paths and permissions are correctly set.
The mongod is not starting. Which of the following is the most likely cause?
Detailed Answer
Correct Answer:
When running mongod with the --fork option, --logpath must be specified.
Question 3
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
List of roles granted that have privileges over the "admin" database
Detailed Answer
Correct Options:
Incorrect Option
List of roles granted that have privileges over the "admin" database
Question 4
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
Detailed Answer
Correct answer:
Incorrect answers:
from a backup, you need all the files together to have a consistant
state.
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
Detailed Answer
Correct Options:
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
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:
Question 7
You are setting up MongoDB and have enabled authorization with the following
setting in your configuration file
COPY
security:
authorization: enabled
Detailed Answer
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 30/64
28/10/2019 MongoDB University
Question 8
Detailed Answer
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
Which of the following statements is true with regard to the localhost exemption?
You can create the first user when connecting to a newly configured
You need to use the mongod user to create additional users when
connecting to a mongod for the first time.
Detailed Answer
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
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
the use of the KMIP server that is running on the local machine
storage encryption
Detailed Answer
Correct Answers:
the use of the KMIP server that is running on the local machine
storage encryption
Incorrect Answers:
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
What is the correct audit filter document that will enable logging any time a
collection in a database is created or dropped?
Detailed Answer
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 34/64
28/10/2019 MongoDB University
Correct Answer:
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
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")
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 35/64
28/10/2019 MongoDB University
Detailed Answer
Correct Option:
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.
Question 3
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.
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.
Incorrect answers
The hostname in the keyfile for each node must match the hostname for the host
it is running on.
Question 4
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
Which of the following actions is a user with the clusterManager built-in role
able to perform?
Remove shards
Detailed Answer
All of the above are actions that users with the clusterManager built-in role are
able to perform.
Question 6
Select the resource definition that best describes all collections named
products in any database.
{ "collection": "products" }
Detailed Answer
Correct Option:
This resource definition document determines that any action over this resource
will be applied on all products collections created on any database.
Incorrect Options:
{ "collection": "products" }
Question 7
Detailed Answer
Incorrect Options:
Correct Option
Question 8
COPY
db.revokePrivilegesFromRole(
"customRole",
[{ resource: { db: "stores", collection: "" },
actions: [ "find" ] }]
)
Which of the following privileges does this command remove from the
"customRole" role?
Detailed Answer
Correct Option:
Incorrect Options:
The removed privilege only applies to find commands. The ability to run
aggregation commands is not affected by revoking this privilege.
Question 9
Which shell command allows to view the contents of the server.pem x509
certificate file in a readable format?
cat server.pem
Detailed Answer
Correct Answer:
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
verify the client identity when connecting to the server using the
ca.pem file
Detailed Answer
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
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()
Incorrect Answer
db.startup_log.stats()
Question 2
majority
linearizable
local
Detailed Answer
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 45/64
28/10/2019 MongoDB University
Correct Options:
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
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
}
],
Detailed Answer
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 47/64
28/10/2019 MongoDB University
Question 4
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
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
Secondary
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
startup_log
system.replSet
oplog.rs
Detailed Answer
Correct Answer
oplog.rs
Incorrect Answers
system.replSet
startup_log
Question 7
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?
Detailed Answer
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
When connected to a replica set secondary node using the mongo shell, which of
the following set of commands will return successfully?
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"})
db.isMaster()
Question 9
Consider a write operation performed against a replica set with write concern w:
1.
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 52/64
28/10/2019 MongoDB University
Detailed Answer
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.
Question 10
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
What is sharding?
Detailed Answer
Is an incorrect answer.
Question 2
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 54/64
28/10/2019 MongoDB University
Question 2
a mongos process
config servers
Detailed Answer
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
You have the following operational requirements and benchmarks within your
organization:
Detailed Answer
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.
Question 4
Which of the following is the most important factor in choosing a shard key?
shard key for which the different values and their frequency are known
Detailed Answer
Correct Answer:
This is the most important criteria. There is often no perfect shard key, so
compromises may be needed.
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:
This will help you estimate the number of shards you may need, however not
help you identify the shard key.
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.
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
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 58/64
28/10/2019 MongoDB University
Detailed Answer
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
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.
Question 7
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}
{"name": {$exists: 1} }
Detailed Answer
Correct 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
Primary shard
Config server
mongos
Detailed Answer
Correct Option:
Primary shard
Incorrect Options:
Config server
The config servers do not hold any application data. Just shard metadata
information.
mongos
Question 9
COPY
{
find({"cast": "Meryl
Streep"}).sort({"year":1}).skip(100).limit(20)
}
And the following steps for executing such query in a sharded cluster:
Which of the following has the right steps, and in the right order?
Detailed Answer
Correct Answer:
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
Detailed Answer
https://university.mongodb.com/exam/practice/DBA/results/5da83396eb88831d73f2e247#5c8bf93422a2a6e6633c341b 64/64