com presentations: Finished the sharding slides.: mongo-tut-zendcon12.xml slides/mongodb/24-hours.jpg slides/mongodb/repl-eventual-consistency.xml
slides/mongodb/repl-features2.xml slides/mongodb/repl-managing.xml slides/mongodb/repl-priorities.png slides/mongodb/repl-priorities3.xml
slides/mongodb/repl-scenarios.xml slides/mongodb/repl-set1.xml slides/mongodb/repl-set2.png slides/mongodb/repl-set2.xml slides/mongodb/repl-set3.png
slides/mongodb/
| From: | Derick Rethans | Date: | Sat, 20 Oct 2012 13:20:34 +0000 |
| Subject: | com presentations: Finished the sharding slides.: mongo-tut-zendcon12.xml slides/mongodb/24-hours.jpg slides/mongodb/repl-eventual-consistency.xml slides/mongodb/repl-features2.xml slides/mongodb/repl-managing.xml slides/mongodb/repl-priorities.png slides/mongodb/repl-priorities3.xml slides/mongodb/repl-scenarios.xml slides/mongodb/repl-set1.xml slides/mongodb/repl-set2.png slides/mongodb/repl-set2.xml slides/mongodb/repl-set3.png slides/mongodb/ |
||
| Groups: | php.pres | ||
| Request: | Send a blank email to pres+get-1859@lists.php.net to get a copy of this message | ||
Commit: c9c7428ef86b4a39b11827cac4c8cd61f7f97972
Author: Derick Rethans <github@derickrethans.nl> Sat, 20 Oct 2012 14:20:34 +0100
Parents: 545682acc60e2a0c648c8d46c7b9fd15c7412187
Branches: master
Link: http://git.php.net/?p=presentations.git;a=commitdiff;h=c9c7428ef86b4a39b11827cac4c8cd61f7f97972
Log:
Finished the sharding slides.
Changed paths:
M mongo-tut-zendcon12.xml
A slides/mongodb/24-hours.jpg
A slides/mongodb/repl-eventual-consistency.xml
A slides/mongodb/repl-features2.xml
M slides/mongodb/repl-managing.xml
A slides/mongodb/repl-priorities.png
A slides/mongodb/repl-priorities3.xml
A slides/mongodb/repl-scenarios.xml
A slides/mongodb/repl-set1.xml
A slides/mongodb/repl-set2.png
A slides/mongodb/repl-set2.xml
A slides/mongodb/repl-set3.png
A slides/mongodb/repl-set3.xml
A slides/mongodb/repl-set4.png
A slides/mongodb/repl-set4.xml
A slides/mongodb/repl-set5.png
A slides/mongodb/repl-set5.xml
A slides/mongodb/repl-set6.png
A slides/mongodb/repl-single.png
A slides/mongodb/repl-single.xml
A slides/mongodb/repl-tagging-example.xml
A slides/mongodb/repl-tagging.xml
A slides/mongodb/repl-tagging2.xml
A slides/mongodb/repl-typical.xml
M slides/mongodb/repl-use-cases.xml
A slides/mongodb/repl-write-concern.xml
M slides/mongodb/replication-setup.xml
M slides/mongodb/safe2.xml
M slides/mongodb/safe3.xml
A slides/mongodb/tagging.jpg
A slides/repl-single.png
diff --git a/mongo-tut-zendcon12.xml b/mongo-tut-zendcon12.xml index e8499f9..eafdd47 100644 --- a/mongo-tut-zendcon12.xml +++ b/mongo-tut-zendcon12.xml @@ -179,11 +179,19 @@ multikey <slide>slides/mongodb/repl-managing.xml</slide> <slide>slides/mongodb/repl-priorities1.xml</slide> <slide>slides/mongodb/repl-priorities2.xml</slide> +<slide>slides/mongodb/repl-priorities3.xml</slide> +<slide>slides/mongodb/safe3.xml</slide> <slide>slides/mongodb/repl-write-concern.xml</slide> <slide>slides/mongodb/repl-tagging.xml</slide> -<slide>slides/mongodb/repl-read-preferences.xml</slide> +<slide>slides/mongodb/repl-tagging2.xml</slide> +<slide>slides/mongodb/repl-tagging-example.xml</slide> +<slide>slides/mongodb/read-preference2.xml</slide> +<slide>slides/mongodb/read-preference.xml</slide> +<slide>slides/mongodb/read-preference3.xml</slide> <slide>slides/mongodb/repl-eventual-consistency.xml</slide> -<slide>slides/mongodb/repl-schenarios.xml</slide> +<slide>slides/mongodb/repl-features2.xml</slide> + +<slide>slides/mongodb/repl-scenarios.xml</slide> <slide>slides/mongodb/repl-single.xml</slide> <slide>slides/mongodb/repl-set1.xml</slide> <slide>slides/mongodb/repl-set2.xml</slide> @@ -196,9 +204,6 @@ multikey - slaveOk - journal - write concerns -<slide>slides/mongodb/safe3.xml</slide> -<slide>slides/mongodb/read-preference.xml</slide> -<slide>slides/mongodb/php-connection-string.xml</slide> <slide>slides/mongodb/sharding.xml</slide> - mongos diff --git a/slides/mongodb/24-hours.jpg b/slides/mongodb/24-hours.jpg new file mode 100644 index 0000000..5454cd3 Binary files /dev/null and b/slides/mongodb/24-hours.jpg differ diff --git a/slides/mongodb/repl-eventual-consistency.xml b/slides/mongodb/repl-eventual-consistency.xml new file mode 100644 index 0000000..0106ca4 --- /dev/null +++ b/slides/mongodb/repl-eventual-consistency.xml @@ -0,0 +1,19 @@ +<slide> +<title>Eventual consistency</title> + +<list> + <bullet>Read Preference / Slave Okay + <list> + <bullet>driver will always send writes to Primary</bullet> + <bullet>driver will send read requests to Secondaries</bullet> + </list> + </bullet> + + <bullet>Warning! + <list> + <bullet>Secondaries may be out of date</bullet> + <bullet>Not applicable for all applications</bullet> + </list> + </bullet> +</list> +</slide> diff --git a/slides/mongodb/repl-features2.xml b/slides/mongodb/repl-features2.xml new file mode 100644 index 0000000..df850f9 --- /dev/null +++ b/slides/mongodb/repl-features2.xml @@ -0,0 +1,12 @@ +<slide> +<title>Replicaset wrap-up</title> + +<list> + <bullet>Reads from Primary are always consistent</bullet> + <bullet>Reads from Secondaries are eventually consistent</bullet> + <bullet>Automatic failover if a Primary fails</bullet> + <bullet>Automatic recovery when a node joins the set</bullet> + <bullet>Full control of where writes occur</bullet> + <bullet>Full control of where reads occur</bullet> +</list> +</slide> diff --git a/slides/mongodb/repl-managing.xml b/slides/mongodb/repl-managing.xml index c9ceaf6..9cfea5d 100644 --- a/slides/mongodb/repl-managing.xml +++ b/slides/mongodb/repl-managing.xml @@ -3,20 +3,20 @@ <div effect="fade-out"> <list> - <bullet>rs.conf(): get current configuration</bullet> - <bullet>rs.initiate(cfg): initiate replica set</bullet> - <bullet>rs.reconfig(cfg): reconfigure a replica set</bullet> - <bullet>rs.add("hostname:port"): add a new member</bullet> - <bullet>rs.addArb("hostname:port"): add a new arbiter</bullet> - <bullet>rs.remove("hostname:port"): remove a member</bullet> + <bullet>%rs.conf()%: get current configuration</bullet> + <bullet>%rs.initiate(cfg)%: initiate replica set</bullet> + <bullet>%rs.reconfig(cfg)%: reconfigure a replica set</bullet> + <bullet>%rs.add("hostname:port")%: add a new member</bullet> + <bullet>%rs.addArb("hostname:port")%: add a new arbiter</bullet> + <bullet>%rs.remove("hostname:port")%: remove a member</bullet> </list> </div> <div effect="fade-in"> <list> - <bullet>rs.status(): Reports status of the replica set from one node's point of view</bullet> - <bullet>rs.stepDown(secs): Request the primary to step down</bullet> - <bullet>rs.freeze(secs): Prevents any changes to the current replica set configuration (primary/secondary status); Use during backups</bullet> + <bullet>%rs.status()%: Reports status of the replica set from one node's point of view</bullet> + <bullet>%rs.stepDown(secs)%: Request the primary to step down</bullet> + <bullet>%rs.freeze(secs)%: Prevents any changes to the current replica set configuration (primary/secondary status); Use during backups</bullet> </list> </div> </slide> diff --git a/slides/mongodb/repl-priorities.png b/slides/mongodb/repl-priorities.png new file mode 100644 index 0000000..2fc9eac Binary files /dev/null and b/slides/mongodb/repl-priorities.png differ diff --git a/slides/mongodb/repl-priorities3.xml b/slides/mongodb/repl-priorities3.xml new file mode 100644 index 0000000..0024934 --- /dev/null +++ b/slides/mongodb/repl-priorities3.xml @@ -0,0 +1,24 @@ +<slide> +<title>Priorities</title> + +<image filename="repl-priorities.png"/> +<list> + <bullet>Assuming all members are up to date</bullet> + <bullet>Members A or B will be chosen first + <list> + <bullet>Highest priority</bullet> + </list> + </bullet> + <bullet>Members C or D will be chosen when: + <list> + <bullet>A and B are unavailable</bullet> + <bullet>A and B are not up to date</bullet> + </list> + </bullet> + <bullet>Member E is never chosen + <list> + <bullet>priority:0 means it cannot be elected</bullet> + </list> + </bullet> +</list> +</slide> diff --git a/slides/mongodb/repl-scenarios.xml b/slides/mongodb/repl-scenarios.xml new file mode 100644 index 0000000..19782b5 --- /dev/null +++ b/slides/mongodb/repl-scenarios.xml @@ -0,0 +1,6 @@ +<slide> +<title>High Availability Scenarios</title> + +<break lines="3"/> +<image attr="http://www.flickr.com/photos/mwichary/2132378428" filename="24-hours.jpg"/> +</slide> diff --git a/slides/mongodb/repl-set1.xml b/slides/mongodb/repl-set1.xml new file mode 100644 index 0000000..a210932 --- /dev/null +++ b/slides/mongodb/repl-set1.xml @@ -0,0 +1,19 @@ +<slide> +<title>Replicaset 1</title> + +<image filename="repl-set2.png"/> + +<list> + <bullet>Single datacentre</bullet> + <bullet>Single switch and power</bullet> + <bullet>One node failure</bullet> + <bullet>Automatic recovery of single node crash</bullet> + <bullet>Points of failure: + <list> + <bullet>Power</bullet> + <bullet>Network</bullet> + <bullet>Datacentre</bullet> + </list> + </bullet> +</list> +</slide> diff --git a/slides/mongodb/repl-set2.png b/slides/mongodb/repl-set2.png new file mode 100644 index 0000000..65a62af Binary files /dev/null and b/slides/mongodb/repl-set2.png differ diff --git a/slides/mongodb/repl-set2.xml b/slides/mongodb/repl-set2.xml new file mode 100644 index 0000000..576e5c4 --- /dev/null +++ b/slides/mongodb/repl-set2.xml @@ -0,0 +1,18 @@ +<slide> +<title>Replicaset 2</title> + +<image filename="repl-set3.png"/> + +<list> + <bullet>Single datacentre</bullet> + <bullet>Multiple power/network zones</bullet> + <bullet>Automatic recovery of single node crash</bullet> + <bullet>w=2 not viable as losing one node means no writes</bullet> + <bullet>Points of failure: + <list> + <bullet>Datacentre</bullet> + <bullet>Two node failure</bullet> + </list> + </bullet> +</list> +</slide> diff --git a/slides/mongodb/repl-set3.png b/slides/mongodb/repl-set3.png new file mode 100644 index 0000000..fd9cd86 Binary files /dev/null and b/slides/mongodb/repl-set3.png differ diff --git a/slides/mongodb/repl-set3.xml b/slides/mongodb/repl-set3.xml new file mode 100644 index 0000000..51398cb --- /dev/null +++ b/slides/mongodb/repl-set3.xml @@ -0,0 +1,18 @@ +<slide> +<title>Replicaset 3</title> + +<image filename="repl-set4.png"/> + +<list> + <bullet>Single datacentre</bullet> + <bullet>Multiple power/network zones</bullet> + <bullet>Automatic recovery of single node crash</bullet> + <bullet>w=2 viable as 2 out of 3 nodes available</bullet> + <bullet>Points of failure: + <list> + <bullet>Datacentre</bullet> + <bullet>Two node failure</bullet> + </list> + </bullet> +</list> +</slide> diff --git a/slides/mongodb/repl-set4.png b/slides/mongodb/repl-set4.png new file mode 100644 index 0000000..6238d99 Binary files /dev/null and b/slides/mongodb/repl-set4.png differ diff --git a/slides/mongodb/repl-set4.xml b/slides/mongodb/repl-set4.xml new file mode 100644 index 0000000..b13fbdb --- /dev/null +++ b/slides/mongodb/repl-set4.xml @@ -0,0 +1,11 @@ +<slide> +<title>Replicaset 4</title> + +<image filename="repl-set5.png"/> + +<list> + <bullet>Multi datacentre</bullet> + <bullet>DR node for safety</bullet> + <bullet>Can't do multi datacentre durable write safely since only one node in distant datacentre</bullet> +</list> +</slide> diff --git a/slides/mongodb/repl-set5.png b/slides/mongodb/repl-set5.png new file mode 100644 index 0000000..b44a6aa Binary files /dev/null and b/slides/mongodb/repl-set5.png differ diff --git a/slides/mongodb/repl-set5.xml b/slides/mongodb/repl-set5.xml new file mode 100644 index 0000000..f801395 --- /dev/null +++ b/slides/mongodb/repl-set5.xml @@ -0,0 +1,11 @@ +<slide> +<title>Replicaset 5</title> + +<image filename="repl-set6.png"/> + +<list> + <bullet>Three datacentres</bullet> + <bullet>Can survive full datacentre loss</bullet> + <bullet>Can do %w = { dc : 2 }% to guarantee write in two datacentres</bullet> +</list> +</slide> diff --git a/slides/mongodb/repl-set6.png b/slides/mongodb/repl-set6.png new file mode 100644 index 0000000..200a5de Binary files /dev/null and b/slides/mongodb/repl-set6.png differ diff --git a/slides/mongodb/repl-single.png b/slides/mongodb/repl-single.png new file mode 100644 index 0000000..aac2ea0 Binary files /dev/null and b/slides/mongodb/repl-single.png differ diff --git a/slides/mongodb/repl-single.xml b/slides/mongodb/repl-single.xml new file mode 100644 index 0000000..37e2fc3 --- /dev/null +++ b/slides/mongodb/repl-single.xml @@ -0,0 +1,11 @@ +<slide> +<title>A single node</title> + +<image filename="repl-single.png"/> + +<list> + <bullet>Will have downtime</bullet> + <bullet>Human intervention required if node crashes</bullet> + <bullet>Journal is required</bullet> +</list> +</slide> diff --git a/slides/mongodb/repl-tagging-example.xml b/slides/mongodb/repl-tagging-example.xml new file mode 100644 index 0000000..9063b31 --- /dev/null +++ b/slides/mongodb/repl-tagging-example.xml @@ -0,0 +1,26 @@ +<slide> +<title>Tagging example</title> + +<example><![CDATA[seta:SECONDARY> rs.config(); +{ + "_id" : "seta", "version" : 5, + "members" : [ + { "_id": 0, "host": "w:13000", "tags": { "dc": "west", "use": "accounting" } }, + { "_id": 1, "host": "w:13001", "tags": { "dc": "east", "use": "reporting" } }, + { "_id": 2, "host": "w:13002", "arbiterOnly": true } + { "_id": 3, "host": "w:13003", "tags": { "dc": "east", "use": "accounting" } }, + { "_id": 4, "host": "w:13004", "tags": { "dc": "north", "use": "reporting" } }, + ], + settings : { + getLastErrorModes: { + allDCs: { "dc": 3 }, + allUses: { "use": 2 } + } + } +}]]></example> + +<blurb>From PHP, enforce the write tags by:</blurb> +<example><![CDATA[ +$c->insert( array( … ), array( 'safe' => 'allUses' ) ); +]]></example> +</slide> diff --git a/slides/mongodb/repl-tagging.xml b/slides/mongodb/repl-tagging.xml new file mode 100644 index 0000000..9c7d6cf --- /dev/null +++ b/slides/mongodb/repl-tagging.xml @@ -0,0 +1,5 @@ +<slide> +<title>Tagging</title> + +<image attr="http://www.flickr.com/photos/laurelfan/5181666711" filename="tagging.jpg"/> +</slide> diff --git a/slides/mongodb/repl-tagging2.xml b/slides/mongodb/repl-tagging2.xml new file mode 100644 index 0000000..11058ce --- /dev/null +++ b/slides/mongodb/repl-tagging2.xml @@ -0,0 +1,15 @@ +<slide> +<title>Tagging</title> + +<list> + <bullet>Control over where data is written to.</bullet> + <bullet>Each member can have one or more tags: + <example> +tags: {dc: "stockholm"} +tags: {dc: "stockholm", + ip: "192.168", + rack: "row3-rk7"}</example></bullet> + <bullet>Replica set defines rules for where data resides</bullet> + <bullet>Rules can change without change application code</bullet> +</list> +</slide> diff --git a/slides/mongodb/repl-typical.xml b/slides/mongodb/repl-typical.xml new file mode 100644 index 0000000..dd62941 --- /dev/null +++ b/slides/mongodb/repl-typical.xml @@ -0,0 +1,12 @@ +<slide> +<title>Typical deployments</title> + +<table> +<tr><th>Use</th><th>Set size</th><th>Data protection</th><th>High Availability</th><th>Notes</th></tr> +<tr><td> </td><td>1</td><td>No </td><td>No</td><td>Must use --journal to protect against crashes</td></tr> +<tr><td>✔</td><td>2</td><td>Yes</td><td>No</td><td>On loss of one member, set becomes read-only</td></tr> +<tr><td>✔</td><td>3</td><td>Yes</td><td>Yes - 1 failure</td><td>On loss of one member, two surviving nodes can elect new primary</td></tr> +<tr><td> </td><td>4</td><td>Yes</td><td>Yes - 1 failure</td><td>On loss of two members, two surviving nodes are read-only</td></tr> +<tr><td>✔</td><td>5</td><td>Yes</td><td>Yes - 2 failures</td><td>On loss of two members, three surviving nodes can elect new primary</td></tr> +</table> +</slide> diff --git a/slides/mongodb/repl-use-cases.xml b/slides/mongodb/repl-use-cases.xml index a059deb..f962f5a 100644 --- a/slides/mongodb/repl-use-cases.xml +++ b/slides/mongodb/repl-use-cases.xml @@ -15,7 +15,7 @@ <list> <bullet>Analytics</bullet> <bullet>Data-processing</bullet> - <bullet>Integration with external systems</bullet> + <bullet>Integration with external systems (f.e. Solr)</bullet> </list> </bullet> </list> diff --git a/slides/mongodb/repl-write-concern.xml b/slides/mongodb/repl-write-concern.xml new file mode 100644 index 0000000..27a2f7e --- /dev/null +++ b/slides/mongodb/repl-write-concern.xml @@ -0,0 +1,11 @@ +<slide> +<title>Write concerns</title> + +<list> + <bullet>Safe mode:<br/>%$c->insert( [ 'text' => 'example' ], [ 'w' => 1 ] );%</bullet> + <bullet>Safe mode:<br/>%$c->insert( [ 'text' => 'example' ], [ 'safe' => true ] );%</bullet> + <bullet>Two nodes:<br/>%$c->insert( [ 'text' => 'example' ], [ 'w' => 2 ] );%</bullet> + <bullet>Majority of nodes:<br/>%$c->insert( [ 'text' => 'example' ], [ 'w' => "majority" ] );%</bullet> + <bullet>Tagged nodes:<br/>%$c->insert( [ 'text' => 'example' ], [ 'w' => "allDCs" ] );%</bullet> +</list> +</slide> diff --git a/slides/mongodb/replication-setup.xml b/slides/mongodb/replication-setup.xml index 3f1dd00..dbbedc5 100644 --- a/slides/mongodb/replication-setup.xml +++ b/slides/mongodb/replication-setup.xml @@ -21,19 +21,19 @@ replSet=seta <div effect="fade-in"> <blurb>Configure the set:</blurb> <example> -mongo localhost:13000 +mongo whisky:13000 > db.adminCommand( { replSetInitiate: { _id: 'seta', members: [ - { _id: 0, host: 'localhost:13000' }, - { _id: 1, host: 'localhost:13001' }, + { _id: 0, host: 'whisky:13000', tags: { 'dc': 'west', 'use': 'accounting' } }, + { _id: 1, host: 'whisky:13001', tags: { 'dc': 'east', 'use': 'reporting' } }, ] } } ); -PRIMARY> rs.addArb('localhost:13002'); +PRIMARY> rs.addArb('whisky:13002'); </example> </div> </slide> diff --git a/slides/mongodb/safe2.xml b/slides/mongodb/safe2.xml index f0c2cc0..b7f8167 100644 --- a/slides/mongodb/safe2.xml +++ b/slides/mongodb/safe2.xml @@ -19,4 +19,9 @@ $c->insert( ); ?>]]></example> +<blurb>From 1.3:</blurb> +<example result="0"><![CDATA[<?php +$m = new Mongo('mongodb://localhost/?safe=true'); +?>]]></example> + </slide> diff --git a/slides/mongodb/safe3.xml b/slides/mongodb/safe3.xml index a4f62df..fd07bd7 100644 --- a/slides/mongodb/safe3.xml +++ b/slides/mongodb/safe3.xml @@ -7,7 +7,7 @@ </list> <example result="1"><![CDATA[<?php -$m = new Mongo( 'mongodb://localhost:13000' ); +$m = new Mongo( 'mongodb://localhost:13000/?replSet=seta' ); $c = $m->demo->talks; $c->insert( @@ -15,4 +15,9 @@ $c->insert( array( 'safe' => true, 'w' => 2 ) // options ); ?>]]></example> + +<list> + <bullet>%w != 0% automatically enables "getLastError"</bullet> + <bullet>%w > 1% means that the extra nodes have read from the oplog</bullet> +</list> </slide> diff --git a/slides/mongodb/tagging.jpg b/slides/mongodb/tagging.jpg new file mode 100644 index 0000000..ddc632d Binary files /dev/null and b/slides/mongodb/tagging.jpg differ diff --git a/slides/repl-single.png b/slides/repl-single.png new file mode 100644 index 0000000..09f12d8 Binary files /dev/null and b/slides/repl-single.png differ
diff --git a/mongo-tut-zendcon12.xml b/mongo-tut-zendcon12.xml index e8499f9..eafdd47 100644 --- a/mongo-tut-zendcon12.xml +++ b/mongo-tut-zendcon12.xml @@ -179,11 +179,19 @@ multikey <slide>slides/mongodb/repl-managing.xml</slide> <slide>slides/mongodb/repl-priorities1.xml</slide> <slide>slides/mongodb/repl-priorities2.xml</slide> +<slide>slides/mongodb/repl-priorities3.xml</slide> +<slide>slides/mongodb/safe3.xml</slide> <slide>slides/mongodb/repl-write-concern.xml</slide> <slide>slides/mongodb/repl-tagging.xml</slide> -<slide>slides/mongodb/repl-read-preferences.xml</slide> +<slide>slides/mongodb/repl-tagging2.xml</slide> +<slide>slides/mongodb/repl-tagging-example.xml</slide> +<slide>slides/mongodb/read-preference2.xml</slide> +<slide>slides/mongodb/read-preference.xml</slide> +<slide>slides/mongodb/read-preference3.xml</slide> <slide>slides/mongodb/repl-eventual-consistency.xml</slide> -<slide>slides/mongodb/repl-schenarios.xml</slide> +<slide>slides/mongodb/repl-features2.xml</slide> + +<slide>slides/mongodb/repl-scenarios.xml</slide> <slide>slides/mongodb/repl-single.xml</slide> <slide>slides/mongodb/repl-set1.xml</slide> <slide>slides/mongodb/repl-set2.xml</slide> @@ -196,9 +204,6 @@ multikey - slaveOk - journal - write concerns -<slide>slides/mongodb/safe3.xml</slide> -<slide>slides/mongodb/read-preference.xml</slide> -<slide>slides/mongodb/php-connection-string.xml</slide> <slide>slides/mongodb/sharding.xml</slide> - mongos diff --git a/slides/mongodb/24-hours.jpg b/slides/mongodb/24-hours.jpg new file mode 100644 index 0000000..5454cd3 Binary files /dev/null and b/slides/mongodb/24-hours.jpg differ diff --git a/slides/mongodb/repl-eventual-consistency.xml b/slides/mongodb/repl-eventual-consistency.xml new file mode 100644 index 0000000..0106ca4 --- /dev/null +++ b/slides/mongodb/repl-eventual-consistency.xml @@ -0,0 +1,19 @@ +<slide> +<title>Eventual consistency</title> + +<list> + <bullet>Read Preference / Slave Okay + <list> + <bullet>driver will always send writes to Primary</bullet> + <bullet>driver will send read requests to Secondaries</bullet> + </list> + </bullet> + + <bullet>Warning! + <list> + <bullet>Secondaries may be out of date</bullet> + <bullet>Not applicable for all applications</bullet> + </list> + </bullet> +</list> +</slide> diff --git a/slides/mongodb/repl-features2.xml b/slides/mongodb/repl-features2.xml new file mode 100644 index 0000000..df850f9 --- /dev/null +++ b/slides/mongodb/repl-features2.xml @@ -0,0 +1,12 @@ +<slide> +<title>Replicaset wrap-up</title> + +<list> + <bullet>Reads from Primary are always consistent</bullet> + <bullet>Reads from Secondaries are eventually consistent</bullet> + <bullet>Automatic failover if a Primary fails</bullet> + <bullet>Automatic recovery when a node joins the set</bullet> + <bullet>Full control of where writes occur</bullet> + <bullet>Full control of where reads occur</bullet> +</list> +</slide> diff --git a/slides/mongodb/repl-managing.xml b/slides/mongodb/repl-managing.xml index c9ceaf6..9cfea5d 100644 --- a/slides/mongodb/repl-managing.xml +++ b/slides/mongodb/repl-managing.xml @@ -3,20 +3,20 @@ <div effect="fade-out"> <list> - <bullet>rs.conf(): get current configuration</bullet> - <bullet>rs.initiate(cfg): initiate replica set</bullet> - <bullet>rs.reconfig(cfg): reconfigure a replica set</bullet> - <bullet>rs.add("hostname:port"): add a new member</bullet> - <bullet>rs.addArb("hostname:port"): add a new arbiter</bullet> - <bullet>rs.remove("hostname:port"): remove a member</bullet> + <bullet>%rs.conf()%: get current configuration</bullet> + <bullet>%rs.initiate(cfg)%: initiate replica set</bullet> + <bullet>%rs.reconfig(cfg)%: reconfigure a replica set</bullet> + <bullet>%rs.add("hostname:port")%: add a new member</bullet> + <bullet>%rs.addArb("hostname:port")%: add a new arbiter</bullet> + <bullet>%rs.remove("hostname:port")%: remove a member</bullet> </list> </div> <div effect="fade-in"> <list> - <bullet>rs.status(): Reports status of the replica set from one node's point of view</bullet> - <bullet>rs.stepDown(secs): Request the primary to step down</bullet> - <bullet>rs.freeze(secs): Prevents any changes to the current replica set configuration (primary/secondary status); Use during backups</bullet> + <bullet>%rs.status()%: Reports status of the replica set from one node's point of view</bullet> + <bullet>%rs.stepDown(secs)%: Request the primary to step down</bullet> + <bullet>%rs.freeze(secs)%: Prevents any changes to the current replica set configuration (primary/secondary status); Use during backups</bullet> </list> </div> </slide> diff --git a/slides/mongodb/repl-priorities.png b/slides/mongodb/repl-priorities.png new file mode 100644 index 0000000..2fc9eac Binary files /dev/null and b/slides/mongodb/repl-priorities.png differ diff --git a/slides/mongodb/repl-priorities3.xml b/slides/mongodb/repl-priorities3.xml new file mode 100644 index 0000000..0024934 --- /dev/null +++ b/slides/mongodb/repl-priorities3.xml @@ -0,0 +1,24 @@ +<slide> +<title>Priorities</title> + +<image filename="repl-priorities.png"/> +<list> + <bullet>Assuming all members are up to date</bullet> + <bullet>Members A or B will be chosen first + <list> + <bullet>Highest priority</bullet> + </list> + </bullet> + <bullet>Members C or D will be chosen when: + <list> + <bullet>A and B are unavailable</bullet> + <bullet>A and B are not up to date</bullet> + </list> + </bullet> + <bullet>Member E is never chosen + <list> + <bullet>priority:0 means it cannot be elected</bullet> + </list> + </bullet> +</list> +</slide> diff --git a/slides/mongodb/repl-scenarios.xml b/slides/mongodb/repl-scenarios.xml new file mode 100644 index 0000000..19782b5 --- /dev/null +++ b/slides/mongodb/repl-scenarios.xml @@ -0,0 +1,6 @@ +<slide> +<title>High Availability Scenarios</title> + +<break lines="3"/> +<image attr="http://www.flickr.com/photos/mwichary/2132378428" filename="24-hours.jpg"/> +</slide> diff --git a/slides/mongodb/repl-set1.xml b/slides/mongodb/repl-set1.xml new file mode 100644 index 0000000..a210932 --- /dev/null +++ b/slides/mongodb/repl-set1.xml @@ -0,0 +1,19 @@ +<slide> +<title>Replicaset 1</title> + +<image filename="repl-set2.png"/> + +<list> + <bullet>Single datacentre</bullet> + <bullet>Single switch and power</bullet> + <bullet>One node failure</bullet> + <bullet>Automatic recovery of single node crash</bullet> + <bullet>Points of failure: + <list> + <bullet>Power</bullet> + <bullet>Network</bullet> + <bullet>Datacentre</bullet> + </list> + </bullet> +</list> +</slide> diff --git a/slides/mongodb/repl-set2.png b/slides/mongodb/repl-set2.png new file mode 100644 index 0000000..65a62af Binary files /dev/null and b/slides/mongodb/repl-set2.png differ diff --git a/slides/mongodb/repl-set2.xml b/slides/mongodb/repl-set2.xml new file mode 100644 index 0000000..576e5c4 --- /dev/null +++ b/slides/mongodb/repl-set2.xml @@ -0,0 +1,18 @@ +<slide> +<title>Replicaset 2</title> + +<image filename="repl-set3.png"/> + +<list> + <bullet>Single datacentre</bullet> + <bullet>Multiple power/network zones</bullet> + <bullet>Automatic recovery of single node crash</bullet> + <bullet>w=2 not viable as losing one node means no writes</bullet> + <bullet>Points of failure: + <list> + <bullet>Datacentre</bullet> + <bullet>Two node failure</bullet> + </list> + </bullet> +</list> +</slide> diff --git a/slides/mongodb/repl-set3.png b/slides/mongodb/repl-set3.png new file mode 100644 index 0000000..fd9cd86 Binary files /dev/null and b/slides/mongodb/repl-set3.png differ diff --git a/slides/mongodb/repl-set3.xml b/slides/mongodb/repl-set3.xml new file mode 100644 index 0000000..51398cb --- /dev/null +++ b/slides/mongodb/repl-set3.xml @@ -0,0 +1,18 @@ +<slide> +<title>Replicaset 3</title> + +<image filename="repl-set4.png"/> + +<list> + <bullet>Single datacentre</bullet> + <bullet>Multiple power/network zones</bullet> + <bullet>Automatic recovery of single node crash</bullet> + <bullet>w=2 viable as 2 out of 3 nodes available</bullet> + <bullet>Points of failure: + <list> + <bullet>Datacentre</bullet> + <bullet>Two node failure</bullet> + </list> + </bullet> +</list> +</slide> diff --git a/slides/mongodb/repl-set4.png b/slides/mongodb/repl-set4.png new file mode 100644 index 0000000..6238d99 Binary files /dev/null and b/slides/mongodb/repl-set4.png differ diff --git a/slides/mongodb/repl-set4.xml b/slides/mongodb/repl-set4.xml new file mode 100644 index 0000000..b13fbdb --- /dev/null +++ b/slides/mongodb/repl-set4.xml @@ -0,0 +1,11 @@ +<slide> +<title>Replicaset 4</title> + +<image filename="repl-set5.png"/> + +<list> + <bullet>Multi datacentre</bullet> + <bullet>DR node for safety</bullet> + <bullet>Can't do multi datacentre durable write safely since only one node in distant datacentre</bullet> +</list> +</slide> diff --git a/slides/mongodb/repl-set5.png b/slides/mongodb/repl-set5.png new file mode 100644 index 0000000..b44a6aa Binary files /dev/null and b/slides/mongodb/repl-set5.png differ diff --git a/slides/mongodb/repl-set5.xml b/slides/mongodb/repl-set5.xml new file mode 100644 index 0000000..f801395 --- /dev/null +++ b/slides/mongodb/repl-set5.xml @@ -0,0 +1,11 @@ +<slide> +<title>Replicaset 5</title> + +<image filename="repl-set6.png"/> + +<list> + <bullet>Three datacentres</bullet> + <bullet>Can survive full datacentre loss</bullet> + <bullet>Can do %w = { dc : 2 }% to guarantee write in two datacentres</bullet> +</list> +</slide> diff --git a/slides/mongodb/repl-set6.png b/slides/mongodb/repl-set6.png new file mode 100644 index 0000000..200a5de Binary files /dev/null and b/slides/mongodb/repl-set6.png differ diff --git a/slides/mongodb/repl-single.png b/slides/mongodb/repl-single.png new file mode 100644 index 0000000..aac2ea0 Binary files /dev/null and b/slides/mongodb/repl-single.png differ diff --git a/slides/mongodb/repl-single.xml b/slides/mongodb/repl-single.xml new file mode 100644 index 0000000..37e2fc3 --- /dev/null +++ b/slides/mongodb/repl-single.xml @@ -0,0 +1,11 @@ +<slide> +<title>A single node</title> + +<image filename="repl-single.png"/> + +<list> + <bullet>Will have downtime</bullet> + <bullet>Human intervention required if node crashes</bullet> + <bullet>Journal is required</bullet> +</list> +</slide> diff --git a/slides/mongodb/repl-tagging-example.xml b/slides/mongodb/repl-tagging-example.xml new file mode 100644 index 0000000..9063b31 --- /dev/null +++ b/slides/mongodb/repl-tagging-example.xml @@ -0,0 +1,26 @@ +<slide> +<title>Tagging example</title> + +<example><![CDATA[seta:SECONDARY> rs.config(); +{ + "_id" : "seta", "version" : 5, + "members" : [ + { "_id": 0, "host": "w:13000", "tags": { "dc": "west", "use": "accounting" } }, + { "_id": 1, "host": "w:13001", "tags": { "dc": "east", "use": "reporting" } }, + { "_id": 2, "host": "w:13002", "arbiterOnly": true } + { "_id": 3, "host": "w:13003", "tags": { "dc": "east", "use": "accounting" } }, + { "_id": 4, "host": "w:13004", "tags": { "dc": "north", "use": "reporting" } }, + ], + settings : { + getLastErrorModes: { + allDCs: { "dc": 3 }, + allUses: { "use": 2 } + } + } +}]]></example> + +<blurb>From PHP, enforce the write tags by:</blurb> +<example><![CDATA[ +$c->insert( array( … ), array( 'safe' => 'allUses' ) ); +]]></example> +</slide> diff --git a/slides/mongodb/repl-tagging.xml b/slides/mongodb/repl-tagging.xml new file mode 100644 index 0000000..9c7d6cf --- /dev/null +++ b/slides/mongodb/repl-tagging.xml @@ -0,0 +1,5 @@ +<slide> +<title>Tagging</title> + +<image attr="http://www.flickr.com/photos/laurelfan/5181666711" filename="tagging.jpg"/> +</slide> diff --git a/slides/mongodb/repl-tagging2.xml b/slides/mongodb/repl-tagging2.xml new file mode 100644 index 0000000..11058ce --- /dev/null +++ b/slides/mongodb/repl-tagging2.xml @@ -0,0 +1,15 @@ +<slide> +<title>Tagging</title> + +<list> + <bullet>Control over where data is written to.</bullet> + <bullet>Each member can have one or more tags: + <example> +tags: {dc: "stockholm"} +tags: {dc: "stockholm", + ip: "192.168", + rack: "row3-rk7"}</example></bullet> + <bullet>Replica set defines rules for where data resides</bullet> + <bullet>Rules can change without change application code</bullet> +</list> +</slide> diff --git a/slides/mongodb/repl-typical.xml b/slides/mongodb/repl-typical.xml new file mode 100644 index 0000000..dd62941 --- /dev/null +++ b/slides/mongodb/repl-typical.xml @@ -0,0 +1,12 @@ +<slide> +<title>Typical deployments</title> + +<table> +<tr><th>Use</th><th>Set size</th><th>Data protection</th><th>High Availability</th><th>Notes</th></tr> +<tr><td> </td><td>1</td><td>No </td><td>No</td><td>Must use --journal to protect against crashes</td></tr> +<tr><td>✔</td><td>2</td><td>Yes</td><td>No</td><td>On loss of one member, set becomes read-only</td></tr> +<tr><td>✔</td><td>3</td><td>Yes</td><td>Yes - 1 failure</td><td>On loss of one member, two surviving nodes can elect new primary</td></tr> +<tr><td> </td><td>4</td><td>Yes</td><td>Yes - 1 failure</td><td>On loss of two members, two surviving nodes are read-only</td></tr> +<tr><td>✔</td><td>5</td><td>Yes</td><td>Yes - 2 failures</td><td>On loss of two members, three surviving nodes can elect new primary</td></tr> +</table> +</slide> diff --git a/slides/mongodb/repl-use-cases.xml b/slides/mongodb/repl-use-cases.xml index a059deb..f962f5a 100644 --- a/slides/mongodb/repl-use-cases.xml +++ b/slides/mongodb/repl-use-cases.xml @@ -15,7 +15,7 @@ <list> <bullet>Analytics</bullet> <bullet>Data-processing</bullet> - <bullet>Integration with external systems</bullet> + <bullet>Integration with external systems (f.e. Solr)</bullet> </list> </bullet> </list> diff --git a/slides/mongodb/repl-write-concern.xml b/slides/mongodb/repl-write-concern.xml new file mode 100644 index 0000000..27a2f7e --- /dev/null +++ b/slides/mongodb/repl-write-concern.xml @@ -0,0 +1,11 @@ +<slide> +<title>Write concerns</title> + +<list> + <bullet>Safe mode:<br/>%$c->insert( [ 'text' => 'example' ], [ 'w' => 1 ] );%</bullet> + <bullet>Safe mode:<br/>%$c->insert( [ 'text' => 'example' ], [ 'safe' => true ] );%</bullet> + <bullet>Two nodes:<br/>%$c->insert( [ 'text' => 'example' ], [ 'w' => 2 ] );%</bullet> + <bullet>Majority of nodes:<br/>%$c->insert( [ 'text' => 'example' ], [ 'w' => "majority" ] );%</bullet> + <bullet>Tagged nodes:<br/>%$c->insert( [ 'text' => 'example' ], [ 'w' => "allDCs" ] );%</bullet> +</list> +</slide> diff --git a/slides/mongodb/replication-setup.xml b/slides/mongodb/replication-setup.xml index 3f1dd00..dbbedc5 100644 --- a/slides/mongodb/replication-setup.xml +++ b/slides/mongodb/replication-setup.xml @@ -21,19 +21,19 @@ replSet=seta <div effect="fade-in"> <blurb>Configure the set:</blurb> <example> -mongo localhost:13000 +mongo whisky:13000 > db.adminCommand( { replSetInitiate: { _id: 'seta', members: [ - { _id: 0, host: 'localhost:13000' }, - { _id: 1, host: 'localhost:13001' }, + { _id: 0, host: 'whisky:13000', tags: { 'dc': 'west', 'use': 'accounting' } }, + { _id: 1, host: 'whisky:13001', tags: { 'dc': 'east', 'use': 'reporting' } }, ] } } ); -PRIMARY> rs.addArb('localhost:13002'); +PRIMARY> rs.addArb('whisky:13002'); </example> </div> </slide> diff --git a/slides/mongodb/safe2.xml b/slides/mongodb/safe2.xml index f0c2cc0..b7f8167 100644 --- a/slides/mongodb/safe2.xml +++ b/slides/mongodb/safe2.xml @@ -19,4 +19,9 @@ $c->insert( ); ?>]]></example> +<blurb>From 1.3:</blurb> +<example result="0"><![CDATA[<?php +$m = new Mongo('mongodb://localhost/?safe=true'); +?>]]></example> + </slide> diff --git a/slides/mongodb/safe3.xml b/slides/mongodb/safe3.xml index a4f62df..fd07bd7 100644 --- a/slides/mongodb/safe3.xml +++ b/slides/mongodb/safe3.xml @@ -7,7 +7,7 @@ </list> <example result="1"><![CDATA[<?php -$m = new Mongo( 'mongodb://localhost:13000' ); +$m = new Mongo( 'mongodb://localhost:13000/?replSet=seta' ); $c = $m->demo->talks; $c->insert( @@ -15,4 +15,9 @@ $c->insert( array( 'safe' => true, 'w' => 2 ) // options ); ?>]]></example> + +<list> + <bullet>%w != 0% automatically enables "getLastError"</bullet> + <bullet>%w > 1% means that the extra nodes have read from the oplog</bullet> +</list> </slide> diff --git a/slides/mongodb/tagging.jpg b/slides/mongodb/tagging.jpg new file mode 100644 index 0000000..ddc632d Binary files /dev/null and b/slides/mongodb/tagging.jpg differ diff --git a/slides/repl-single.png b/slides/repl-single.png new file mode 100644 index 0000000..09f12d8 Binary files /dev/null and b/slides/repl-single.png differ