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
John T. Davies:Enterprise Integration - The seriously nasty stuff, Enterprise Integration
John T. Davies : 12th Dec 2011
View Podcast: Enterprise Integration - The seriously nasty stuff,
Uncle Bob (Robert C. Martin):Why can't anyone get Web architecture right?, Web architecture
Uncle Bob (Robert C. Martin) : 28th Nov 2011
View Podcast: Why can't anyone get Web architecture right?,
Simon Brown:The Frustrated Architect, Frustrated Architect
Simon Brown : 15th Nov 2011
View Podcast: The Frustrated Architect,
Emil Eifrem:The State of NOSQL Today, State of NOSQL
Emil Eifrem : 2nd Nov 2011
View Podcast: The State of NOSQL Today,
Dave Gardner:Real Life Cassandra, Cassandra
Dave Gardner : 2nd Nov 2011
View Podcast: Real Life Cassandra,
Ian Robinson:Doctor Who and Neo4j, Dr Who & Neo4j
Ian Robinson : 2nd Nov 2011
View Podcast: Doctor Who and Neo4j,
Brendan McAdams:MongoDB + Scala: Case Classes, Documents and Shards for a New Data Model, MongoDB + Scala: Case Classes, Documents
Brendan McAdams : 2nd Nov 2011
View Podcast: MongoDB + Scala: Case Classes, Documents and Shards for a New Data Model,
Simon Waterer:Introduction to Platform MapReduce, Introduction to Platform MapReduce
Simon Waterer : 12th Oct 2011
View Podcast: Introduction to Platform MapReduce,
Scott Cranton:Getting Started with FuseIDE, Get started - FuseIDE
Scott Cranton : 27th Sep 2011
View Podcast: Getting Started with FuseIDE,
Martin Sustrik:The Future of Messaging, Messaging's Future
Martin Sustrik : 23rd Sep 2011
View Podcast: The Future of Messaging,
Andy Piper:Introducing MQTT, Introducing MQTT
Andy Piper : 23rd Sep 2011
View Podcast: Introducing MQTT,
Marek Majkowski:Realtime web: Not there yet!, Realtime web: Not there yet!
Marek Majkowski : 23rd Sep 2011
View Podcast: Realtime web: Not there yet!,
Julien Genestoux:PubSub for the web : PubSubHubbub, XMPP and Superfeedr, PubSub for the web : PubSubHubbub, XMPP
Julien Genestoux : 23rd Sep 2011
View Podcast: PubSub for the web : PubSubHubbub, XMPP and Superfeedr,
Udi Dahan:Q&A with Udi Dahan, Q&A with Udi Dahan
Udi Dahan : 13th Sep 2011
View Podcast: Q&A with Udi Dahan,
Simon Brown:Load Testing for Developers, Load Testing for Developers
Simon Brown : 5th Sep 2011
View Podcast: Load Testing for Developers,
OTHER SOFTWARE ARCHITECTURE EVENTS
Alberto Brandolini:Eric Evans Domain Driven Design Hands-On Immersion Workshop,  Eric Evans' DDD Immersion Workshop
4 DAY COURSE. Featuring Alberto Brandolini
London, Monday, February 13th
Alberto Brandolini Drive your DBA Crazy in 3 easy steps,  Drive your DBA Crazy in 3 easy steps
FREE EVENT: In The Brain of Alberto Brandolini
London, Tuesday, February 14th
Andreas Ohlund:Udi Dahan's Enterprise Development with NServiceBus,  Udi Dahan's NServiceBus Workshop
4 DAY COURSE. Featuring Andreas Ohlund
London, Monday, February 20th
Andreas Ohlund Putting your events on a diet,  Putting your events on a diet
FREE EVENT: In The Brain of Andreas Ohlund
London, Monday, February 20th
Itamar  Syn-Hershko:Ayende Rahien's RavenDB Workshop,  Ayende Rahien's RavenDB Workshop
2 DAY COURSE. Featuring Itamar Syn-Hershko
London, Tuesday, February 28th
QCon London 2012, QCon London 2012
CONFERENCE (3 DAYS)
London, Wednesday, March 7th BOOK NOW!
Elevate Events:Elevate Launch Event - The SAAS Platform Connecting Contractors and Hiring Clients, Elevate Events
FREE EVENT: Elevate Launch Event
London, Wednesday, March 7th
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, Monday, March 12th
© 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