Created
June 4, 2018 18:33
-
-
Save afonsoaugusto/7538021b712ef85f87ef3092f702aeca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Final Exam | |
/* | |
Which of the following are valid command line instructions to start a mongod? | |
You may assume that all specified files already exist. | |
*/ | |
mongod -f /etc/mongod.conf # ok | |
mongod --logpath /var/log/mongo/mongod.log --dbpath /data/db --fork # ok | |
mongod --dbpath /data/db --fork # BadValue: --fork has to be used with --logpath or --syslog | |
mongod --log /var/log/mongo/mongod.log --authentication # Error parsing command line: unrecognised option '--log' | |
/* | |
Given the following config file: | |
storage: | |
dbPath: /data/db | |
systemLog: | |
destination: file | |
path: /var/log/mongod.log | |
net: | |
bindIp: localhost,192.168.0.100 | |
security: | |
keyFile: /var/pki/keyfile | |
processManagement: | |
fork: true | |
How many directories must MongoDB have access to? | |
*/ | |
3 | |
/var/pki | |
/var/log | |
/data/db | |
/* | |
Given the following output from rs.status().members: | |
[ | |
{ | |
"_id": 0, | |
"name": "localhost:27017", | |
"health": 1, | |
"state": 1, | |
"stateStr": "PRIMARY", | |
"uptime": 548, | |
"optime": { | |
"ts": Timestamp(1521038871, 1), | |
"t": NumberLong("1") | |
}, | |
"optimeDate": ISODate("2018-03-14T14:47:51Z"), | |
"electionTime": Timestamp(1521038358, 2), | |
"electionDate": ISODate("2018-03-14T14:39:18Z"), | |
"configVersion": 2, | |
"self": true | |
}, | |
{ | |
"_id": 1, | |
"name": "localhost:27018", | |
"health": 1, | |
"state": 2, | |
"stateStr": "SECONDARY", | |
"uptime": 289, | |
"optime": { | |
"ts": Timestamp(1521038871, 1), | |
"t": NumberLong("1") | |
}, | |
"optimeDurable": { | |
"ts": Timestamp(1521038871, 1), | |
"t": NumberLong("1") | |
}, | |
"optimeDate": ISODate("2018-03-14T14:47:51Z"), | |
"optimeDurableDate": ISODate("2018-03-14T14:47:51Z"), | |
"lastHeartbeat": ISODate("2018-03-14T14:47:56.558Z"), | |
"lastHeartbeatRecv": ISODate("2018-03-14T14:47:56.517Z"), | |
"pingMs": NumberLong("0"), | |
"syncingTo": "localhost:27022", | |
"configVersion": 2 | |
}, | |
{ | |
"_id": 2, | |
"name": "localhost:27019", | |
"health": 1, | |
"state": 2, | |
"stateStr": "SECONDARY", | |
"uptime": 289, | |
"optime": { | |
"ts": Timestamp(1521038871, 1), | |
"t": NumberLong("1") | |
}, | |
"optimeDurable": { | |
"ts": Timestamp(1521038871, 1), | |
"t": NumberLong("1") | |
}, | |
"optimeDate": ISODate("2018-03-14T14:47:51Z"), | |
"optimeDurableDate": ISODate("2018-03-14T14:47:51Z"), | |
"lastHeartbeat": ISODate("2018-03-14T14:47:56.558Z"), | |
"lastHeartbeatRecv": ISODate("2018-03-14T14:47:56.654Z"), | |
"pingMs": NumberLong("0"), | |
"syncingTo": "localhost:27022", | |
"configVersion": 2 | |
}, | |
{ | |
"_id": 3, | |
"name": "localhost:27020", | |
"health": 1, | |
"state": 2, | |
"stateStr": "SECONDARY", | |
"uptime": 289, | |
"optime": { | |
"ts": Timestamp(1521038871, 1), | |
"t": NumberLong("1") | |
}, | |
"optimeDurable": { | |
"ts": Timestamp(1521038871, 1), | |
"t": NumberLong("1") | |
}, | |
"optimeDate": ISODate("2018-03-14T14:47:51Z"), | |
"optimeDurableDate": ISODate("2018-03-14T14:47:51Z"), | |
"lastHeartbeat": ISODate("2018-03-14T14:47:56.558Z"), | |
"lastHeartbeatRecv": ISODate("2018-03-14T14:47:56.726Z"), | |
"pingMs": NumberLong("0"), | |
"syncingTo": "localhost:27022", | |
"configVersion": 2 | |
}, | |
{ | |
"_id": 4, | |
"name": "localhost:27021", | |
"health": 0, | |
"state": 8, | |
"stateStr": "(not reachable/healthy)", | |
"uptime": 0, | |
"optime": { | |
"ts": Timestamp(0, 0), | |
"t": NumberLong("-1") | |
}, | |
"optimeDurable": { | |
"ts": Timestamp(0, 0), | |
"t": NumberLong("-1") | |
}, | |
"optimeDate": ISODate("1970-01-01T00:00:00Z"), | |
"optimeDurableDate": ISODate("1970-01-01T00:00:00Z"), | |
"lastHeartbeat": ISODate("2018-03-14T14:47:56.656Z"), | |
"lastHeartbeatRecv": ISODate("2018-03-14T14:47:12.668Z"), | |
"pingMs": NumberLong("0"), | |
"lastHeartbeatMessage": "Connection refused", | |
"configVersion": -1 | |
}, | |
{ | |
"_id": 5, | |
"name": "localhost:27022", | |
"health": 1, | |
"state": 2, | |
"stateStr": "SECONDARY", | |
"uptime": 289, | |
"optime": { | |
"ts": Timestamp(1521038871, 1), | |
"t": NumberLong("1") | |
}, | |
"optimeDurable": { | |
"ts": Timestamp(1521038871, 1), | |
"t": NumberLong("1") | |
}, | |
"optimeDate": ISODate("2018-03-14T14:47:51Z"), | |
"optimeDurableDate": ISODate("2018-03-14T14:47:51Z"), | |
"lastHeartbeat": ISODate("2018-03-14T14:47:56.558Z"), | |
"lastHeartbeatRecv": ISODate("2018-03-14T14:47:55.974Z"), | |
"pingMs": NumberLong("0"), | |
"syncingTo": "localhost:27017", | |
"configVersion": 2 | |
}, | |
{ | |
"_id": 6, | |
"name": "localhost:27023", | |
"health": 1, | |
"state": 2, | |
"stateStr": "SECONDARY", | |
"uptime": 289, | |
"optime": { | |
"ts": Timestamp(1521038871, 1), | |
"t": NumberLong("1") | |
}, | |
"optimeDurable": { | |
"ts": Timestamp(1521038871, 1), | |
"t": NumberLong("1") | |
}, | |
"optimeDate": ISODate("2018-03-14T14:47:51Z"), | |
"optimeDurableDate": ISODate("2018-03-14T14:47:51Z"), | |
"lastHeartbeat": ISODate("2018-03-14T14:47:56.558Z"), | |
"lastHeartbeatRecv": ISODate("2018-03-14T14:47:56.801Z"), | |
"pingMs": NumberLong("0"), | |
"syncingTo": "localhost:27022", | |
"configVersion": 2 | |
} | |
] | |
At this moment, how many replica set members are eligible to become primary in the event of a failover? | |
*/ | |
5 | |
/* | |
Given the following replica set configuration: | |
conf = { | |
"_id": "replset", | |
"version": 1, | |
"protocolVersion": 1, | |
"members": [ | |
{ | |
"_id": 0, | |
"host": "192.168.103.100:27017", | |
"priority": 2, | |
"votes": 1 | |
}, | |
{ | |
"_id": 0, | |
"host": "192.168.103.100:27018", | |
"priority": 1, | |
"votes": 1 | |
}, | |
{ | |
"_id": 2, | |
"host": "192.168.103.100:27018", | |
"priority": 1, | |
"votes": 1 | |
} | |
] | |
} | |
What errors are present in the above replica set configuration? | |
*/ | |
You cannot specify two members with the same _id. | |
/* | |
Given the following replica set configuration: | |
conf = { | |
"_id": "replset", | |
"version": 1, | |
"protocolVersion": 1, | |
"members": [ | |
{ | |
"_id": 0, | |
"host": "localhost:27017", | |
"priority": 1, | |
"votes": 1 | |
}, | |
{ | |
"_id": 1, | |
"host": "localhost:27018", | |
"priority": 1, | |
"votes": 1 | |
}, | |
{ | |
"_id": 2, | |
"host": "localhost:27019", | |
"priority": 1, | |
"votes": 1 | |
}, | |
{ | |
"_id": 3, | |
"host": "localhost:27020", | |
"priority": 0, | |
"votes": 0, | |
"slaveDelay": 3600 | |
} | |
] | |
} | |
What is the most likely role served by the node with "_id": 3? | |
*/ | |
It serves as a "hot" backup of data in case of accidental data loss on the other members, like a DBA accidentally dropping the database. | |
/* | |
Given the following shard key: | |
{ "country": 1, "_id": 1 } | |
Which of the following queries will be routed? Remember that queries may be routed to more than one shard. | |
*/ | |
db.customers.find({"_id": 914, "country": "Sweden"}) | |
db.customers.find({"country": "Norway", "_id": 54}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment