Kristina Chodorow kristina@mongodb.org
MongoDB: A New Genie in the LAMP (Stack) Kristina Chodorow - - PowerPoint PPT Presentation
MongoDB: A New Genie in the LAMP (Stack) Kristina Chodorow - - PowerPoint PPT Presentation
MongoDB: A New Genie in the LAMP (Stack) Kristina Chodorow kristina@mongodb.org a retrospective SQL invented now 1974 2010 SQL invented now 1974 2010 SQL invented now 1974 2010 1979 SQL invented now 1974 2010 1979 SQL
a retrospective
SQL invented 1974 now 2010
SQL invented 1974 now 2010
SQL invented 1974 now 2010 1979
SQL invented 1974 now 2010 1979
SQL invented 1974 now 2010 1979 1982-1996
SQL invented 1974 now 2010 1995 1979 1982-1996
SQL invented 1974 now 2010 1995 1979 2010 1982-1996
until 2009...
until 2009...
SQL invented 1974 now 2010 1995 1979 2010 1982-1996
databases
contain tables contain rows
server
databases
contain tables contain rows
schema server
databases
contain tables contain rows
joins schema server
things have changed in the last 15 years
duh
SQL invented 1974 now 2010 1995 1979 2010 1982-1996
SQL invented 1974 now 2010 1995 1979 2010 1995 1982-1996
SQL invented 1974 now 2010 1995 1979 2010 1995 2738 websites 1994 1982-1996
SQL invented 1974 now 2010 1995 1979 2010 1995 2738 websites 1994 >10,000 websites 1995 1982-1996
SQL invented 1974 now 2010 1995 1979 2010 1998 1995 2738 websites 1994 >10,000 websites 1995 1982-1996
We should get a mainframe, old chap. Harumph.
never leave me!
downtime becomes important
hardware
- k?
hardware
- k?
failover to slave no
hardware
- k?
failover to slave fsck worked? yes no
hardware
- k?
failover to slave fsck worked? yes no no
hardware
- k?
failover to slave fsck worked? transaction log yes yes no no
hardware
- k?
failover to slave fsck worked? transaction log yes yes no no no
hardware
- k?
failover to slave fsck worked? transaction log yay! yes yes yes no no no
hardware
- k?
failover to slave fsck worked? transaction log yay! yes yes yes no no no
SQL invented 1974 now 2010 1995 1979 2010 1998 1995 2738 websites 1994 >10,000 websites 1995 1982-1996
SQL invented 1974 now 2010 1995 1979 2010 2004 1998 1995 2738 websites 1994 >10,000 websites 1995 1982-1996
SQL invented 1974 now 2010 1995 1979 2010 2004 1998 1995 BigTable 2004 2738 websites 1994 >10,000 websites 1995 1982-1996
SQL invented 1974 now 2010 1995 1979 2010 MapReduce 2005 2004 1998 1995 BigTable 2004 2738 websites 1994 >10,000 websites 1995 1982-1996
you left me!
eh, whatever.
prod1.example.co m prod2.example.co m
prod1.example.co m prod2.example.co m
prod1.example.co m prod2.example.co m
prod1.example.co m prod2.example.co m
prod1.example.co m prod2.example.co m
prod1.example.co m prod2.example.co m
prod1.example.co m
?
prod2.example.co m
prod2.example.co m prod1.example.co m
prod2.example.co m prod1.example.co m
?
prod2.example.co m prod1.example.co m
prod2.example.co m prod1.example.co m
primary secondary passive secondary
secondary passive secondary
My priority is 2 My priority is 1
primary passive secondary
secondary passive secondary
I'm 3ms behind I'm 2ms behind
secondary passive primary
passive
I'll still take reads.
- kay
?
make sure two slaves have this
all set
EXCEPTION
EXCEPTION
E
SQL invented 1974 now 2010 1995 1979 2010 MapReduce 2005 2004 1998 1995 BigTable 2004 2738 websites 1994 >10,000 websites 1995 1982-1996 2007
Application PHP Linux Apache
getting started
www.mongodb.org
$ mysqld
$ mongod
$ mysql
$ mongo
$ mongo MongoDB shell version 1.6.0 connecting to: test >
$ mongo MongoDB shell version 1.6.0 connecting to: test > db
$ mongo MongoDB shell version 1.6.0 connecting to: test > db test >
$ mongo MongoDB shell version 1.6.0 connecting to: test > db test >
NO ADMINISTRATION
$ mongo MongoDB shell version 1.6.0 connecting to: test > db test > table = db.foo
server
databases server
databases
contain tables
server
databases
contain tables
server
databases
contain tables
server c
- l
l e c t i
- n
s
databases
contain rows
server
contain tables
c
- l
l e c t i
- n
s
databases
contain rows
server
contain tables
c
- l
l e c t i
- n
s
databases
contain rows
server
contain tables
c
- l
l e c t i
- n
s documents
databases
contain rows
server
contain tables
c
- l
l e c t i
- n
s documents schema
databases
contain rows
server
contain tables
c
- l
l e c t i
- n
s documents schema joins
databases
contain collections contain documents
server
$ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help" for help > db test > collection = db.foo
$ mongo MongoDB shell version 1.5.5 url: test connecting to: test type "help" for help > db test > collection = db.foo
NO ADMINISTRATION
{ "name" : "kristina", "contact info" : { "twitter" : "@kchodorow", "email" : "kristina@10gen.com" }, "friends" : 400232, "pic" : BinData(...) "member since" : new Date() }
> doc = { "name" : "kristina", "contact info" : { "twitter" : "@kchodorow", "email" : "kristina@10gen.com" }, "friends" : 400232, "pic" : BinData(...) "member since" : new Date() }
> db.foo.insert(doc)
> db.foo.findOne({"name" : "kristina"});
> db.foo.findOne({"name" : "kristina"}) > db.foo.findOne({ ... "contact.twitter" : "@kchodorow"})
> db.foo.findOne({"name" : "kristina"}) > db.foo.findOne({ ... "contact.twitter" : "@kchodorow"}) > db.foo.find({ ... "member since" : { ... "$gt" : yesterday, ... "$lt" : today ... }})
> 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)
db.people.update( {name : "kristina"},
db.people.update( {name : "kristina"}, {$set :
db.people.update( {name : "kristina"}, {$set : {"contact.website" : "snailinaturtleneck.com" }});
> db.pageviews.update( {url : "example.com"}, {$inc : {pageviews : 1}}, true)
some features
I suddenly have a deep love for stored procedures
I suddenly have a deep love for stored procedures
now with stored procedures!
> db.system.js.insert({ "_id" : "x", "value" : 3}); > db.system.js.insert({ "_id" : "y", "value" : 4}); > db.eval("return x+y")
> db.system.js.insert({_id : "log", ... value : function(msg, level) { ... var date = "[" + new Date() + "] "; ... var lvl = level ? level+" " : ""; ... print(date + lvl + msg); ... }})
> db.eval("log('all your base are belong to us', 'FATAL');");
> 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
capped collections
indexes
geospatial indexes
MapReduce
scaling
(rdbms)
silly putty
U - Z K - O A - E F - J P - T
U - Z K - O A - E F - J P - T
I want Mark through Sarah.
U - Z K - O A - E F - J P - T
U - Z K - O A - E F - J P - T
U - Z K - O A - E F - J P - T
Insert Linus
U - Z K - O A - E F - J P - T
Insert Linus
U - Z K - O A - E F - J P - T
$ mongo MongoDB shell version 1.6.0 connecting to: test >
$ mongo MongoDB shell version 1.6.0 connecting to: test > db.foo.insert({x:1})
thank you!
@kchodorow http://www.snailinaturtleneck.com