Introduction to Mongodb
Upcoming SlideShare
Loading in...5
×
 

Introduction to Mongodb

on

  • 3,372 views

Introduction to MongoDB

Introduction to MongoDB

Statistics

Views

Total Views
3,372
Views on SlideShare
789
Embed Views
2,583

Actions

Likes
2
Downloads
27
Comments
0

2 Embeds 2,583

http://devveri.com 2572
https://twitter.com 11

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Introduction to Mongodb Introduction to Mongodb Presentation Transcript

  • MongoDBIntroduction to MongoDB
  • Harun YardımcıSoftware Architect @ eBay@nosqlcozumler
  • What is MongoDB?MongoDB is a scalable, high-performance, open-source,schema-free, document-oriented database developed by10gen.- MongoDB is named from "huMONGOus," meaning "extremely large".
  • Features•  Dynamic schemas•  Full, flexible index support and rich queries•  Sharding for horizontal scalability•  Replication for high availability•  Text search•  Advanced security•  Aggregation Framework and Map-Reduce•  GridFS•  Geospatial
  • TerminologyRDBMS MongoDBTable CollectionRow DocumentIndex IndexJoin Embedded DocumentForeign Key ReferencePartition ShardDatabase Database
  • NoSQL Databases
  • Document Database•  What is a document?o  PDF, Word document, text file?Document is an associated array
  • Deployment Architecture•  Standalone•  Replica Set•  Sharded ClusterStandalone < Replica Set < Sharded Cluster** Typical sharded cluster consist of replica sets in production.
  • CAP TheoremAvailabilityConsistencyPartitionToleranceN/ACAAPCPOracleMySQLPostgresMongoDBBigTableHBaseRedisMemcacheCouchDBCassandraRiakDynamoSimpleDB
  • Standalone$ mongod--dbpath /data/db--fork--logappend--logpath /var/log/mongod.log--journal--port 27017
  • Configuration Filevim /etc/mongod.confdbpath = /data/dbfork = truelogappend = truelogpath = /var/log/mongodb.logjournal = trueport = 27017$ mongod --config /etc/mongod.conf
  • ReplicationRedundancy, Backup, and Automatic Failover•  Master / Slave (Deprecated since 1.6)•  Replica Set
  • Replica Set$ mongod--dbpath /data/db--fork--logappend--logpath /var/log/mongod.log--journal--port 27017--replSet set01
  • Replica Set InitializationStartup mongod process and connect to one of them> var cnf = { _id : set01, members : [{ _id : 0, host: myhost1.net:27017 },{ _id : 1, host: myhost2.net:27017 },{ _id : 2, host: myhost3.net:27017 }]}> rs.initiate(cnf)
  • Replica Set•  Majority•  Voting•  Arbiters•  Hidden Members•  Delayed Members
  • Application Concerns•  Write Concerno  Errors Ignoredo  Unacknowledgeo  Acknowledged (default)o  Journaledo  Replica Acknowledged•  Read Preferenceso  primaryo  primaryPreferredo  secondaryo  secondaryPreferredo  nearest
  • Sharding•  Why?•  Scale-out•  Store different part of data on different hosts•  Auto Balancing
  • Sharding Components•  Shardso  Standaloneo  Replica Set•  Config Servers•  Mongos
  • Replica Set as a ShardAdd each replica set as a shard> sh.addShard( "set01/myhost1.net:27017, myhost2.net:27017,myhost3.net:27017" )To add standalone server as a shard.. DON’T DO IT!!> sh.addShard( "myhost9.net:27017" )
  • Selecting Shard Key•  Distribution of Data•  Hashed Shard Key•  Chunks and Balancing
  • Enable ShardingYou must enable sharding on each database separately> sh.enableSharding("mydatabase")And for each collection> sh.shardCollection( "mydatabase.mycol", { "userId" : 1 } )
  • ThanksIf you have any questions, please feel free to ask