HOME SCALA & F# JAVA .NET WEB GROOVY & GRAILS ANDROID & IOS NOSQL ARCHITECTURE AGILE & SCRUM AGILE DEVELOPER  
MongoUK: Mathias Stearn on MongoDB Administration
MongoDB Administration
In this talk, Mathias Stearn presents what Ops guys need to know about MongoDB.

Here're some talk notes:
When setting up:
download and untar (thats it)
/data/db or custom --dbpath (use XFS or ext4)
--directoryperdb
startup and shutdown (ctrl-c or SIGTERM)


Getting stats:
db.serverStatus()
db.stats()
db.collection.stats()
http://localhost:28017 (server port + 1000)
http://localhost:28017/_status
mongostat tool

iostat -x 2
atop

Monitoring tool plugins:
Munin ganglia nagios cacti

Code to see stats:
db.foo.drop()
for (var i=400000; i<1000000; i++){
    db.foo.insert({_id: i});
    for (var j=0; j< 10; j++){
        db.foo.findOne({_id: (i-j)});
    }
}
Run in many mongo's to boost perf. Use htop to see where time is going.
Add a big string to show disk util.

Whats going on right now?
db.currentOp()

Use this to have a query slow enough to see:
db.foo.find({$where: 'var i=1000; while(i--); return this.blah != undefined'})

Backup
mongodump / mongorestore (online-backup)
locking or shut down
backup from slave
db._adminCommand({fsync:1, lock:1})
db.$cmd.sys.unlock.findOne()

Replication (Just Do It!)
mongod --master --oplogSize 500
mongod --slave --source localhost:27017 --port 3000 --dbpath /data/slave
local.oplog.$main
seeding a slave from a master (--fastsync)
delayed replication (--slavedelay secs)
db.printReplicationInfo()
db.printSlaveReplicationInfo()

It isn't working!?!?!
check the logs
try connecting from the shell
check http output

Going into production:
distro pkgs (we have them)
init scripts (make sure they shut down cleanly)
--fork
--logpath (internal rotation)
did I mention replication?

When there's something strange
In your server room.
When you get a page
at 2am.
Who you gonna call?


ABOUT MATHIAS STEARN
Mathias Stearn is a Software Engineer at 10gen.
More about Mathias Stearn
PODCAST MONGODB ADMINISTRATION

This session took part at the MongoUK. You can view the other 19 podcasts here.
SPONSORS
MongoDB
SOFTWARE ARCHITECTURE PODCASTS
Gael Fraiteur:Multithreading beyond the lock keyword, Multithreading
Gael Fraiteur : 24th May 2012
View Podcast: Multithreading beyond the lock keyword,
Oren Eini aka Ayende Rahien:Sharding And Scaling with RavenDB, Scaling with RavenDB
Oren Eini aka Ayende Rahien : 15th May 2012
View Podcast: Sharding And Scaling with RavenDB,
John Zablocki:Developing with Couchbase, Developing with Couchbase
John Zablocki : 9th May 2012
View Podcast: Developing with Couchbase,
Chris Harris:MongoDB and Document Databases, Document Databases
Chris Harris : 9th May 2012
View Podcast: MongoDB and Document Databases,
David Mytton:MongoDB performance at scale, MongoDB performance
David Mytton : 9th May 2012
View Podcast: MongoDB performance at scale,
John Zablocki:The Couchbase Server Tutorial, The Couchbase Server Tutorial
John Zablocki : 9th May 2012
View Podcast: The Couchbase Server Tutorial,
Chris Harris:Hands-on MongoDB, Hands-on MongoDB
Chris Harris : 9th May 2012
View Podcast: Hands-on MongoDB,
Tom McMillen:CouchDB at the Hut Group, CouchDB at the Hut Group
Tom McMillen : 9th May 2012
View Podcast: CouchDB at the Hut Group,
Jim Webber:Managing Highly Connected Data in Neo4j, Neo4j Highly Connected Data
Jim Webber : 9th May 2012
View Podcast: Managing Highly Connected Data in Neo4j,
Nicki Watt:Neo4j Tales from the Trenches: A recommendation Engine Case Study, Neo4j Tales from the Trenches
Nicki Watt : 9th May 2012
View Podcast: Neo4j Tales from the Trenches: A recommendation Engine Case Study,
Oren Eini aka Ayende Rahien:RavenDB: A 2nd generation document database, RavenDB
Oren Eini aka Ayende Rahien : 9th May 2012
View Podcast: RavenDB: A 2nd generation document database,
Phil Jones:The challenges and rewards of using RavenDB, RavenDB: challenges & rewards
Phil Jones : 9th May 2012
View Podcast: The challenges and rewards of using RavenDB,
Oren Eini aka Ayende Rahien:RavenDB Crash Course, RavenDB Crash Course
Oren Eini aka Ayende Rahien : 9th May 2012
View Podcast: RavenDB Crash Course,
Ian Robinson:A Programmatic Introduction to Neo4j, Neo4j Intro
Ian Robinson : 3rd May 2012
View Podcast: A Programmatic Introduction to Neo4j,
Brian Sletten:Information Resources : Moving Beyond Objects, Moving Beyond Objects
Brian Sletten : 3rd May 2012
View Podcast: Information Resources : Moving Beyond Objects,
OTHER SOFTWARE ARCHITECTURE EVENTS
Uncle Bob (Robert C. Martin):Uncle Bob's Advanced Test Driven Development in NYC,  Uncle Bob's Advanced Test Driven Development in NY
3 DAY COURSE. Featuring Uncle Bob (Robert C. Martin)
New York, Tuesday, May 29th
Alberto Brandolini:Eric Evans Domain Driven Design Hands-On Immersion Workshop,  Eric Evans' DDD Immersion Workshop
4 DAY COURSE. Featuring Alberto Brandolini
London, Monday, June 11th
DDD eXchange 2012, DDD eXchange 2012
CONFERENCE (1 DAY)
London, Friday, June 15th BOOK NOW!
Simon Brown:Simon Brown's Enterprise Software Developer,  Simon Brown's Enterprise Software Developer
3 DAY COURSE. Featuring Simon Brown
London, Monday, June 18th
QCon New York 2012, QCon New York 2012
CONFERENCE (3 DAYS)
New York, Monday, June 18th BOOK NOW!
Francis Sanger:Craig Larman's Applying Advanced Object Design with Patterns,  Craig Larman's Object Design w Patterns
4 DAY COURSE. Featuring Francis Sanger
London, Tuesday, June 19th
David Laribee:David Laribee's Leading Lean/Agile Teams,  David Laribee's Leading Lean/Agile Teams
2 DAY COURSE. Featuring David Laribee
New York, Thursday, June 21st
Find Your Ninja Project:Cool Projects in June , Find Your Ninja Project
FREE EVENT: Cool Projects in June
London, Monday, June 25th
© Copyright 2003-2011, Skills Matter Ltd
  Web development by You In Control
About Us  Jobs  Find Us  Meeting & Training Rooms  Newsletter  Jobs: Sales Executive  Jobs: Student SkillsCaster  jobs - junior event coordinator  Speed Coding 2011  Open Source Journal  Ticket Raffle  Agile Expert Series  Jobs: Sponsorship Development  jobs: Marketing & Sales Graduate Internship