SlideShare a Scribd company logo
MongoDB: Replication,Sharding,MapReduce
MongoDB: Replication,Sharding,MapReduce
MongoDB: Replication,Sharding,MapReduce
MongoDB: Replication,Sharding,MapReduce
MongoDB: Replication,Sharding,MapReduce
MongoDB: Replication,Sharding,MapReduce
MongoDB: Replication,Sharding,MapReduce
MongoDB: Replication,Sharding,MapReduce
{

    "_id" : ObjectId("4dcd3ebc9278000000005158"),

    "timestamp" : ISODate("2011-05-13T14:22:46.777Z"),

    "binary" : BinData(0,""),

    "string" : "abc",

    "number" : 3,

    "subobj" : {"subA": 1, "subB": 2 },

    "array" : [1, 2, 3],

    "dbref" : [_id1, _id2, _id3]

                        padding

}
{   db.coll.find({"string": "abc"});
db.coll.find({ "string" : /^a.*$/i });
    "_id" : ObjectId("4dcd3ebc9278000000005158"),

    "timestamp" : ISODate("2011-05-13T14:22:46.777Z"),
                   db.coll.find({"subobj.subA": 1});
                db.coll.find({"subobj.subB": {$exists: true} });
    "binary" : BinData(0,""),

    "string" : "abc",              db.coll.find({"number": 3});
                               db.coll.find({"number": {$gt: 1}});
    "number" : 3,

    "subobj" : {"subA": 1, "subB": 2 },

    "array" : [1, 2, 3],
                         db.coll.find({"array": {$all:[1, 2]} });
    "dbref" : [_id1, _id2, _id3]
                        db.coll.find({"array": {$in:[2, 4, 6]} });
                             padding

}
{

    "_id" : ObjectId("4dcd3ebc9278000000005158"),

    "timestamp" : ISODate("2011-05-13T14:22:46.777Z"),
          { $set : {"string": "def"} }

    "binary" : BinData(0,""), { $inc : {"number": 1} }

    "string" : "def",
                          { $pull : {"subobj": {"subB": 2 } } }
    "number" : 4,

    "subobj" : {"subA": 1, "subB": 2 },

    "array" : [1, 2, 3, 4, 5, 6],

    "dbref"$addToSet : { "array" : { $each : [ 4 , 5 , 6 ] } } }
         { : [_id1, _id2, _id3]


    "newkey" : "In-place"

}                              { $set : {"newkey": "In-place"} }
MongoDB: Replication,Sharding,MapReduce
MongoDB: Replication,Sharding,MapReduce
Member1     Member2
Primary     Secondary




Member4     Member3
Secondary   Secondary
Member1     Member2
Primary     Secondary




Member4     Member3
Secondary   Secondary
Member1     Member2
Primary     Secondary




Member4     Member3
Secondary   Secondary
Member2
            Secondary




Member4     Member3
Secondary   Secondary
Member1
            Primary

Member6                 Member2
Secondary               Secondary




Member5                 Member3
Secondary               Secondary
            Member4
            Secondary
Member1
            Primary

Member6                 Member2
Secondary               Secondary




Member5                 Member3
Secondary               Secondary
            Member4
            Secondary
Member1
            Primary

Member6                 Member2
Secondary               Secondary




Member5                 Member3
Secondary               Secondary
            Member4
            Secondary
MongoDB: Replication,Sharding,MapReduce
MongoDB: Replication,Sharding,MapReduce
MongoDB: Replication,Sharding,MapReduce
Chunk

         Shard Key   Chunk

 200MB
Cluster
                                   Shard Servers (Data)
   config Servers
 (Shard Configration)   shard1           shard2           shard3
                        [ a, f )          [ k, n)         [ o, t )   Chunk
                        [ f, k )          [ n, o )        [ t, } )




                               mongos Servers (Routers)
http://www.mongodb.org/display/DOCS/Introduction
primary
  Shard
                      primary
      1
 ( mongos
primary     primary                   primary
        )
                         Shard




cinfig      Shard
                                      mongos
                                http://www.mongodb.org/display/DOCS/Introduction
shard1                   shard2

[ a, f )       [ n, o )   [ o, t)
       [ 0, 9)
[ f, k )       [ k, n)



           shard1                   shard2

[ a, f )                  [ o, t)        [ n, o )


[ f, k )       [ k, n)    [ 0, 9)
MongoDB: Replication,Sharding,MapReduce
MongoDB: Replication,Sharding,MapReduce
MongoDB: Replication,Sharding,MapReduce
MongoDB: Replication,Sharding,MapReduce
MongoDB: Replication,Sharding,MapReduce
m = function(){
     this.tags.forEach{
          function(z) {
              emit(z, {count: 1});
          }
     };
};
r = function(key, values) {
     var total=0;
     for (i=0, i<values.length, i++)
          total += values[i].count;
     return { count : total };
}
res=db.things.mapReduce(m,!r);
#                              finalize
MongoDB: Replication,Sharding,MapReduce
MongoDB: Replication,Sharding,MapReduce
MongoDB: Replication,Sharding,MapReduce
MongoDB: Replication,Sharding,MapReduce
MongoDB: Replication,Sharding,MapReduce

More Related Content

PDF
はじめてのMongoDB
PDF
20110514 mongo dbチューニング
PDF
Mongodb workshop
PDF
MongoDBで作るソーシャルデータ新解析基盤
PDF
AST + Better Reflection (PHP Benelux 2016 Unconference)
PDF
San Francisco Java User Group
PDF
MongoDB全機能解説2
はじめてのMongoDB
20110514 mongo dbチューニング
Mongodb workshop
MongoDBで作るソーシャルデータ新解析基盤
AST + Better Reflection (PHP Benelux 2016 Unconference)
San Francisco Java User Group
MongoDB全機能解説2

What's hot (20)

PDF
Inside MongoDB: the Internals of an Open-Source Database
PDF
Latinoware
PDF
MongoUK - PHP Development
PDF
Introduction to jRuby
PDF
The State of NoSQL
PDF
MongoDB Oplog入門
PDF
Redis the better NoSQL
PDF
Moose Lightning Talk
KEY
C# Development (Sam Corder)
PDF
Couchdb
PDF
Elastic search 검색
PPTX
20171014 tips for manipulating filesystem in julia
PPTX
MongoDB-SESSION03
PPTX
Webinar: Replication and Replica Sets
PPTX
MooseX::Datamodel - Barcelona Perl Workshop Lightning talk
PDF
Realm to Json & Royal
PDF
Map Reduce 〜入門編:仕組みの理解とアルゴリズムデザイン〜
PDF
From mysql to MongoDB(MongoDB2011北京交流会)
TXT
Tipo virus espia con esto aprenderan a espiar a personas etc jeropas de mrd :v
PDF
MongoDBと位置情報 ~地理空間インデックスの紹介
Inside MongoDB: the Internals of an Open-Source Database
Latinoware
MongoUK - PHP Development
Introduction to jRuby
The State of NoSQL
MongoDB Oplog入門
Redis the better NoSQL
Moose Lightning Talk
C# Development (Sam Corder)
Couchdb
Elastic search 검색
20171014 tips for manipulating filesystem in julia
MongoDB-SESSION03
Webinar: Replication and Replica Sets
MooseX::Datamodel - Barcelona Perl Workshop Lightning talk
Realm to Json & Royal
Map Reduce 〜入門編:仕組みの理解とアルゴリズムデザイン〜
From mysql to MongoDB(MongoDB2011北京交流会)
Tipo virus espia con esto aprenderan a espiar a personas etc jeropas de mrd :v
MongoDBと位置情報 ~地理空間インデックスの紹介
Ad

Viewers also liked (11)

PPT
Mongo db roma replication and sharding
PDF
MongoDB by Tonny
DOCX
MongoDB Replication and Sharding
PPTX
Aggregation Framework
ODP
MongoDB: Advance concepts - Replication and Sharding
PPTX
MongoDB Introduction - Document Oriented Nosql Database
KEY
MongoDB Aggregation Framework
PPTX
"Sharding - patterns & antipatterns". Доклад Алексея Рыбака (Badoo) и Констан...
PDF
Data Processing and Aggregation with MongoDB
KEY
An Introduction to Map/Reduce with MongoDB
PPT
Introduction to MongoDB
Mongo db roma replication and sharding
MongoDB by Tonny
MongoDB Replication and Sharding
Aggregation Framework
MongoDB: Advance concepts - Replication and Sharding
MongoDB Introduction - Document Oriented Nosql Database
MongoDB Aggregation Framework
"Sharding - patterns & antipatterns". Доклад Алексея Рыбака (Badoo) и Констан...
Data Processing and Aggregation with MongoDB
An Introduction to Map/Reduce with MongoDB
Introduction to MongoDB
Ad

Similar to MongoDB: Replication,Sharding,MapReduce (20)

PPTX
MongoDB Live Hacking
PDF
MongoDB: Intro & Application for Big Data
PDF
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
KEY
MongoDB Best Practices in AWS
PPTX
Mongodb introduction and_internal(simple)
PPTX
Scaling with MongoDB
PDF
mongodb-introduction
KEY
MongoDB, Hadoop and Humongous Data
PDF
MongoDB, Hadoop and humongous data - MongoSV 2012
PPTX
Introduction to MongoDB
PPTX
Advanced Sharding Features in MongoDB 2.4
KEY
MongoDB and hadoop
PPTX
MongoDB San Francisco 2013: Hash-based Sharding in MongoDB 2.4 presented by B...
PDF
FrozenRails Training
PDF
Mongo DBを半年運用してみた
PPTX
Webinar: MongoDB 2.4 Feature Demo and Q&A on Hash-based Sharding
KEY
2012 phoenix mug
KEY
Scaling MongoDB (Mongo Austin)
PDF
Mongo db
PPT
MongoDB Basic Concepts
MongoDB Live Hacking
MongoDB: Intro & Application for Big Data
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
MongoDB Best Practices in AWS
Mongodb introduction and_internal(simple)
Scaling with MongoDB
mongodb-introduction
MongoDB, Hadoop and Humongous Data
MongoDB, Hadoop and humongous data - MongoSV 2012
Introduction to MongoDB
Advanced Sharding Features in MongoDB 2.4
MongoDB and hadoop
MongoDB San Francisco 2013: Hash-based Sharding in MongoDB 2.4 presented by B...
FrozenRails Training
Mongo DBを半年運用してみた
Webinar: MongoDB 2.4 Feature Demo and Q&A on Hash-based Sharding
2012 phoenix mug
Scaling MongoDB (Mongo Austin)
Mongo db
MongoDB Basic Concepts

More from Takahiro Inoue (20)

PDF
Treasure Data × Wave Analytics EC Demo
PDF
トレジャーデータとtableau実現する自動レポーティング
PDF
Tableauが魅せる Data Visualization の世界
PDF
トレジャーデータのバッチクエリとアドホッククエリを理解する
PDF
20140708 オンラインゲームソリューション
PDF
トレジャーデータ流,データ分析の始め方
PDF
オンラインゲームソリューション@トレジャーデータ
PDF
事例で学ぶトレジャーデータ 20140612
PDF
トレジャーデータ株式会社について(for all Data_Enthusiast!!)
PDF
この Visualization がすごい2014 〜データ世界を彩るツール6選〜
PDF
Treasure Data Intro for Data Enthusiast!!
PDF
Hadoop and the Data Scientist
PDF
An Introduction to Fluent & MongoDB Plugins
PDF
An Introduction to Tinkerpop
PDF
An Introduction to Neo4j
PDF
The Definition of GraphDB
PDF
Large-Scale Graph Processing〜Introduction〜(完全版)
PDF
Large-Scale Graph Processing〜Introduction〜(LT版)
PDF
Advanced MongoDB #1
PDF
はじめてのGlusterFS
Treasure Data × Wave Analytics EC Demo
トレジャーデータとtableau実現する自動レポーティング
Tableauが魅せる Data Visualization の世界
トレジャーデータのバッチクエリとアドホッククエリを理解する
20140708 オンラインゲームソリューション
トレジャーデータ流,データ分析の始め方
オンラインゲームソリューション@トレジャーデータ
事例で学ぶトレジャーデータ 20140612
トレジャーデータ株式会社について(for all Data_Enthusiast!!)
この Visualization がすごい2014 〜データ世界を彩るツール6選〜
Treasure Data Intro for Data Enthusiast!!
Hadoop and the Data Scientist
An Introduction to Fluent & MongoDB Plugins
An Introduction to Tinkerpop
An Introduction to Neo4j
The Definition of GraphDB
Large-Scale Graph Processing〜Introduction〜(完全版)
Large-Scale Graph Processing〜Introduction〜(LT版)
Advanced MongoDB #1
はじめてのGlusterFS

Recently uploaded (20)

PDF
Empathic Computing: Creating Shared Understanding
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
A Presentation on Artificial Intelligence
PDF
cuic standard and advanced reporting.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Big Data Technologies - Introduction.pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Cloud computing and distributed systems.
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Machine learning based COVID-19 study performance prediction
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
Empathic Computing: Creating Shared Understanding
Understanding_Digital_Forensics_Presentation.pptx
A Presentation on Artificial Intelligence
cuic standard and advanced reporting.pdf
Network Security Unit 5.pdf for BCA BBA.
Big Data Technologies - Introduction.pptx
Digital-Transformation-Roadmap-for-Companies.pptx
Spectral efficient network and resource selection model in 5G networks
MYSQL Presentation for SQL database connectivity
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
The AUB Centre for AI in Media Proposal.docx
20250228 LYD VKU AI Blended-Learning.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
Mobile App Security Testing_ A Comprehensive Guide.pdf
NewMind AI Weekly Chronicles - August'25 Week I
Cloud computing and distributed systems.
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Machine learning based COVID-19 study performance prediction
Diabetes mellitus diagnosis method based random forest with bat algorithm

MongoDB: Replication,Sharding,MapReduce

  • 9. { "_id" : ObjectId("4dcd3ebc9278000000005158"), "timestamp" : ISODate("2011-05-13T14:22:46.777Z"), "binary" : BinData(0,""), "string" : "abc", "number" : 3, "subobj" : {"subA": 1, "subB": 2 }, "array" : [1, 2, 3], "dbref" : [_id1, _id2, _id3] padding }
  • 10. { db.coll.find({"string": "abc"}); db.coll.find({ "string" : /^a.*$/i }); "_id" : ObjectId("4dcd3ebc9278000000005158"), "timestamp" : ISODate("2011-05-13T14:22:46.777Z"), db.coll.find({"subobj.subA": 1}); db.coll.find({"subobj.subB": {$exists: true} }); "binary" : BinData(0,""), "string" : "abc", db.coll.find({"number": 3}); db.coll.find({"number": {$gt: 1}}); "number" : 3, "subobj" : {"subA": 1, "subB": 2 }, "array" : [1, 2, 3], db.coll.find({"array": {$all:[1, 2]} }); "dbref" : [_id1, _id2, _id3] db.coll.find({"array": {$in:[2, 4, 6]} }); padding }
  • 11. { "_id" : ObjectId("4dcd3ebc9278000000005158"), "timestamp" : ISODate("2011-05-13T14:22:46.777Z"), { $set : {"string": "def"} } "binary" : BinData(0,""), { $inc : {"number": 1} } "string" : "def", { $pull : {"subobj": {"subB": 2 } } } "number" : 4, "subobj" : {"subA": 1, "subB": 2 }, "array" : [1, 2, 3, 4, 5, 6], "dbref"$addToSet : { "array" : { $each : [ 4 , 5 , 6 ] } } } { : [_id1, _id2, _id3] "newkey" : "In-place" } { $set : {"newkey": "In-place"} }
  • 14. Member1 Member2 Primary Secondary Member4 Member3 Secondary Secondary
  • 15. Member1 Member2 Primary Secondary Member4 Member3 Secondary Secondary
  • 16. Member1 Member2 Primary Secondary Member4 Member3 Secondary Secondary
  • 17. Member2 Secondary Member4 Member3 Secondary Secondary
  • 18. Member1 Primary Member6 Member2 Secondary Secondary Member5 Member3 Secondary Secondary Member4 Secondary
  • 19. Member1 Primary Member6 Member2 Secondary Secondary Member5 Member3 Secondary Secondary Member4 Secondary
  • 20. Member1 Primary Member6 Member2 Secondary Secondary Member5 Member3 Secondary Secondary Member4 Secondary
  • 24. Chunk Shard Key Chunk 200MB
  • 25. Cluster Shard Servers (Data) config Servers (Shard Configration) shard1 shard2 shard3 [ a, f ) [ k, n) [ o, t ) Chunk [ f, k ) [ n, o ) [ t, } ) mongos Servers (Routers)
  • 27. primary Shard primary 1 ( mongos primary primary primary ) Shard cinfig Shard mongos http://www.mongodb.org/display/DOCS/Introduction
  • 28. shard1 shard2 [ a, f ) [ n, o ) [ o, t) [ 0, 9) [ f, k ) [ k, n) shard1 shard2 [ a, f ) [ o, t) [ n, o ) [ f, k ) [ k, n) [ 0, 9)
  • 34. m = function(){ this.tags.forEach{ function(z) { emit(z, {count: 1}); } }; }; r = function(key, values) { var total=0; for (i=0, i<values.length, i++) total += values[i].count; return { count : total }; } res=db.things.mapReduce(m,!r); # finalize