Mongodb certification exam questions

Mongodb certification exam questions will help you prepare and crack the mongodb certification
1) How do you monitor mongodb instances?
a) mongodb utilities
b) Ops manager
c) database commands
d) All of the above
Answer : d
Explanation : Mongodb instance should be monitored starting with set of utilities that come pre-packaged as part of mongodb. These are mainly used for reporting purposes. Database commands come handy to get details on current database statistics. In addition to this mongodb cloud manager a cloud monitoring GUI, ops manage an on-premise install that has features equivalent to mongodb cloud manager help with visualization and alerts real-time from database
2) How do you start mongod and mongos instances using config file?
a) mongod -f /etc/mongod.conf; mongos -f /etc/mongos.conf
b) mongod -a /etc/mongod.conf; mongos -a /etc/mongos.conf
c) mongod -h /etc/mongod.conf; mongos -h /etc/mongos.conf
d) mongod -s /etc/mongod.conf; mongos -s /etc/mongos.conf
Answer : a
Explanation : We can start mongod and mongos instances from command-line as well as config files. To make use of config file, we specify option -f
In Mongodb mongodb.lock file has more than zero bytes. What does this mean?
mongodb.lock is the lock file that is available in /data/db directory the data dbpath of MongoDB. This file in a normal state will be accessed by mongodb daemon and is system internal. At times when we try to start a mongodb this file may be of non-zero bytes.
This simply means that mongodb had an abnormal shutdown and attempt to startup the database in normal mode will leave db in inconsistent state
How to fix this?
Start mongodb with repair (or) repairpath option
mongod –repair command will copy the contents from datafile onto a temp file, copy back to datafile
mongod –repairpath command can be used as well
Can we delete mongodb.lock file?
mongod –repairpath command allows the deletion of this lock file
Give details on Mongodb professional paid support on community edition :-
MongoDB the most popular nosql database is gaining popularity and customer base. They are planning to go public real soon. They have recently changed their CEO who is an expert with IPO. This shows the vision of this company.
Currently MongoDB is an open-source software that can be downloaded for free. MongoDB Enterprise is catered towards enterprises
MongoDB has recently announced a bold move on supporting community edition on paid basis called as mongodb professional
Give details on MongoDB Write operation protocol enhancement :-
MongoDB modifies the document informations via write operations. This includes usual CRUD operations like insert,update, delete, bulk insert. In versions before MongoDB 2.4 all the write operations issued will return results that determines the status of write operation. rEporting the status is made possible using write concern. Write concern is integrated with write operation starting MongoDB 2.6 which comes as part of enhanced write protocol. This eliminates the need to make use of functions like db.getlasterrormessage() from clients connecting to mongoDB server
How does MongoDB make use of Journaling to handle instance crash?
MongoDB journaling mechanism is the write-ahead redo logs written to journal files that can be used to recover the database datafiles after a mongoDB daemon crash. When journaling is enabled, mongodb creates a sub-folder within dbPath folder the default location of storing datafiles.
MongoDB lets journal file grow upto 1GB in size
After hitting this size limit a new journal file is created
Journal directory holds journal files and last-sequence files
Journal files are append only files. Their names start with j._
Using mongod’s storage.smallfile runtime option we can limit size of journal file to 128MB
After a crash mongodb instance does make use of journal files and sequence number files to perform crash recovery
Give details on mongodb index types a quick overview :-
MongoDB the most popular NoSQL database offers performance improvement via index usage. As with an RDBMS indexes in mongodb are of different types and it makes good sense to choose optimal index during application design phase based on he need of application, data pattern, data distribution etc
By default all the _id primary keys in a collection have an internal index created on them. All indexes created by users are secondary indexes in a mongoDB environment. Here are some good secondary indexes:
1) TTL Index – Time to Live index is created with the setting expiretotime in seconds. All the documents are purged from collection based on this setting. For clickstreams, logs retained these kind of indexes come handy as there may not be need to store data indefinitely
2) Geospatial index – For applications utilizing geographical latitudinal. longitudinal co-ordinates these indexes come handy
3) Hash index – Hash value is generated and stored to reference the documents
4) Sparse index – Unique advantage of document data model in mongodb is that schema collections can be altered on the fly. Hence not all the documents contain all fields. For fields that contain minimal value sparse index comes handy
5) Compound indexes – Indexes are created on a single field, combination of fields and can be sorted based on combination of values. They provide optimal performance particularly in case of filter search
6) Unique indexes – The value in a field cna be made unique using unique indexes. This can be used to enforce unique constraints as well
7) Array indexes -Collection contain fields that contain arrays. All the values in an array are stored as an index for optimal search
8) Text-search index – This is an advanced index option with mongoDB that uses advanced linguistic rules for stemming, tokenization and stop words. Text search index can be created in a single field as well as more than one field
An unique advantage of mongodb over databases like mysql is that all the index types can be created with a single storage engine and there is no need to switch storage engines
Give details on MongoDB _id primary key :-
MongoDB the leading NoSQL database does store data in collections which are table equivalents in RDBMS. The row in RDBMS becomes document in mongoDB. Every document in MongoDB is uniquely identified by a primary key which takes the form _id. Lets see some quick voerview of what the _id is , how it is made , meaning of it
1) _id is the primary key in any collection that uniquely identifies a document
2) This can be inserted by user (or) system generated
3) This uniquely identifies a document
4) This is a 12 byte hesadecimal number
5) First 4 bytes represent current timestamp, next 3 bytes represents machine id, next 2 bytes represents mongod server process id, last 3 bytes is generated by system which simply increments the count
6) An unique index is internally created on _id field[column equivalent in RDBMS]
What is the significance of ulimit settings in Linux environment?
In environments running Linux/UNIX like operating system resources in the system including files, threads, network connections need to be properly regulated. It becomes essential to avoid the over usage of resources by restricting resource usage at user level.
This is possible by making use of ulimit commands. It becomes necessary to allocate resources appropriately. Too much resource leads to slow system performance, too low might lead to issue while users connect to environment.
How is an OS resource utilized in MongoDB environment?
Mongodb processes including mongod, mongos make use of threads, file descriptors to track connections and manage internal operations. Here is a general recommendation while allocating system resources for mongoDB instances:
1) 1 file descriptor for one datafile in use if this is used by mongodb instance
2) 1 file descriptor for one journal file being used by mongodb instance. This is utilized while storage.journal.enabled is set to true
3) While a replica set configuration is in place, each mongodb maintains connection to all other members of the set to replicate the information from master to slaves
Give details on Mongodb syncdelay an advanced tuning parameter :-
Syncdelay a parameter by default set to 60s in mongoDB should not be changed in most cases. Before we proceed further let us first see what is the prime purpose of syncdelay parameter?
Syncdelay determines the time interval within which mongodb flushes data to datafiles.By default it is set to 60 seconds and mongo recommends not to change this. Flushing of dirty pages from memory to datafiles on the disk in an mongodb environment happens via fsync() function. The fsync() function is called at a time duration set for syncdelay
Say, if syncdelay=90 then fsync() function is called once in 90 seconds
It is interesting to note that while we perform backup of mongodb to write-lock a mongoDB fsync function is used.If set to 0 mongodb does not flush data from memory onto disk
Give details on Mongodb remove() function to purge collection :-
Most of the database developers and DBA’s from typical RDBMS background are familiar with DML – Insert, Update, DElete. The function to insert into a collection will be db.collectionname.insert({}). With that in mind if you choose to purge an existing document from a collection using delete() function, you are not correct
> db
> db.mycollection.delete({hello:”world12″})
Sat Jan 02 12:26:40.474 TypeError: Property ‘delete’ of object test.mycollection is not a function
> db.mycollection.remove({hello:”world12″})
> db
> db.collection.find()
The above command shows that to pure a document from collection make use of remove() function

Enter your email address:

Delivered by FeedBurner