Sharding for Mere Mortals

36
Sharding for Mere Mortals MongoDB Austin Antonio Rosales February 15, 2013

Transcript of Sharding for Mere Mortals

Page 1: Sharding for Mere Mortals

Sharding for Mere MortalsMongoDB AustinAntonio RosalesFebruary 15, 2013

Page 2: Sharding for Mere Mortals

● I got some ideas.

● I have heard there are some great tools to use.

● How can I deploy with limited:○ time and knowledge?

Deploying Your App

Page 3: Sharding for Mere Mortals

Lots to Read

https://juju.ubuntu.com/

Page 4: Sharding for Mere Mortals

Wake Up

http://synchealthblog.files.wordpress.com/2011/01/i-love-waking-up.gif

Page 5: Sharding for Mere Mortals

Eat

http://i.somethingawful.com/u/garbageday/2011/Comedy_Goldmine/drawmyav/peterjmatt_01.jpghttp://images.cpcache.com/merchandise/514_230x230_NoPeel.jpg?region=name:FrontCenter,id:60672883,w:16

Page 6: Sharding for Mere Mortals

Work

http://explicitlyrics.us/images/comment/leftcomputer.png

Page 7: Sharding for Mere Mortals

Family

http://www.harbus.org/wp-content/uploads/2011/10/Old-fashioned-couple.jpg

Page 8: Sharding for Mere Mortals

Family

http://www.sunnking.com/assets/images/blog/story-of-electronics.jpg

Page 9: Sharding for Mere Mortals

Sleep

http://www.patspapers.com/images/uploads/beautysleep.jpg

Page 10: Sharding for Mere Mortals

Normal Day

http://www.sunnking.com/assets/images/blog/story-of-electronics.jpg

Or . .

Page 11: Sharding for Mere Mortals

Game

http://www.mariomayhem.com/fun/colour_mario_in/Mario_Coloring_029_1_up.jpg

Page 12: Sharding for Mere Mortals

Watch

https://developers.google.com/youtube/images/YouTube_watermark_black.png

Page 13: Sharding for Mere Mortals

Make a Discovery

https://developers.google.com/youtube/images/YouTube_watermark_black.png

Page 14: Sharding for Mere Mortals

Train for the Olympics

http://www.visitmudgeeregion.com.au/mrti/wp-content/uploads/2012/09/Weight_Lifting_09.jpg

Page 15: Sharding for Mere Mortals

Be a Ninja

http://us.123rf.com/400wm/400/400/dclipart/dclipart1206/dclipart120600158/13932293-ninja-fighter--vector-illustration-vinyl-ready.jpg

Page 16: Sharding for Mere Mortals

Drink Beer(s)

http://farm8.staticflickr.com/7054/6934838001_58ac314d5c_z.jpg

Page 17: Sharding for Mere Mortals

Sleep

http://www.patspapers.com/images/uploads/beautysleep.jpg

Page 18: Sharding for Mere Mortals

Repeat

http://cdn1.iconfinder.com/data/icons/nounproject/512/290.png

Page 19: Sharding for Mere Mortals

Still Haven't Read

https://juju.ubuntu.com/

Page 20: Sharding for Mere Mortals

Time

Not enough unless you have . . .

http://1.bp.blogspot.com/-KSGB6DryCsc/UFHnDErwbMI/AAAAAAAAAIg/72cRrHtBnCo/s1600/Infinity+Time.JPG

Page 21: Sharding for Mere Mortals

Delorean Time Machine

http://media.giantbomb.com/uploads/2/26725/870907-delorean_super.jpg

Page 22: Sharding for Mere Mortals

Wormhole

http://kauilapele.files.wordpress.com/2011/08/wormhole_by_stefitms_50.jpg

Page 23: Sharding for Mere Mortals

Time Turner

http://www.pinkraygun.com/wp-content/uploads/2010/08/Time-Turner1.jpg

Page 24: Sharding for Mere Mortals

Star Gate

http://images.cryhavok.org/d/18278-2/Stargate.png

Page 25: Sharding for Mere Mortals

Brain Envy

http://www.builttosell.com/wp-content/uploads/2011/09/brain.png

Your brainMy brain

Page 26: Sharding for Mere Mortals

How Can I configure, deploy, scale?

https://juju.ubuntu.com/http://clean.alltheragefaces.com/img/faces/large/sad-sad-l.png

Page 27: Sharding for Mere Mortals

● Distills DevOps knowledge into Charms○ Repeatable, Scalable, Relatable, Sharable

https://juju.ubuntu.comhttp://www.ubuntu.com/static/u/img/logos/logo-juju-143x143.png

Page 28: Sharding for Mere Mortals

Deploy over 100 Charms

https://juju.ubuntu.comhttp://maas.ubuntu.comhttp://www.blogcdn.com/www.engadget.com/media/2012/11/laptop-ubuntu-xps13.png

Page 29: Sharding for Mere Mortals

0 to Deployed

● Install Juju○ sudo apt-get-repository ppa:juju/pkgs

○ sudo apt-get update && sudo apt-get install juju

● Configure environments.yaml for interested cloud○ juju bootstrap

○ ~/.juju/environments.yaml

● Deploy

○ juju deploy node-app my app

○ juju deploy mongodb

○ juju add-relation mongodb mayapp

○ juju expose myapp

Page 30: Sharding for Mere Mortals

Taking It Further

● Scale

○ juju add-unit -n 10 myapp

● Add load balancing○ juju deploy haproxy

○ juju add-relation myapp haproxy

● Add Monitoring○ juju deploy nagios

○ juju add-relation myapp nagios

Page 31: Sharding for Mere Mortals

GUI

Page 32: Sharding for Mere Mortals

Sharding Example

Bootstrap the environmentjuju bootstrap

Mongo Shelljuju deploy mongodb mongos

Config Servers ( we'll deploy 3 of them )juju deploy mongodb configsvr --config ~/mongodb-shard.yaml -n3

Shards ( We'll deploy three replica-sets )juju deploy mongodb shard1 --config ~/mongodb-shard.yaml -n3juju deploy mongodb shard2 --config ~/mongodb-shard.yaml -n3juju deploy mongodb shard3 --config ~/mongodb-shard.yaml -n3

Connect the Config Servers to the Mongo shell (mongos)juju add-relation mongos:mongos-cfg configsvr:configsvr

Connect each Shard to the Mongo shell (mongos)juju add-relation mongos:mongos shard1:databasejuju add-relation mongos:mongos shard2:databasejuju add-relation mongos:mongos shard3:database

Page 33: Sharding for Mere Mortals

Sharding Example

● Verify your config servers○ juju expose configsvr

○ juju status configsvr

○ Open your browser to http://<public-address-of-configsvr:28017

● Verify that each shard○ juju expose <shard1|shard2|shard3>

○ juju status <shard1|shard2|shard3>

○ Open your browser to http://<public-address-of-shard>:28017

● Verify that each shard has been successfully register with the cluster:○ juju expose mongos

○ juju status mongos

○ mongo --host <public-address-of-mongos>:27021

○ Once connected:■ sh.status()

Page 34: Sharding for Mere Mortals

Sharding Example

● sh.status should return:

mongos> sh.status()

--- Sharding Status ---

sharding version: { "_id" : 1, "version" : 3 }

shards:

{ "_id" : "shard1", "host" : "shard1/ec2-184-169-236-25.us-west-1.compute.amazonaws.com:27017,ec2-54-241-89-206.us-west-1.compute.amazonaws.com:27017,ip-10-170-173-51:27017" }

{ "_id" : "shard2", "host" : "shard2/ec2-204-236-159-194.us-west-1.compute.amazonaws.com:27017,ip-10-170-22-104:27017" }

{ "_id" : "shard3", "host" : "shard3/ec2-184-169-219-11.us-west-1.compute.amazonaws.com:27017,ec2-184-169-239-214.us-west-1.compute.amazonaws.com:27017,ip-10-170-215-20:27017" }

databases:

{ "_id" : "admin", "partitioned" : false, "primary" : "config" }

mongos>

Page 35: Sharding for Mere Mortals

Get Involved

[email protected]● #juju on IRC Freenode● juju.ubuntu.com

● Interested in Charming:○ Embed best practice into charms

Page 36: Sharding for Mere Mortals

Thanks!MongoDB [email protected]