Sunday, 27 November 2016

MongoDB University Course M102: MongoDB for DBAs

My first introduction to MongoDB was to sign up to university.mongodb.com and take the course M102: MongoDB for DBAs. This is the basic course for DBAs and while I wouldn't say it made me feel production-ready, it demystified MongoDB and gave me a good overview of JSON and the various MongoDB concepts.

The course lectures are provided via YouTube videos as normal with MongoDB University and the practical side is performed on a personal MongoDB installation.

I installed the latest version of MongodDB version 3.2.6 for Windows although the course recommended 3.2.2. However, I didn't have any problems related to the version.

I did encounter some problems due to starting MongoDB without the necessary permissions. This comes from how you start the Windows command line interface, cmd.exe. Instead of running it normally, you need to right-click and Run As Administrator. Then when you start your MongoDB processes they will function correctly. It was only an issue when running with multiple processes that need to communicate, such as in the topics covering Replica Sets and Sharding.

I took the May 2016 release of the course and passed with a 100% grade.

The questions were all quite straightforward and covered in the online course material.

Chapter 1: Introduction 
Introduction to MongoDB, key concepts and installing Mongo

Homework 1.1
What do you get as a result?


Homework 1.2
What's the result?


Homework 1.3
Now, what query would you run to get all the products where brand equals the string "ACME"?


Homework 1.4
Check all that apply:
 var c = db.products.find( { }, { name : 1, _id : 0 } ).sort( { name : 1 } ); while( c.hasNext() ) { print( c.next().name); }
 var c = db.products.find( { } ).sort( { name : 1 } ); c.forEach( function( doc ) { print( doc.name ) } );


Chapter 2: CRUD and Administrative Commands  
Creating, reading and updating data

Homework 2.1
What is the output? (The above will check that products_bak is populated.)


Homework 2.2
What is the output?


Homework 2.3
How many products have a voice limit? (That is, have a voice field present in the limits subdocument.)



Chapter 3: Performance 
Indexing and monitoring

Homework 3.1
When you are done, run:
homework.a()
and enter the numeric result below (no spaces).


Homework 3.2
Once you have eliminated the slow operation, run (on your second tab):
homework.c()
and enter the output below. Once you have it right and are ready to move on, ctrl-c (terminate) the shell that is still running the homework.b() function.


Homework 3.3
  • Q1: How many products match this query?
  • Q2: Run the same query, but this time do an explain(). How many documents were examined?
  • Q3: Does the explain() output indicate that an index was used?
Check all that apply:
Which of the following are available in WiredTiger but not in MMAPv1? Check all that apply.
Check all that apply:


Chapter 4: Replication 
Replication, Failover, Recovery
Homework 4.1
Now run:
homework.a()
and enter the result. This will simply confirm all the above happened ok.

Homework 4.2
Once done with that, run
homework.b()
in the mongo shell and enter that result below.

Homework 4.3
Once you have two secondary servers, both of which have sync'd with the primary and are caught up, run (on your primary):
homework.c()
and enter the result below.

Homework 4.4
When done, run:
> homework.d()
and enter the result.

Homework 4.5
What result does this expression give when evaluated?
db.oplog.rs.find( { } ).sort( { $natural : 1 } ).limit( 1 ).next( ).o.msg[0]

Chapter 5: Replication Part 2 
Optimizing and monitoring your Replica Sets
Homework 5.1
what is the text in the "state" field for the arbiter when you run rs.status()?

Homework 5.2
Which of the following options will allow you to ensure that a primary is available during server maintenance, and that any writes it receives will replicate during this time?

Homework 5.3
You only have two data centers available. Which arrangement(s) of servers will allow you to be stay up (as in, still able to elect a primary) in the event of a failure of either data center (but not both at once)? Check all that apply.

Homework 5.4
Find out the optional parameter that you'll need, and input it into the box below for your rs.reconfig(new_cfg, OPTIONAL PARAMETER).

Chapter 6: Scalability 
Sharding setup, sharding monitoring, shard key selection, inserting large amounts of data
Homework 6.1
Run homework.a() and enter the result below. This method will simply verify that this simple cluster is up and running and return a result key.

Homework 6.2
Run homework.b() to verify the above and enter the return value below.

Homework 6.3
When done, run homework.c() and enter the result value.

Chapter 7: Backup and Recovery 
Security, backups and restoring for backups

Final Exam:
Question 1:
How many documents do you have?

Question 2:
Question: Which of the following are true about mongodb's operation in these scenarios? Check all that apply.
Check all that apply.
Choose the best answer:

Reconfigure the replica set so that the third member can never be primary. Then run:
$ mongo --shell a.js --port 27003
And run:
> part4()
And enter the result in the text box below (with no spaces or line feeds just the exact value returned).

Which of these statements is true?
Check all that apply:

db.postings.find( { "comments.flagged" : true } )

db.postings.update(
  { _id: . . . , voters:{$ne:'joe'} },
  { $inc : {votes:1}, $push : {voters:'joe'} } );



Question 6:
Which of these statements is true?
Check all that apply:

Question 7:
Which of these statements is true?
Check all that apply:
Once you have the config server running, confirm the restore of the config server data by running the last javascript line below in the mongo shell, and entering the 5 character result it returns.
Connect to the mongos with a mongo shell. Run this:
use snps
var x = db.elegans.aggregate( [ { $match : { N2 : "T" } } , { $group : { _id:"$N2" , n : { $sum : 1 } } } ] ).next(); print( x.n )
Enter the number output for n.
Based on the explain output, which of the following statements below are true?
Check all that apply:

 

5 comments:

  1. The blog is so interactive and Informative , you should write more blogs like this
    Full Stack Training in Hyderabad
    Full Stack Training in Ameerpet

    ReplyDelete
  2. Good post and informative. Thank you very much for sharing this good article, it was so good to read and useful to improve my knowledge as updated, keep blogging. This article is very much helpful and i hope this will be an useful information for the needed one.Keep on updating these kinds of informative things.
    oracle training in chennai

    oracle training institute in chennai

    oracle training in bangalore

    oracle training in hyderabad

    oracle training

    oracle online training

    hadoop training in chennai

    hadoop training in bangalore




    ReplyDelete
  3. Its really helpful for the users of this site. I am also searching about these type of sites now a days. MongoDB Training in Bangalore

    ReplyDelete
  4. This is the exact information I am been searching for, Thanks for sharing the required infos with the clear update and required points. To appreciate this I like to share some useful information

    Mongodb Training in Bangalore

    ReplyDelete