2. 2
• Recap from last session
• Monitoring Tools
– MongoDB command line and shell
• Key Metrics in MongoDB
• Logs
– Log levels
– mtools
• Disk saturation
Agenda
3. 3
• Virtual Genius Bar
– Use the chat to post
questions
– EMEA Solution
Architecture / Support
team are on hand
– Make use of them
during the sessions!!!
Q & A
5. 5
• mongodump & mongorestore
• File system copy
• Files system snapshot
• Don’t use mongoimport & mongoexport!
Backup Tools & Approaches
//mongodump Example
server> mongodump -h myhost -d cms -c articles
6. 6
• Creates a .bson file
– (and a json metadata
file)
– Over network or direct
from file system.
Mongodump
>mongodump –h myhost -d cms -c articles
connected to: myhost
2014-04-16T12:54:56.758+0100 DATABASE: cms to dump/cms
2014-04-16T12:54:56.759+0100 cms.articles to
dump/cms/articles.bson
2014-04-16T12:54:56.816+0100 7 documents
2014-04-16T12:54:56.817+0100 Metadata for cms.articles to
dump/cms/articles.metadata.json
7. 7
• Use secondary for backup
– Or hidden secondary
• Fsync+Lock
• Balance off
– In sharded cluster
Backup Architecture
mongodump
15. 15
• Commands for access metrics
– db.serverStatus()
– workingSet analyzer
Mongo shell
//to access a subset of serverStatus output specify the sub document
>db.serverStatus().mem
{
"bits" : 64,
"resident" : 266,
"virtual" : 5920,
"supported" : true,
"mapped" : 1712,
"mappedWithJournal" : 3424
}
16. 16
• Estimates the ‘working set’ of the database
– Number of ‘pagesInMemory’ accessed in RAM over
‘overSeconds’ number of seconds.
– Default Page is 4k
– overSecond – delta between oldest and newest
WorkingSet analyzer
>db.serverStatus({ workingSet : 1 })
{
"note" : "thisIsAnEstimate",
"pagesInMemory" : 723,
"computationTimeMicros" : 4601,
"overSeconds" : 2311
}
overSeconds
decreasing or small,
workingSet could be
larger than RAM
27. 27
• Increase the log level
– See further insight to operation performance
– Index efficiency
– Document moves
– Operation time
Set log level
//Increase log level verbosity from the shell
> db.adminCommand( { setParameter:1, logLevel:1 } )
{ "was" : 0, "ok" : 1 }
>
-v [ --verbose ] be more verbose (include multiple times for more
verbosity e.g. -vvvvv)
28. 28
• Pinpoint problems
– In this example we can see that there has been a document move.
Log output example
2014-05-02T13:55:02.047+0100 [conn7] update cms.articles query: {
_id: ObjectId('532198379fb5ba99a6bd4063') } update: { $inc: {
comment_count: 1 }, $push: { comments: { $each: [ { date: new
Date(1399035302013), text: "Data locality provides an amazing
performance boost over relational" } ], $slice: -10, $sort: { date: 1 } } } }
nscanned:1 nscannedObjects:1 nmoved:1 nMatched:1 nModified:1
keyUpdates:0 numYields:0 locks(micros) w:33529 33ms
29. 29
• Log analysis (example syntax)
– Show me queries that took more than 1000 ms from 6
am to 6 pm:
• Now, graph those queries:
mtools
prompt> mlogfilter mongodb.log --from 06:00 --to 18:00 --
slow 1000 > mongodb-filtered.log
prompt> mplotqueries --logscale mongodb-filtered.log
32. 32
• iostat
– Disk IO usage
– Use to review % utilisation of disk
– High %
• If it’s sustained, you may need to increase disk IO.
– Sharding
– RAID 1+0
– Partitioning on different disk
– Provisioned IOPS
OS Tools and Paramenters
prompt> iostat –xmt 1
34. 34
• Monitor regularly
– Set alerts for changes
• Quick check with command line and shell
• View trends with MMS graphs over time
• High levels of utilisation
– Increase RAM, disk IO
– Scale out
– (Having first checked Indexes etc!)
• Database profiler (covered in Indexing session)
Summary