introduction to mongodb - o'reilly mediaassets.en.oreilly.com/1/event/45/introduction to...

132
Kristina Chodorow [email protected] Introduction to MongoDB

Upload: phamdat

Post on 09-Mar-2018

252 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

Kristina [email protected]

Introduction to MongoDB

Page 2: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"
Page 3: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

Application

PHP

Linux

DatabaseApache

Page 4: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

Application

PHP

Windows

IIS

Page 5: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

Application

PHP

Linux

Apache

Page 6: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

Application

PHP

Linux

Apache

Page 7: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

Application

PHP

Linux

Apache

Page 8: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

Application

PHP

Linux

Apache

The world's mostpopular open source

database

Page 9: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

Application

PHP

Linux

Apache

The world's mostadvanced open source

database

Page 10: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"
Page 11: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

databases

contain tables

contain rows

server

Page 12: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

databases

contain tables

contain rows

schemaserver

Page 13: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

databases

contain tables

contain rows

joins

schemaserver

Page 14: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

databases

contain tables

contain rows

joins

schemaserver

Page 15: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"
Page 16: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"
Page 17: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"
Page 18: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"
Page 19: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

Application

Perl

Linux

Apache

Page 20: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

getting started

Page 21: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

www.mongodb.org

Page 22: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

$ mysqld

Page 23: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

$ mongod

Page 24: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

$ mysql

Page 25: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

$ mongo

Page 26: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

$ mongo

MongoDB shell version 1.5.5

url: test

connecting to: test

type "help" for help

>

Page 27: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

$ mongo

MongoDB shell version 1.5.5

url: test

connecting to: test

type "help" for help

> db

Page 28: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

$ mongo

MongoDB shell version 1.5.5

url: test

connecting to: test

type "help" for help

> db

test

>

Page 29: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

$ mongo

MongoDB shell version 1.5.5

url: test

connecting to: test

type "help" for help

> db

test

>

Page 30: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

$ mongo

MongoDB shell version 1.5.5

url: test

connecting to: test

type "help" for help

> db

test

> table = db.foo

Page 31: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

server

Page 32: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

databases

server

Page 33: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

databases

contain tables

server

Page 34: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

databases

contain tables

server

Page 35: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

databases

contain tables

server

Page 36: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

databases

contain rows

server

contain tables

Page 37: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

databases

contain rows

server

contain tables

Page 38: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

databases

contain rows

server

contain tables

Page 39: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

databases

contain rows

server

contain tables

schema

Page 40: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

databases

contain rows

server

contain tables

schema

joins

Page 41: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

databases

contain collections

contain documents

server

Page 42: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

$ mongo

MongoDB shell version 1.5.5

url: test

connecting to: test

type "help" for help

> db

test

> collection = db.foo

Page 43: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

$ mongo

MongoDB shell version 1.5.5

url: test

connecting to: test

type "help" for help

> db

test

> collection = db.foo

Page 44: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

> doc = {

... "name" : "kristina",

... "contact info" : {

... "twitter" : "@kchodorow",

... "email" : "[email protected]"

... },

... "friends" : 400232,

... "pic" : BinData(...)

... "member since" : new Date()}

Page 45: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

> db.foo.insert(doc)

Page 46: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

> db.foo.findOne({"name" : "kristina"});

Page 47: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

> db.foo.findOne({"name" : "kristina"})

> db.foo.findOne({

... "contact.twitter" : "@kchodorow"})

Page 48: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

> db.foo.findOne({"name" : "kristina"})

> db.foo.findOne({

... "contact.twitter" : "@kchodorow"})

> db.foo.find({

... "member since" : {

... "$gt" : yesterday,

... "$lt" : today

... }})

Page 49: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

> db.foo.findOne({"name" : "kristina"})

> db.foo.findOne({

... "contact.twitter" : "@kchodorow"})

> db.foo.find({

... "member since" : {

... "$gt" : yesterday,

... "$lt" : today

... }}).sort({friends : 1}).limit(10).

... skip(100)

Page 50: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

db.people.update(

{name : "kristina"},

Page 51: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

db.people.update(

{name : "kristina"},

{$set :

Page 52: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

db.people.update(

{name : "kristina"},

{$set :

{"contact.website" :

"snailinaturtleneck.com"

}});

Page 53: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

> db.pageviews.update(

{url : "example.com"},

{$inc : {pageviews : 1}},

true)

Page 54: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"
Page 55: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"
Page 56: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

some features

Page 57: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

I suddenly have a deep love for stored procedures

Page 58: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

I suddenly have a deep love for stored procedures

Page 59: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

> db.system.js.insert({

"_id" : "x",

"value" : 3});

> db.system.js.insert({

"_id" : "y",

"value" : 4});

> db.eval("return x+y")

Page 60: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

> db.system.js.insert({_id : "log",

... value : function(msg, level) {

... var date = "[" + new Date() + "] ";

... var lvl = level ? level+" " : "";

... print(date + lvl + msg);

... }})

Page 61: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

> db.eval("log('all your base are

belong to us', 'FATAL');");

Page 62: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

> db.eval("log('all your base are

belong to us', 'FATAL');");

[Fri May 19 18:34:57] FATAL all your

base are belong to us

Page 63: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"
Page 64: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"
Page 65: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

J J J

J J J

J J J

Page 66: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"
Page 67: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

capped collections

Page 68: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

indexes

Page 69: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

geospatial indexes

Page 70: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"
Page 71: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

MapReduce

Page 72: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

what did we leave out?

Page 73: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"
Page 74: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

I say, we should get a mainframe, old chap.

Harumph.

Page 75: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"
Page 76: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"
Page 77: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"
Page 78: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

are you practicing safedata storage?

Page 79: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"
Page 80: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

Insert this.

Okay, got it.

Phew, my data's safe.

Page 81: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

Write this to disk

All over it!

I know better than

he does, I'll just

let this sit in a

buffer for a while.

Page 82: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"
Page 83: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

? I have no idea what

you're talking about.

Page 84: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

trust no one!

...trust a bunch of ones. Mostly.

Page 85: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

prod1.example.com

prod2.example.com

Page 86: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

prod1.example.com

prod2.example.com

Page 87: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

prod1.example.com

prod2.example.com

Page 88: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

prod1.example.com

prod2.example.com

Page 89: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"
Page 90: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

prod1.example.com

prod2.example.com

Page 91: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

prod1.example.com

prod2.example.com

Page 92: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

prod1.example.com ?

prod2.example.com

Page 93: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

prod2.example.com

prod1.example.com

Page 94: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

prod2.example.com

prod1.example.com

?

Page 95: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

prod2.example.com

prod1.example.com

Page 96: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

prod2.example.com

prod1.example.com

Page 97: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

primary

secondary

passive

secondary

Page 98: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

secondary

passive

secondary

My priority is 2

My priority is 1

Page 99: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

primary

passive

secondary

Page 100: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

secondary

passive

secondary

I'm 5 minutes behind the master

I'm 3 seconds behind the master

Page 101: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

secondary

passive

primary

Page 102: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

passive

I'll still take reads.

Page 103: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"
Page 104: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"
Page 105: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"
Page 106: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"
Page 107: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

okay

Page 108: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

?

Page 109: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

make sure two slaves have this

Page 110: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"
Page 111: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"
Page 112: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"
Page 113: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

all set

Page 114: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"
Page 115: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"
Page 116: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"
Page 117: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"
Page 118: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"
Page 119: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"
Page 120: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

scaling

Page 121: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"
Page 122: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

(rdbms)

Page 123: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

U - ZK - OA - E F - J P - T

Page 124: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

U - ZK - OA - E F - J P - T

I want Mark through Sarah.

Page 125: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

U - ZK - OA - E F - J P - T

Page 126: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

U - ZK - OA - E F - J P - T

Page 127: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

U - ZK - OA - E F - J P - T

Insert Linus

Page 128: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

U - ZK - OA - E F - J P - T

Insert Linus

Page 129: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

U - ZK - OA - E F - J P - T

Page 130: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

$ mongo

MongoDB shell version 1.5.5

url: test

connecting to: test

type "help" for help

>

Page 131: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

$ mongo

MongoDB shell version 1.5.5

url: test

connecting to: test

type "help" for help

> db.foo.insert({x:1})

Page 132: Introduction to MongoDB - O'Reilly Mediaassets.en.oreilly.com/1/event/45/Introduction to MongoDB... · $ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help"

thank you!

@kchodorow

http://www.snailinaturtleneck.com