Your SlideShare is downloading. ×
0
MongoDBIntroduction      2012/02/16 Tse-Ching Ho 何澤清
About meRuby Developer     Twitter: tsechingho2011: 開始使用 NoSQL   Skype: tsechingho1978工作。                   GitHub: https:...
Not Only SQLKey V alue Store:   Column Store:Memcached, Redis,   Cassandra, Hadoop/Couchbase Server,   HBase, Hypertable,B...
What & Why
Size matters
Type matters
Place matters
Time matters
Money matters
Person mattersEasy learn, Easy use, Easy designQuick, AgileFlexibilityNice APIs are best &iends
Specification
MongoDB vs RDBMS
FeaturesWritten in: C++                           Better update-in-place than CouchDBMain point: Retains some &iendly     ...
Key PointsDocument based,       Eventual consistencyCo#ection driven                      ReplicationEmbeded, Referenced  ...
Install
Mac/usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"brew insta# mongodbcp /usr/local/Ce#ar/mongodb/2.0.2...
Debianecho "deb http://downloads-distro.mongodb.org/repo/debian-sysvinit dist 10gen" > /etc/apt/sources.list.d/10gen.lista...
Ruby & Mongoidbash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-insta#er )rvm insta...
Configurationvim $(brew --prefix mongodb)/mongod.confvim /etc/mongodb.confdbpath = /usr/local/var/mongodblogpath = /usr/loca...
Syntax
BSON{    "_id" : ObjectId("4d3ed089#60ab534684b7e9"),    "title" : "Sir",    "name" : {      "_id" : ObjectId("4d3ed089#60...
Database Manipulationmongo                     > db.things.count()> help                    > db.things.dataSize()> show d...
CRUDCreate Co#ection             Update Co#ection> db.things.insert({db:      > db.things.update({db:mongodb, type:native}...
QueryGeneral find                                 Conditional Operators                                               <, <=...
ELSEIndexMap / ReduceTransaction / ACID
Application
Replica Setsasynchronous replicationdistributing read loadautomatic recoveryautomatic failoverauto election of primaryprim...
Demo Codehttps://github.com/tsechingho/mongodb-tutorial
ShardingBalancing            Shards (Replica Sets)Failover             Config ServerScaling model        Mongos (Router,   ...
Sharding Components
Servers layout
Sharding Architecture
Usage CasesSma# nested data set   Reproducible data set  Comments, Tweets,      API fetched data  SMS                     ...
Tools
MongoHubManagementhttp://mongohub.todayclose.com/
Mongo 3Data manipulationhttps://github.com/derailed/mongo3
Thought
References
http://nosql-database.orghttp://blog.nosqlfan.comhttp://www.mongodb.orghttp://mongoid.org/
Upcoming SlideShare
Loading in...5
×

mongodb-introduction

2,725

Published on

NoSQL Taiwan #1 Talk

Published in: Technology
0 Comments
6 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,725
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
69
Comments
0
Likes
6
Embeds 0
No embeds

No notes for slide

Transcript of "mongodb-introduction"

  1. 1. MongoDBIntroduction 2012/02/16 Tse-Ching Ho 何澤清
  2. 2. About meRuby Developer Twitter: tsechingho2011: 開始使用 NoSQL Skype: tsechingho1978工作。 GitHub: https://2011.9-present: github.com/tsechingho陽明大學生物資訊所資深工程師
  3. 3. Not Only SQLKey V alue Store: Column Store:Memcached, Redis, Cassandra, Hadoop/Couchbase Server, HBase, Hypertable,BerkeleyDB, Riak, Amazon SimpleDBDynamoDB Graphic Database:Document Store: Neo4j, InfiniteGraph,MongoDB, CouchDB, InfoGrid, A#egroGraph,OrientDB, RavenDB HyperGraphDB
  4. 4. What & Why
  5. 5. Size matters
  6. 6. Type matters
  7. 7. Place matters
  8. 8. Time matters
  9. 9. Money matters
  10. 10. Person mattersEasy learn, Easy use, Easy designQuick, AgileFlexibilityNice APIs are best &iends
  11. 11. Specification
  12. 12. MongoDB vs RDBMS
  13. 13. FeaturesWritten in: C++ Better update-in-place than CouchDBMain point: Retains some &iendly Uses memory mapped files for dataproperties of SQL. (Query, index) storageLicense: AGPL (Drivers: Apache) Performance over featuresProtocol: Custom, binary (BSON) Journaling (with --journal) is best turnedMaster/slave replication (auto failover onwith replica sets) On 32bit systems, limited to ~2.5GbSharding built-in An empty database takes up 192MbQueries are javascript expressions GridFS to store big data + metadata (notRun arbitrary javascript functions actua#y an FS)server-side Has geospatial indexing
  14. 14. Key PointsDocument based, Eventual consistencyCo#ection driven ReplicationEmbeded, Referenced ShardingSchema &ee pros: easy additionDistributed cons: fault tolerance,Durability migration tolerance
  15. 15. Install
  16. 16. Mac/usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"brew insta# mongodbcp /usr/local/Ce#ar/mongodb/2.0.2-x86_64/org.mongodb.mongod.plist ~/Library/LaunchAgents/launchctl load -w ~/Library/LaunchAgents/org.mongodb.mongod.plist
  17. 17. Debianecho "deb http://downloads-distro.mongodb.org/repo/debian-sysvinit dist 10gen" > /etc/apt/sources.list.d/10gen.listapt-key adv --keyserver keyserver.ubuntu.com --recv7F0CEB10aptitude updateaptitude insta# mongodb-10gen
  18. 18. Ruby & Mongoidbash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-insta#er )rvm insta# ruby-1.9.3gem insta# mongoid
  19. 19. Configurationvim $(brew --prefix mongodb)/mongod.confvim /etc/mongodb.confdbpath = /usr/local/var/mongodblogpath = /usr/local/var/log/mongodbbind_ip = 127.0.0.1
  20. 20. Syntax
  21. 21. BSON{ "_id" : ObjectId("4d3ed089#60ab534684b7e9"), "title" : "Sir", "name" : { "_id" : ObjectId("4d3ed089#60ab534684b7ff "), "first_name" : "Durran" }, "addresses" : [ { "_id" : ObjectId("4d3ed089#60ab534684b7e0"), "city" : "Berlin", "country" : "Deutschland" } ]}
  22. 22. Database Manipulationmongo > db.things.count()> help > db.things.dataSize()> show dbs > db.things.find()> use demo > db.things.remove()> db.things > db.dropDatabase()> db.things.help()> db.things.save({name:NoSQL Taiwan})
  23. 23. CRUDCreate Co#ection Update Co#ection> db.things.insert({db: > db.things.update({db:mongodb, type:native}) mongodb}, {db: redis}) > db.things.update({db:Retrieve Co#ection redis}, {$set: {type: copy}})> db.things.find({db:mongodb}) Delete Co#ection> db.things.find({db: > db.things.remove({db:mongodb}, {type: false}) redis})
  24. 24. QueryGeneral find Conditional Operators <, <=, >, >= db.things.find( { x : 3, y : "foo" } ); $a# db.things.find({j: {$ne: 3}, k: {$gt: $exists 10} }); $modRegular Expressions $ne db.customers.find( { name : $in { $regex : acme.*corp, $options: $nin i } } ); $nor $or $and $size $type
  25. 25. ELSEIndexMap / ReduceTransaction / ACID
  26. 26. Application
  27. 27. Replica Setsasynchronous replicationdistributing read loadautomatic recoveryautomatic failoverauto election of primaryprimary for writes replacement of master-slave
  28. 28. Demo Codehttps://github.com/tsechingho/mongodb-tutorial
  29. 29. ShardingBalancing Shards (Replica Sets)Failover Config ServerScaling model Mongos (Router, Routing Processes)
  30. 30. Sharding Components
  31. 31. Servers layout
  32. 32. Sharding Architecture
  33. 33. Usage CasesSma# nested data set Reproducible data set Comments, Tweets, API fetched data SMS Analysis data Manipulation logTime careless CMS
  34. 34. Tools
  35. 35. MongoHubManagementhttp://mongohub.todayclose.com/
  36. 36. Mongo 3Data manipulationhttps://github.com/derailed/mongo3
  37. 37. Thought
  38. 38. References
  39. 39. http://nosql-database.orghttp://blog.nosqlfan.comhttp://www.mongodb.orghttp://mongoid.org/
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×