Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Mongodb

1,847 views

Published on

best viewed in ubuntu (openoffice )

  • Be the first to comment

  • Be the first to like this

Mongodb

  1. 1. Gagan | Rohith | Sunil
  2. 2. “ MongoDB (from "hu mongo us") is a scalable, high-performance, open source, schema-free, document-oriented database.” - mongodb.org Created by 10gen
  3. 3. Features <ul><li>Document Oriented Storage </li></ul><ul><li>Querying </li></ul><ul><li>Auto Sharding </li></ul><ul><li>Replication Set </li></ul>
  4. 4. Document oriented storage <ul><li>Document 1: FirstName=“raj&quot;, Address=“bogadi&quot;, Hobby=“stamp collection&quot; </li></ul><ul><li>Document 2: FirstName=“raghu&quot;, Address=“25, kuvempu nagar&quot;, Children=(“ram,10&quot;, “hari,8&quot;, “ramya,5”) </li></ul><ul><li>BSON </li></ul><ul><li>JSON </li></ul><ul><li>JSON Notation </li></ul><ul><li>db.people.insert({FirstName:’raj’,Address=‘bogadi’,Hobby=‘stamp collection’}) </li></ul>
  5. 7. Querying <ul><li>Collections == Tables </li></ul><ul><li>Documents/objects == Records/rows </li></ul>
  6. 8. SQL Statement  Mongo Query Language Statement  CREATE TABLE USERS (a Number, b Number); implicit; can be done  explicitly  INSERT INTO USERS VALUES(1,1); db.users.insert({a:1,b:1}) SELECT * FROM users; db.users.find() SELECT * FROM users WHERE age=33; db.users.find({age:33}) SELECT * FROM users WHERE age=33 ORDER BY name; db.users.find({age:33}).sort({name:1}) SELECT * FROM users WHERE age>33; db.users.find({'age':{$gt:33}}) SELECT * FROM users WHERE age<33; db.users.find({'age':{$lt:33}})
  7. 9. DEMO (Part 1)
  8. 10. Sharding Sharding is the partitioning of data among multiple machines in an order-preserving manner . SHARDING IN MONGODB: Auto –Sharding (only needs shard key ). Automatic load Balancing. Scaling out to thousands of nodes. Availability and automated failover
  9. 12. Architectural Overview
  10. 13. Operations <ul><li>The config server => Meta-data </li></ul><ul><li>The mongos process =>Routing & Coordination </li></ul><ul><li>Mongod=> Mongo Demon(Mysqld) </li></ul>
  11. 14. Config server Mongos Shards
  12. 15. Architectural Overview
  13. 16. Operation Types <ul><li>Operations on a sharded system fall into one of two categories. </li></ul><ul><li>global </li></ul><ul><li>Targeted </li></ul><ul><li>db.foo.find( { x : 300, age : 40 } ) (Targeted) db.foo.find( { age : 40 } ) (Global) </li></ul>
  14. 17. Flowchart App Server Client (Mongos) Configuration Server DECISION Global Targeted Shard3 Shard4 Shard2 Shard1
  15. 18. Sharding and Failover NO SINGLE POINT FAILURE Failure of ->Mongos process ->Single mongod server ->Failure of all mongod servers comprising a shard. ->Config server.
  16. 19. Master and Slave
  17. 20. REPLICA SETS Shards Architecture Representation
  18. 21. Replication Set
  19. 22. A Set
  20. 23. A Set
  21. 24. A Set
  22. 25. A Set
  23. 26. Election Algorithm Periodically exchange Maxappliedoptime with all other nodes using the following format (selfid,maxoptime) . If nodes maxoptime is more send NO or else send YES(Arbitrer). The node getting the majority of yes and see majority of nodes will be elected as Primary . The process is repeated periodically.
  24. 27. Election Algorithm(Flow) server-a: primary oplog: (a1,a2,a3,a4,a5) server-b: secondary oplog: (a1) server-c: secondary oplog: (a1,a2,a3) … // server-a goes down … server-b: secondary oplog: (a1) server-c: secondary oplog: (a1,a2,a3) ... server-b: secondary oplog: (a1) server-c: primary oplog: (a1,a2,a3) // c has highest ord and becomes primary ... server-b: secondary oplog: (a1,a2,a3) server-c: primary oplog: (a1,a2,a3,c4) ... server-a resumes ... server-a: recovering oplog: (a1,a2,a3,a4,a5) server-b: secondary oplog: (a1,a2,a3) server-c: primary oplog: (a1,a2,a3,c4) … server-a: recovering oplog: (a1,a2,a3,c4) server-b: secondary oplog: (a1,a2,a3,c4) server-c: primary oplog: (a1,a2,a3,c4) … server-a: secondary oplog: (a1,a2,a3,c4) server-b: secondary oplog: (a1,a2,a3,c4) server-c: primary oplog: (a1,a2,a3,c4,c5,c6,c7,c8) … server-a: secondary oplog: (a1,a2,a3,c4,c5,c6,c7,c8) server-b: secondary oplog: (a1,a2,a3,c4,c5,c6,c7,c8) server-c: primary oplog: (a1,a2,a3,c4,c5,c6,c7,c8)
  25. 28. DEMO
  26. 29. BIBLOGRAPHY <ul><li>Www.mongodb.org </li></ul><ul><li>Snails in Turtleneck.com </li></ul>

×