MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo...

157
Kristina Chodorow [email protected] MongoDB: A New Genie in the LAMP (Stack)

Transcript of MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo...

Page 1: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

Kristina [email protected]

MongoDB: A New Genie in the LAMP (Stack)

Page 2: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version
Page 3: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version
Page 4: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version
Page 5: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

a retrospective

Page 6: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

SQL invented1974

now2010

Page 7: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version
Page 8: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

SQL invented1974

now2010

Page 9: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

SQL invented1974

now2010

1979

Page 10: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

SQL invented1974

now2010

1979

Page 11: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

SQL invented1974

now2010

1979

1982-1996

Page 12: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

SQL invented1974

now2010

1995

1979

1982-1996

Page 13: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

SQL invented1974

now2010

1995

19792010

1982-1996

Page 14: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

until 2009...

Page 15: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

until 2009...

Page 16: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

SQL invented1974

now2010

1995

19792010

1982-1996

Page 17: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version
Page 18: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

databases

contain tables

contain rows

server

Page 19: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

databases

contain tables

contain rows

schemaserver

Page 20: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

databases

contain tables

contain rows

joins

schemaserver

Page 21: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

things have changed in the last 15 years

duh

Page 22: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version
Page 23: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version
Page 24: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version
Page 25: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version
Page 26: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

SQL invented1974

now2010

1995

19792010

1982-1996

Page 27: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

SQL invented1974

now2010

1995

19792010

1995

1982-1996

Page 28: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

SQL invented1974

now2010

1995

19792010

19952738 websites

1994

1982-1996

Page 29: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

SQL invented1974

now2010

1995

19792010

19952738 websites

1994

>10,000 websites

1995

1982-1996

Page 30: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

SQL invented1974

now2010

1995

19792010

1998

19952738 websites

1994

>10,000 websites

1995

1982-1996

Page 31: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

We should get a mainframe, old chap.

Harumph.

Page 32: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

never leave me!

Page 33: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

downtime becomes important

Page 34: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version
Page 35: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

hardware ok?

Page 36: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

hardware ok?

failover to slave

no

Page 37: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

hardware ok?

failover to slave

fsck worked?

yes

no

Page 38: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

hardware ok?

failover to slave

fsck worked?

yes

no

no

Page 39: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

hardware ok?

failover to slave

fsck worked?

transaction log

yes

yes

no

no

Page 40: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

hardware ok?

failover to slave

fsck worked?

transaction log

yes

yes

nono

no

Page 41: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

hardware ok?

failover to slave

fsck worked?

transaction log yay!

yes

yes

yes

nono

no

Page 42: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

hardware ok?

failover to slave

fsck worked?

transaction log yay!

yes

yes

yes

nono

no

Page 43: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

SQL invented1974

now2010

1995

19792010

1998

19952738 websites

1994

>10,000 websites

1995

1982-1996

Page 44: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

SQL invented1974

now2010

1995

19792010

2004

1998

19952738 websites

1994

>10,000 websites

1995

1982-1996

Page 45: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

SQL invented1974

now2010

1995

19792010

2004

1998

1995

BigTable2004

2738 websites1994

>10,000 websites

1995

1982-1996

Page 46: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

SQL invented1974

now2010

1995

19792010

MapReduce2005

2004

1998

1995

BigTable2004

2738 websites1994

>10,000 websites

1995

1982-1996

Page 47: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version
Page 48: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

you left me!

Page 49: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

eh, whatever.

Page 50: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version
Page 51: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

prod1.example.com

prod2.example.com

Page 52: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

prod1.example.com

prod2.example.com

Page 53: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

prod1.example.com

prod2.example.com

Page 54: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

prod1.example.com

prod2.example.com

Page 55: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version
Page 56: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

prod1.example.com

prod2.example.com

Page 57: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

prod1.example.com

prod2.example.com

Page 58: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

prod1.example.com ?

prod2.example.com

Page 59: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

prod2.example.com

prod1.example.com

Page 60: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

prod2.example.com

prod1.example.com

?

Page 61: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

prod2.example.com

prod1.example.com

Page 62: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

prod2.example.com

prod1.example.com

Page 63: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

primary

secondary

passive

secondary

Page 64: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

secondary

passive

secondary

My priority is 2 My priority is

1

Page 65: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

primary

passive

secondary

Page 66: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

secondary

passive

secondary

I'm 3ms behind

I'm 2ms behind

Page 67: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

secondary

passive

primary

Page 68: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

passive

I'll still take reads.

Page 69: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version
Page 70: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version
Page 71: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version
Page 72: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version
Page 73: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

okay

Page 74: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

?

Page 75: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

make sure two slaves have

this

Page 76: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version
Page 77: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version
Page 78: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version
Page 79: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

all set

Page 80: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version
Page 81: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version
Page 82: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

EXCEPTION

Page 83: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

EXCEPTION

Page 84: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

EXCEPTION

Page 85: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version
Page 86: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

SQL invented1974

now2010

1995

19792010

MapReduce2005

2004

1998

1995

BigTable2004

2738 websites1994

>10,000 websites

1995

1982-1996

2007

Page 87: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

Application

PHP

Linux

Apache

Page 88: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

getting started

Page 89: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

www.mongodb.org

Page 90: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

$ mysqld

Page 91: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

$ mongod

Page 92: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

$ mysql

Page 93: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

$ mongo

Page 94: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

$ mongoMongoDB shell version 1.6.0connecting to: test>

Page 95: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

$ mongoMongoDB shell version 1.6.0connecting to: test> db

Page 96: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

$ mongoMongoDB shell version 1.6.0connecting to: test> dbtest>

Page 97: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

$ mongoMongoDB shell version 1.6.0connecting to: test> dbtest>

NO ADMINISTRATION

Page 98: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

$ mongoMongoDB shell version 1.6.0connecting to: test> dbtest> table = db.foo

Page 99: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

server

Page 100: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

databases

server

Page 101: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

databases

contain tables

server

Page 102: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

databases

contain tables

server

Page 103: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

databases

contain tables

server

collections

Page 104: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

databases

contain rows

server

contain tables collections

Page 105: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

databases

contain rows

server

contain tables collections

Page 106: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

databases

contain rows

server

contain tables collections documents

Page 107: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

databases

contain rows

server

contain tables collections documents

schema

Page 108: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

databases

contain rows

server

contain tables collections documents

schema

joins

Page 109: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

databases

contain collections

contain documents

server

Page 110: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

$ mongoMongoDB shell version 1.5.5url: testconnecting to: testtype "help" for help> dbtest> collection = db.foo

Page 111: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

$ mongoMongoDB shell version 1.5.5url: testconnecting to: testtype "help" for help> dbtest> collection = db.foo

NO ADMINISTRATION

Page 112: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

{ "name" : "kristina", "contact info" : { "twitter" : "@kchodorow", "email" : "[email protected]" }, "friends" : 400232, "pic" : BinData(...) "member since" : new Date()}

Page 113: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

> doc = { "name" : "kristina", "contact info" : { "twitter" : "@kchodorow", "email" : "[email protected]" }, "friends" : 400232, "pic" : BinData(...) "member since" : new Date()}

Page 114: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

> db.foo.insert(doc)

Page 115: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

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

Page 116: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

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

> db.foo.findOne({... "contact.twitter" : "@kchodorow"})

Page 117: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

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

> db.foo.findOne({... "contact.twitter" : "@kchodorow"})

> db.foo.find({... "member since" : {... "$gt" : yesterday,... "$lt" : today... }})

Page 118: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

> 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 119: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

db.people.update( {name : "kristina"},

Page 120: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

db.people.update( {name : "kristina"}, {$set :

Page 121: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

db.people.update( {name : "kristina"}, {$set : {"contact.website" : "snailinaturtleneck.com"}});

Page 122: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

> db.pageviews.update( {url : "example.com"}, {$inc : {pageviews : 1}}, true)

Page 123: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version
Page 124: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version
Page 125: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

some features

Page 126: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

I suddenly have a deep love for stored

procedures

Page 127: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

I suddenly have a deep love for stored

procedures

now wi

th store

d

procedu

res!

Page 128: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

> db.system.js.insert({

"_id" : "x",

"value" : 3});

> db.system.js.insert({

"_id" : "y",

"value" : 4});

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

Page 129: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

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

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

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

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

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

... }})

Page 130: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

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

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

Page 131: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

> 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 132: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version
Page 133: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version
Page 134: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version
Page 135: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version
Page 136: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

capped collections

Page 137: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

indexes

Page 138: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

geospatial indexes

Page 139: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version
Page 140: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

MapReduce

Page 141: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

scaling

Page 142: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version
Page 143: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

(rdbms)

Page 144: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version
Page 145: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

silly putty

Page 146: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version
Page 147: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version
Page 148: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

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

Page 149: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

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

I want Mark through Sarah.

Page 150: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

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

Page 151: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

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

Page 152: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

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

Insert Linus

Page 153: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

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

Insert Linus

Page 154: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

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

Page 155: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

$ mongoMongoDB shell version 1.6.0connecting to: test>

Page 156: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

$ mongoMongoDB shell version 1.6.0connecting to: test> db.foo.insert({x:1})

Page 157: MongoDB: A New Genie in the LAMP (Stack)€¦ · getting started. $ mysqld $ mongod $ mysql $ mongo $ mongo MongoDB shell version 1.6 ... > db test > $ mongo MongoDB shell version

thank you!

@kchodorow

http://www.snailinaturtleneck.com