Introduction to MongoDB Presentation
-
Upload
dwarak-chaluvadi -
Category
Documents
-
view
233 -
download
0
Transcript of Introduction to MongoDB Presentation
-
8/3/2019 Introduction to MongoDB Presentation
1/132
Kristina Chodorow
Introduction to MongoDB
-
8/3/2019 Introduction to MongoDB Presentation
2/132
-
8/3/2019 Introduction to MongoDB Presentation
3/132
Application
PHP
Linux
DatabaseApache
-
8/3/2019 Introduction to MongoDB Presentation
4/132
Application
PHP
Windows
IIS
-
8/3/2019 Introduction to MongoDB Presentation
5/132
Application
PHP
Linux
Apache
-
8/3/2019 Introduction to MongoDB Presentation
6/132
Application
PHP
Linux
Apache
-
8/3/2019 Introduction to MongoDB Presentation
7/132
Application
PHP
Linux
Apache
-
8/3/2019 Introduction to MongoDB Presentation
8/132
Application
PHP
Linux
Apache
The world's most
popular open source
database
-
8/3/2019 Introduction to MongoDB Presentation
9/132
Application
PHP
Linux
Apache
The world's most
advanced open source
database
-
8/3/2019 Introduction to MongoDB Presentation
10/132
-
8/3/2019 Introduction to MongoDB Presentation
11/132
databases
contain tables
contain rows
server
-
8/3/2019 Introduction to MongoDB Presentation
12/132
databases
contain tables
contain rows
schema
server
-
8/3/2019 Introduction to MongoDB Presentation
13/132
databases
contain tables
contain rows
joins
schema
server
-
8/3/2019 Introduction to MongoDB Presentation
14/132
databases
contain tables
contain rows
joins
schema
server
-
8/3/2019 Introduction to MongoDB Presentation
15/132
-
8/3/2019 Introduction to MongoDB Presentation
16/132
-
8/3/2019 Introduction to MongoDB Presentation
17/132
-
8/3/2019 Introduction to MongoDB Presentation
18/132
-
8/3/2019 Introduction to MongoDB Presentation
19/132
Application
Perl
Linux
Apache
-
8/3/2019 Introduction to MongoDB Presentation
20/132
getting started
-
8/3/2019 Introduction to MongoDB Presentation
21/132
www.mongodb.org
-
8/3/2019 Introduction to MongoDB Presentation
22/132
$ mysqld
-
8/3/2019 Introduction to MongoDB Presentation
23/132
$ mongod
-
8/3/2019 Introduction to MongoDB Presentation
24/132
$ mysql
-
8/3/2019 Introduction to MongoDB Presentation
25/132
$ mongo
-
8/3/2019 Introduction to MongoDB Presentation
26/132
$ mongo
MongoDB shell version 1.5.5url: test
connecting to: test
type "help" for help>
-
8/3/2019 Introduction to MongoDB Presentation
27/132
$ mongo
MongoDB shell version 1.5.5url: test
connecting to: test
type "help" for help> db
-
8/3/2019 Introduction to MongoDB Presentation
28/132
$ mongo
MongoDB shell version 1.5.5url: test
connecting to: test
type "help" for help> db
test
>
-
8/3/2019 Introduction to MongoDB Presentation
29/132
$ mongo
MongoDB shell version 1.5.5url: test
connecting to: test
type "help" for help> db
test
>
-
8/3/2019 Introduction to MongoDB Presentation
30/132
$ mongo
MongoDB shell version 1.5.5url: test
connecting to: test
type "help" for help> db
test
> table = db.foo
-
8/3/2019 Introduction to MongoDB Presentation
31/132
server
-
8/3/2019 Introduction to MongoDB Presentation
32/132
databases
server
-
8/3/2019 Introduction to MongoDB Presentation
33/132
databases
contain tables
server
-
8/3/2019 Introduction to MongoDB Presentation
34/132
databases
contain tables
server
-
8/3/2019 Introduction to MongoDB Presentation
35/132
databases
contain tables
server
-
8/3/2019 Introduction to MongoDB Presentation
36/132
databases
contain rows
server
contain tables
-
8/3/2019 Introduction to MongoDB Presentation
37/132
databases
contain rows
server
contain tables
-
8/3/2019 Introduction to MongoDB Presentation
38/132
databases
contain rows
server
contain tables
-
8/3/2019 Introduction to MongoDB Presentation
39/132
databases
contain rows
server
contain tables
schema
-
8/3/2019 Introduction to MongoDB Presentation
40/132
databases
contain rows
server
contain tables
schema
joins
-
8/3/2019 Introduction to MongoDB Presentation
41/132
databases
contain collections
contain documents
server
-
8/3/2019 Introduction to MongoDB Presentation
42/132
$ mongo
MongoDB shell version 1.5.5
url: testconnecting to: test
type "help" for help
> db
test
> collection = db.foo
-
8/3/2019 Introduction to MongoDB Presentation
43/132
$ mongo
MongoDB shell version 1.5.5
url: testconnecting to: test
type "help" for help
> db
test
> collection = db.foo
-
8/3/2019 Introduction to MongoDB Presentation
44/132
> doc = {
... "name" : "kristina",
... "contact info" : {
... "twitter" : "@kchodorow",
... "email" : "[email protected]"
... },
... "friends" : 400232,
... "pic" : BinData(...)
... "member since" : new Date()}
-
8/3/2019 Introduction to MongoDB Presentation
45/132
> db.foo.insert(doc)
-
8/3/2019 Introduction to MongoDB Presentation
46/132
> db.foo.findOne({"name" : "kristina"});
-
8/3/2019 Introduction to MongoDB Presentation
47/132
> db.foo.findOne({"name" : "kristina"})
> db.foo.findOne({... "contact.twitter" : "@kchodorow"})
-
8/3/2019 Introduction to MongoDB Presentation
48/132
> db.foo.findOne({"name" : "kristina"})
> db.foo.findOne({... "contact.twitter" : "@kchodorow"})
> db.foo.find({
... "member since" : {
... "$gt" : yesterday,
... "$lt" : today
... }})
-
8/3/2019 Introduction to MongoDB Presentation
49/132
> 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)
-
8/3/2019 Introduction to MongoDB Presentation
50/132
db.people.update(
{name : "kristina"},
-
8/3/2019 Introduction to MongoDB Presentation
51/132
db.people.update(
{name : "kristina"},
{$set :
-
8/3/2019 Introduction to MongoDB Presentation
52/132
db.people.update(
{name : "kristina"},
{$set :
{"contact.website" :
"snailinaturtleneck.com"
}});
-
8/3/2019 Introduction to MongoDB Presentation
53/132
> db.pageviews.update(
{url : "example.com"},
{$inc : {pageviews : 1}},
true)
-
8/3/2019 Introduction to MongoDB Presentation
54/132
-
8/3/2019 Introduction to MongoDB Presentation
55/132
-
8/3/2019 Introduction to MongoDB Presentation
56/132
some features
-
8/3/2019 Introduction to MongoDB Presentation
57/132
I suddenly have a deep
love for stored procedures
-
8/3/2019 Introduction to MongoDB Presentation
58/132
I suddenly have a deep
love for stored procedures
-
8/3/2019 Introduction to MongoDB Presentation
59/132
> db.system.js.insert({
"_id" : "x",
"value" : 3});
> db.system.js.insert({
"_id" : "y",
"value" : 4});
> db.eval("return x+y")
-
8/3/2019 Introduction to MongoDB Presentation
60/132
> db.system.js.insert({_id : "log",
... value : function(msg, level) {
... var date = "[" + new Date() + "] ";
... var lvl = level ? level+" " : "";
... print(date + lvl + msg);
... }})
-
8/3/2019 Introduction to MongoDB Presentation
61/132
> db.eval("log('all your base are
belong to us', 'FATAL');");
-
8/3/2019 Introduction to MongoDB Presentation
62/132
> 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
-
8/3/2019 Introduction to MongoDB Presentation
63/132
-
8/3/2019 Introduction to MongoDB Presentation
64/132
-
8/3/2019 Introduction to MongoDB Presentation
65/132
J J J
J J J
J J J
-
8/3/2019 Introduction to MongoDB Presentation
66/132
-
8/3/2019 Introduction to MongoDB Presentation
67/132
capped collections
-
8/3/2019 Introduction to MongoDB Presentation
68/132
indexes
-
8/3/2019 Introduction to MongoDB Presentation
69/132
geospatial indexes
-
8/3/2019 Introduction to MongoDB Presentation
70/132
-
8/3/2019 Introduction to MongoDB Presentation
71/132
MapReduce
-
8/3/2019 Introduction to MongoDB Presentation
72/132
what did we leave out?
-
8/3/2019 Introduction to MongoDB Presentation
73/132
-
8/3/2019 Introduction to MongoDB Presentation
74/132
I say, we should get a
mainframe, old chap.
Harumph.
-
8/3/2019 Introduction to MongoDB Presentation
75/132
-
8/3/2019 Introduction to MongoDB Presentation
76/132
-
8/3/2019 Introduction to MongoDB Presentation
77/132
-
8/3/2019 Introduction to MongoDB Presentation
78/132
are you practicing safe
data storage?
-
8/3/2019 Introduction to MongoDB Presentation
79/132
-
8/3/2019 Introduction to MongoDB Presentation
80/132
Insert this.
Okay, got it.
Phew, my data's safe.
-
8/3/2019 Introduction to MongoDB Presentation
81/132
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.
-
8/3/2019 Introduction to MongoDB Presentation
82/132
-
8/3/2019 Introduction to MongoDB Presentation
83/132
? I have no idea what
you're talking about.
-
8/3/2019 Introduction to MongoDB Presentation
84/132
trust no one!
...trust a bunch of ones. Mostly.
-
8/3/2019 Introduction to MongoDB Presentation
85/132
prod1.example.com
prod2.example.com
-
8/3/2019 Introduction to MongoDB Presentation
86/132
prod1.example.com
prod2.example.com
-
8/3/2019 Introduction to MongoDB Presentation
87/132
prod1.example.com
prod2.example.com
-
8/3/2019 Introduction to MongoDB Presentation
88/132
prod1.example.com
prod2.example.com
-
8/3/2019 Introduction to MongoDB Presentation
89/132
-
8/3/2019 Introduction to MongoDB Presentation
90/132
prod1.example.com
prod2.example.com
-
8/3/2019 Introduction to MongoDB Presentation
91/132
prod1.example.com
prod2.example.com
-
8/3/2019 Introduction to MongoDB Presentation
92/132
prod1.example.com ?
prod2.example.com
-
8/3/2019 Introduction to MongoDB Presentation
93/132
prod2.example.com
prod1.example.com
?
-
8/3/2019 Introduction to MongoDB Presentation
94/132
prod2.example.com
prod1.example.com
?
-
8/3/2019 Introduction to MongoDB Presentation
95/132
prod2.example.com
prod1.example.com
-
8/3/2019 Introduction to MongoDB Presentation
96/132
prod2.example.com
prod1.example.com
-
8/3/2019 Introduction to MongoDB Presentation
97/132
primary
secondary
passive
secondary
-
8/3/2019 Introduction to MongoDB Presentation
98/132
secondary
passive
secondary
My priority is 2
My priority is 1
-
8/3/2019 Introduction to MongoDB Presentation
99/132
primary
passive
secondary
-
8/3/2019 Introduction to MongoDB Presentation
100/132
secondary
passive
secondary
I'm 5 minutes
behind the masterI'm 3 seconds
behind the master
-
8/3/2019 Introduction to MongoDB Presentation
101/132
secondary
passive
primary
-
8/3/2019 Introduction to MongoDB Presentation
102/132
passive
I'll still takereads.
-
8/3/2019 Introduction to MongoDB Presentation
103/132
-
8/3/2019 Introduction to MongoDB Presentation
104/132
-
8/3/2019 Introduction to MongoDB Presentation
105/132
-
8/3/2019 Introduction to MongoDB Presentation
106/132
-
8/3/2019 Introduction to MongoDB Presentation
107/132
okay
-
8/3/2019 Introduction to MongoDB Presentation
108/132
?
-
8/3/2019 Introduction to MongoDB Presentation
109/132
make sure two
slaves have this
-
8/3/2019 Introduction to MongoDB Presentation
110/132
-
8/3/2019 Introduction to MongoDB Presentation
111/132
-
8/3/2019 Introduction to MongoDB Presentation
112/132
-
8/3/2019 Introduction to MongoDB Presentation
113/132
all set
-
8/3/2019 Introduction to MongoDB Presentation
114/132
-
8/3/2019 Introduction to MongoDB Presentation
115/132
-
8/3/2019 Introduction to MongoDB Presentation
116/132
-
8/3/2019 Introduction to MongoDB Presentation
117/132
-
8/3/2019 Introduction to MongoDB Presentation
118/132
-
8/3/2019 Introduction to MongoDB Presentation
119/132
-
8/3/2019 Introduction to MongoDB Presentation
120/132
scaling
-
8/3/2019 Introduction to MongoDB Presentation
121/132
-
8/3/2019 Introduction to MongoDB Presentation
122/132
(rdbms)
-
8/3/2019 Introduction to MongoDB Presentation
123/132
U - ZK - OA - E F - J P - T
-
8/3/2019 Introduction to MongoDB Presentation
124/132
U - ZK - OA - E F - J P - T
I want Mark through
Sarah.
-
8/3/2019 Introduction to MongoDB Presentation
125/132
U - ZK - OA - E F - J P - T
-
8/3/2019 Introduction to MongoDB Presentation
126/132
U - ZK - OA - E F - J P - T
-
8/3/2019 Introduction to MongoDB Presentation
127/132
-
8/3/2019 Introduction to MongoDB Presentation
128/132
U - ZK - OA - E F - J P - T
Insert Linus
-
8/3/2019 Introduction to MongoDB Presentation
129/132
U - ZK - OA - E F - J P - T
$ mongo
-
8/3/2019 Introduction to MongoDB Presentation
130/132
$ mongo
MongoDB shell version 1.5.5
url: test
connecting to: test
type "help" for help
>
$ mongo
-
8/3/2019 Introduction to MongoDB Presentation
131/132
$ mongo
MongoDB shell version 1.5.5
url: test
connecting to: test
type "help" for help
> db.foo.insert({x:1})
-
8/3/2019 Introduction to MongoDB Presentation
132/132
thank you!
@kchodorow
http://www.snailinaturtleneck.com