mongodb
DESCRIPTION
best viewed in ubuntu (openoffice )TRANSCRIPT
![Page 1: Mongodb](https://reader031.vdocument.in/reader031/viewer/2022020217/554f73b0b4c905bb178b5341/html5/thumbnails/1.jpg)
Gagan | Rohith | Sunil
![Page 2: Mongodb](https://reader031.vdocument.in/reader031/viewer/2022020217/554f73b0b4c905bb178b5341/html5/thumbnails/2.jpg)
“MongoDB (from "humongous") is a scalable, high-performance, open source, schema-free, document-oriented database.”
- mongodb.org
Created by 10gen
![Page 3: Mongodb](https://reader031.vdocument.in/reader031/viewer/2022020217/554f73b0b4c905bb178b5341/html5/thumbnails/3.jpg)
Features
• Document Oriented Storage• Querying• Auto Sharding• Replication Set
![Page 4: Mongodb](https://reader031.vdocument.in/reader031/viewer/2022020217/554f73b0b4c905bb178b5341/html5/thumbnails/4.jpg)
Document oriented storageDocument 1: FirstName=“raj", Address=“bogadi", Hobby=“stamp collection"
Document 2: FirstName=“raghu", Address=“25, kuvempu nagar", Children=(“ram,10", “hari,8", “ramya,5”)
• BSON• JSON
• JSON Notation• db.people.insert({FirstName:’raj’,Address=‘bogadi’,Hobby=‘stamp
collection’})
![Page 5: Mongodb](https://reader031.vdocument.in/reader031/viewer/2022020217/554f73b0b4c905bb178b5341/html5/thumbnails/5.jpg)
![Page 6: Mongodb](https://reader031.vdocument.in/reader031/viewer/2022020217/554f73b0b4c905bb178b5341/html5/thumbnails/6.jpg)
![Page 7: Mongodb](https://reader031.vdocument.in/reader031/viewer/2022020217/554f73b0b4c905bb178b5341/html5/thumbnails/7.jpg)
Querying
• Collections == Tables
• Documents/objects == Records/rows
![Page 8: Mongodb](https://reader031.vdocument.in/reader031/viewer/2022020217/554f73b0b4c905bb178b5341/html5/thumbnails/8.jpg)
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}})
![Page 9: Mongodb](https://reader031.vdocument.in/reader031/viewer/2022020217/554f73b0b4c905bb178b5341/html5/thumbnails/9.jpg)
DEMO (Part 1)
![Page 10: Mongodb](https://reader031.vdocument.in/reader031/viewer/2022020217/554f73b0b4c905bb178b5341/html5/thumbnails/10.jpg)
ShardingSharding 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
![Page 11: Mongodb](https://reader031.vdocument.in/reader031/viewer/2022020217/554f73b0b4c905bb178b5341/html5/thumbnails/11.jpg)
![Page 12: Mongodb](https://reader031.vdocument.in/reader031/viewer/2022020217/554f73b0b4c905bb178b5341/html5/thumbnails/12.jpg)
Architectural Overview
![Page 13: Mongodb](https://reader031.vdocument.in/reader031/viewer/2022020217/554f73b0b4c905bb178b5341/html5/thumbnails/13.jpg)
OperationsThe config server => Meta-data
The mongos process =>Routing & Coordination
Mongod=> Mongo Demon(Mysqld)
![Page 14: Mongodb](https://reader031.vdocument.in/reader031/viewer/2022020217/554f73b0b4c905bb178b5341/html5/thumbnails/14.jpg)
Config server
Mongos
Shards
![Page 15: Mongodb](https://reader031.vdocument.in/reader031/viewer/2022020217/554f73b0b4c905bb178b5341/html5/thumbnails/15.jpg)
Architectural Overview
![Page 16: Mongodb](https://reader031.vdocument.in/reader031/viewer/2022020217/554f73b0b4c905bb178b5341/html5/thumbnails/16.jpg)
Operation Types
Operations on a sharded system fall into one of two categories. global Targeteddb.foo.find( { x : 300, age : 40 } ) (Targeted)db.foo.find( { age : 40 } ) (Global)
![Page 17: Mongodb](https://reader031.vdocument.in/reader031/viewer/2022020217/554f73b0b4c905bb178b5341/html5/thumbnails/17.jpg)
Flowchart
App ServerApp Server Client(Mongos)Client
(Mongos) Configuration ServerConfiguration Server
DECISIONGlobal
Targeted
DECISIONGlobal
Targeted
Shard3Shard3
Shard4Shard4
Shard2Shard2
Shard1Shard1
![Page 18: Mongodb](https://reader031.vdocument.in/reader031/viewer/2022020217/554f73b0b4c905bb178b5341/html5/thumbnails/18.jpg)
Sharding and Failover
NO SINGLE POINT FAILURE
Failure of->Mongos process->Single mongod server->Failure of all mongod servers comprising a shard.->Config server.
![Page 19: Mongodb](https://reader031.vdocument.in/reader031/viewer/2022020217/554f73b0b4c905bb178b5341/html5/thumbnails/19.jpg)
Master and Slave
![Page 20: Mongodb](https://reader031.vdocument.in/reader031/viewer/2022020217/554f73b0b4c905bb178b5341/html5/thumbnails/20.jpg)
REPLICA SETS
Shards Architecture Representation
![Page 21: Mongodb](https://reader031.vdocument.in/reader031/viewer/2022020217/554f73b0b4c905bb178b5341/html5/thumbnails/21.jpg)
Replication Set
![Page 22: Mongodb](https://reader031.vdocument.in/reader031/viewer/2022020217/554f73b0b4c905bb178b5341/html5/thumbnails/22.jpg)
A Set
![Page 23: Mongodb](https://reader031.vdocument.in/reader031/viewer/2022020217/554f73b0b4c905bb178b5341/html5/thumbnails/23.jpg)
A Set
![Page 24: Mongodb](https://reader031.vdocument.in/reader031/viewer/2022020217/554f73b0b4c905bb178b5341/html5/thumbnails/24.jpg)
A Set
![Page 25: Mongodb](https://reader031.vdocument.in/reader031/viewer/2022020217/554f73b0b4c905bb178b5341/html5/thumbnails/25.jpg)
A Set
![Page 26: Mongodb](https://reader031.vdocument.in/reader031/viewer/2022020217/554f73b0b4c905bb178b5341/html5/thumbnails/26.jpg)
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.
![Page 27: Mongodb](https://reader031.vdocument.in/reader031/viewer/2022020217/554f73b0b4c905bb178b5341/html5/thumbnails/27.jpg)
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)
![Page 28: Mongodb](https://reader031.vdocument.in/reader031/viewer/2022020217/554f73b0b4c905bb178b5341/html5/thumbnails/28.jpg)
DEMO
![Page 29: Mongodb](https://reader031.vdocument.in/reader031/viewer/2022020217/554f73b0b4c905bb178b5341/html5/thumbnails/29.jpg)
BIBLOGRAPHY
Www.mongodb.org Snails in Turtleneck.com