• Like
Superficial mongo db
Upcoming SlideShare
Loading in...5
×

Superficial mongo db

  • 980 views
Uploaded on

 

More in: Technology , Business
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
980
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
19
Comments
0
Likes
2

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Superficial MongoDB charsyam@naver.com
  • 2. MongoDB NoSQLDocument BSON
  • 3. Document-Oriented StorageFull Index SupportReplication & High AvailabilityAuto ShardingQueryingFast In-Place UpdatesMap/ReduceGridFS
  • 4. Document-Oriented StorageFull Index SupportReplication & High AvailabilityAuto ShardingQueryingFast In-Place UpdatesMap/ReduceGridFS
  • 5. Document-Oriented > db.users.insert( { _id : "alex", name: { first:"Alex", last:"Benisson" }, karma : 1.0 } )> db.posts.findOne() { _id : ObjectId("4e77bb3b8a3e000000004f7a"), when : Date("2011-09-19T02:10:11.3Z", author : "alex", title : "No Free Lunch", text : "This is the text of the post. It could be very long.", tags : [ "business", "ramblings" ], votes : 5, voters : [ "jane", "joe", "spencer", "phyllis", "li" ], comments : [ { who : "jane", when : Date("2011-09-19T04:00:10.112Z"), comment : "I agree." }, { who : "meghan", when : Date("2011-09-20T14:36:06.958Z"), comment : "You must be joking. etc etc ..." } ] }
  • 6. Full-Index Support> db.things.ensureIndex({j:1});> db.things.ensureIndex({"address.city": 1})> db.things.ensureIndex({j:1, name:-1});> db.factories.insert( { name: "xyz", metro: { city: "New York", state: "NY" } } );> db.factories.ensureIndex( { metro : 1 } ); // this query can use the above index: >> db.factories.find( { metro: { city: "New York", state: "NY" } } );// this one too, as {city:"New York"} < {city:"New York",state:"NY"}> db.factories.find( { metro: { $gte : { city: "New York" } } } );// this query does not match the document because the order of fields is significant> db.factories.find( { metro: { state: "NY" , city: "New York" } } );
  • 7. Replication Asynchronous Replication
  • 8. HA & FailOverOnly Write to PrimaryCan read from SecondaryOp Ordinal:Increasing ordinal to represent each operationUsing Server ID + Op Ordinal
  • 9. Picking Primary1. Get Max LocalOpOrdinal from each Server2. if a majority of servers are not up (fromthis servers POV), remain in Secondarymode and stop.3. if the last op time seems very old, stopand await human intervention.4. else, using a consensus protocol, pick theserver with the highest maxLocalOpOrdinalas the Primary.
  • 10. TIPs.
  • 11. Use 64bit MachineMongoDB Use Memory-Mapped FileIn 32bit. DB Size can’t over 2.5GBMongoDB is needed Big Memory
  • 12. Use Replica SetUse Replica Set and Journaling
  • 13. Use Lastest Version2.0.2 is better than 1.8.xMongoDB has global Lock1.8.x uses global Write Lock2.0.x uses write with yield.Not supports db or collection lock
  • 14. Use Big MemoryDisk Op is slower than Memory Op
  • 15. Shard
  • 16. Shard Architecture
  • 17. BasicData is split up into ChunksChunk: 64mb or 100,000 objects Replication unit is chunk. Chunk Count > 9
  • 18. MongodData Store Replica Set(3 mongod)
  • 19. MongosProxy StateLess Routing to Shard
  • 20. Mongod configSvrmongodCan’t use Replica Set or M/A1(test) or 3(real)
  • 21. Mongod configSvrChanges are made with 2PCIf any are down, meta datagoes read onlySystem is online as long as 1/3is up
  • 22. Use Scale Up than ShardingDifficult to find good Shard Key.Not Support Data CenterawarenessAdd memory and hdd, ssd
  • 23. Object Id_
  • 24. Object Id_12 bytes
  • 25. Replica Set
  • 26. OperationsDefault: Write/read operationgoes to masterCan read from slaves.
  • 27. Thank you!