Important Bits

Mongo Stuff @ MongoDB meetup

February 14, 2014



Kevin Cearns talks about what do when things go wrong


Each process has its own log, check each log


Know your DB – what is your configuration? Read heavy or write heavy

Know your logs – OS logs, Mongo logs

Try MMS Monitoring – free service until backing up

Try mongostat

Try OS tools (vmstat)

Working set

db.runCommand({serverStatus:1, workingSet:1});

Do some math to figure out if your working set fits in memory

Database Profiler

db.setProfileLevel(x) where x is 0 (off), 1, or 2. More info on Mongo site.

Reads vs Writes

Ideally, use replica sets. Write to primary, read from secondaries


Set logging level

db.runCommand({setParameter:1, logLevel:2})

independent of MMS


Use it for anything in production. It will warn you if your ulimit for max files open is too low


Also a good tool, similar to vmstat

top, iostat, vmstat

Can tell you about hard drive issues

In general, try MMS first, and then go to system tools

Discussed running Mongo in Windows. Some people say its great, some people say it leaks memory.

Disaster Recovery Walkthroughs



Like genghis, maybe more features

Sharding is done per collection, not per DB

Shard key selection is haaard

How to select a random document in a collection

Give documents a random float

Index the field with a random float to make sorting on it fast

Do queries for 1 document with {$gte:a random number}, return only 1 document

Adam Sullovey

Written by Adam Sullovey, powered by Gatsby.
Find me on codepen, github, or at Toronto meetups.

tags: meetup, mongodb