MongoDB

 Part II
Admin UI

There are a number of open source projects that provide an
admin console to your MongoDB instances.

Some are web UI and some are native UI applications. 

   MongoHub is a native Mac OS app that has many great
   bells and whistles (my personal fav)
   MongoVUE is a native Windows .NET
   Many Ruby web based apps that run using Sinatra and
   MongoDB driver (Futon4Mongo, Mongo3, etc)
MongoHub details

Retail time CRUD operations monitoring
Multi-database views
Detailed collection views
Interactive querying
MySQL Import / Export
Monitoring and Diagnostics

The newer versions on MongoDB come with 
   mongostat
   sudo mongosniff --source NET lo0
Could be straight forward to hook up custom Nagios
alerts and monitoring with this data
Replication
Old way < 1.6                 New way >= 1.6
How it all works

MongoDB has a primary node who does the writes
The data is then replicated to the rest of the set
MongoDB has auto fail-over so if the current primary
pukes, then another node is "elected"
A write is theoretically complete when a "majority" of
the nodes in the set received the data
   ma·jor·i·ty noun mə-ˈjor-ə-tē
      In MongoDB terms it means there is at least 1
      primary and at least 1 other node running
      If only 1 node is left standing...well that sucks
The Ugly Truth

If a node fails-over during replication and all the nodes
haven't received it...
The data drops ;..(
MongoDB Make Believe Land




      Node 2   Node 3
MongoDB Make Believe Land




      Node 2   Node 3
MongoDB Make Believe Land




      Node 2   Node 3
MongoDB Make Believe Land




      Node 2   Node 3
How do I set that up?
Well, its super hard...
   ...NOT to do it right
I <3 MongoDB documentation
   http://www.mongodb.
   org/display/DOCS/Replica+Set+Tutorial
You can also do N nodes and 1 arbiter, where N % 2 == 0
"Shards are the secret sauce..."
I just shar(d|t)ed
Shards


                            Shard 2
Shard 1




          Node 2   Node 3
Choose wisely!

> When sharding you must
choose your shard key wisely
for an even distribution of load
and data
> It's best to choose composite
shard keys and determine the
most common queries
> Helps ensure your query
targets a single shard vs.
querying ALL shards
Map / Reduce
Map / Reduce

> You can write map/reduce
functions in the shell and with
any of the supported MongoDB
drivers
Logging with MongoDB

Got this link from the MongoDB
meetup at Engine Yard this past
week.

Thanks to Robert Stewart for
the great presentation:

http://www.slideshare.
net/WombatNation/logging-
app-behavior-to-mongo-db

MongoDB Part 2

  • 1.
  • 2.
    Admin UI There area number of open source projects that provide an admin console to your MongoDB instances. Some are web UI and some are native UI applications.  MongoHub is a native Mac OS app that has many great bells and whistles (my personal fav) MongoVUE is a native Windows .NET Many Ruby web based apps that run using Sinatra and MongoDB driver (Futon4Mongo, Mongo3, etc)
  • 3.
    MongoHub details Retail timeCRUD operations monitoring Multi-database views Detailed collection views Interactive querying MySQL Import / Export
  • 4.
    Monitoring and Diagnostics Thenewer versions on MongoDB come with  mongostat sudo mongosniff --source NET lo0 Could be straight forward to hook up custom Nagios alerts and monitoring with this data
  • 5.
    Replication Old way <1.6 New way >= 1.6
  • 6.
    How it allworks MongoDB has a primary node who does the writes The data is then replicated to the rest of the set MongoDB has auto fail-over so if the current primary pukes, then another node is "elected" A write is theoretically complete when a "majority" of the nodes in the set received the data ma·jor·i·ty noun mə-ˈjor-ə-tē In MongoDB terms it means there is at least 1 primary and at least 1 other node running If only 1 node is left standing...well that sucks
  • 7.
    The Ugly Truth Ifa node fails-over during replication and all the nodes haven't received it... The data drops ;..(
  • 8.
    MongoDB Make BelieveLand Node 2 Node 3
  • 9.
    MongoDB Make BelieveLand Node 2 Node 3
  • 10.
    MongoDB Make BelieveLand Node 2 Node 3
  • 11.
    MongoDB Make BelieveLand Node 2 Node 3
  • 12.
    How do Iset that up? Well, its super hard... ...NOT to do it right I <3 MongoDB documentation http://www.mongodb. org/display/DOCS/Replica+Set+Tutorial You can also do N nodes and 1 arbiter, where N % 2 == 0
  • 13.
    "Shards are thesecret sauce..."
  • 14.
  • 15.
    Shards Shard 2 Shard 1 Node 2 Node 3
  • 16.
    Choose wisely! > Whensharding you must choose your shard key wisely for an even distribution of load and data > It's best to choose composite shard keys and determine the most common queries > Helps ensure your query targets a single shard vs. querying ALL shards
  • 17.
  • 18.
    Map / Reduce >You can write map/reduce functions in the shell and with any of the supported MongoDB drivers
  • 19.
    Logging with MongoDB Gotthis link from the MongoDB meetup at Engine Yard this past week. Thanks to Robert Stewart for the great presentation: http://www.slideshare. net/WombatNation/logging- app-behavior-to-mongo-db