sharding for mere mortals
TRANSCRIPT
Sharding for Mere MortalsMongoDB AustinAntonio RosalesFebruary 15, 2013
● 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
Lots to Read
https://juju.ubuntu.com/
Wake Up
http://synchealthblog.files.wordpress.com/2011/01/i-love-waking-up.gif
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
Work
http://explicitlyrics.us/images/comment/leftcomputer.png
Family
http://www.harbus.org/wp-content/uploads/2011/10/Old-fashioned-couple.jpg
Family
http://www.sunnking.com/assets/images/blog/story-of-electronics.jpg
Sleep
http://www.patspapers.com/images/uploads/beautysleep.jpg
Normal Day
http://www.sunnking.com/assets/images/blog/story-of-electronics.jpg
Or . .
Game
http://www.mariomayhem.com/fun/colour_mario_in/Mario_Coloring_029_1_up.jpg
Watch
https://developers.google.com/youtube/images/YouTube_watermark_black.png
Make a Discovery
https://developers.google.com/youtube/images/YouTube_watermark_black.png
Train for the Olympics
http://www.visitmudgeeregion.com.au/mrti/wp-content/uploads/2012/09/Weight_Lifting_09.jpg
Be a Ninja
http://us.123rf.com/400wm/400/400/dclipart/dclipart1206/dclipart120600158/13932293-ninja-fighter--vector-illustration-vinyl-ready.jpg
Drink Beer(s)
http://farm8.staticflickr.com/7054/6934838001_58ac314d5c_z.jpg
Sleep
http://www.patspapers.com/images/uploads/beautysleep.jpg
Repeat
http://cdn1.iconfinder.com/data/icons/nounproject/512/290.png
Still Haven't Read
https://juju.ubuntu.com/
Time
Not enough unless you have . . .
http://1.bp.blogspot.com/-KSGB6DryCsc/UFHnDErwbMI/AAAAAAAAAIg/72cRrHtBnCo/s1600/Infinity+Time.JPG
Delorean Time Machine
http://media.giantbomb.com/uploads/2/26725/870907-delorean_super.jpg
Wormhole
http://kauilapele.files.wordpress.com/2011/08/wormhole_by_stefitms_50.jpg
Time Turner
http://www.pinkraygun.com/wp-content/uploads/2010/08/Time-Turner1.jpg
Star Gate
http://images.cryhavok.org/d/18278-2/Stargate.png
Brain Envy
http://www.builttosell.com/wp-content/uploads/2011/09/brain.png
Your brainMy brain
How Can I configure, deploy, scale?
https://juju.ubuntu.com/http://clean.alltheragefaces.com/img/faces/large/sad-sad-l.png
● Distills DevOps knowledge into Charms○ Repeatable, Scalable, Relatable, Sharable
https://juju.ubuntu.comhttp://www.ubuntu.com/static/u/img/logos/logo-juju-143x143.png
Deploy over 100 Charms
https://juju.ubuntu.comhttp://maas.ubuntu.comhttp://www.blogcdn.com/www.engadget.com/media/2012/11/laptop-ubuntu-xps13.png
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
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
GUI
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
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()
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>
Get Involved
● [email protected]● #juju on IRC Freenode● juju.ubuntu.com
● Interested in Charming:○ Embed best practice into charms
Thanks!MongoDB [email protected]