SlideShare ist ein Scribd-Unternehmen logo
1 von 31
Julie Sommerville
jsommerville@businessinsider.com
DB1 primary                     DB3 primary

  businessinsider                  bi_analytics

           64GB                          16GB


Web1                            DB2 - Secondary

 arbiter businessinsider
                               businessinsider port xxxxx
 arbiter bi_analytics
                               bi_analytics port yyyyyy     32GB
                        16GB
It’s very easy to add a new nodes to a replica set


Start the process on the new server:
    mkdir /data/db
   mongod --port xxx --dbpath /data/db --replSet setname

Add the node on the Primary DB
  rs.add(“[hostname]:port”);
Most of the operations we perform on the analytics db are atomic in-place updates :

 analytics.heatmap.update(
  {
   homepage_id:"4ecfb4eefcda248b89000003",
   uri : "/ron-paul-slams-trump-joins-huntsman-in-sitting-out-circus-like-debate-2011-12"
   },
   {
       $inc : {views : 1},
       $set : {updated_at : {"sec":1329587057,"usec":175000}} }},
       true // upsert
)
Check this
Process
Example: adding a new field to an object
In the console

> var myObj = {name: 'julie', role: "developer"}

//creates the foo collection and inserts an object
> db.foo.save(myObj)

> db.foo.find()
{ "_id" : ObjectId("4f418251f4dd8d3d88a776ea"), "name" : "julie", "role" : "developer" }

// Add a new field
var julie = db.foo.findOne()
{
       "_id" : ObjectId("4f418251f4dd8d3d88a776ea"),
       "name" : "julie",
       "role" : "developer"
}
> julie.last_name = "sommerville'

> db.foo.save(julie)

> db.foo.find().pretty()
{
      "_id" : ObjectId("4f418251f4dd8d3d88a776ea"),
      "name" : "julie",
      "role" : "developer",
      "last_name" : "sommerville"
}

(pretty just makes it pretty)
Some Examples from our DB
Post Object: contains comments, many posts will have way more than a couple of comments

db.blog.posts.findOne({comments : {$exists:true}, comment_count : {$gte: 1}, ts : {$gte: start}})
{
    "_id" : ObjectId("4d4798c949e2aef0100d0000"),
    "attached_images" : [ ],
    "author" : "Ed Dolan",
    "author_id" : ObjectId("4d121ca0ccd1d5d337000000"),
    "autotweet" : false,
    "badges" : [ ],
    "browser_title" : null,
    "categories" : [ ],
    "cls" : "entry",
    "comment_count" : 1,
    "comment_thread_count" : 1,
    "comments" : [
         {
               "cid" : ObjectId("4d482923cadcbb310a080000"),
               "ts" : ISODate("2011-02-01T15:39:15.541Z"),
               "ip" : "113.53.150.3",
               "author" : "kenhow",
               "email" : "info@howincorporated.com",
               "url" : "http://howincorporated.com",
               "user_id" : ObjectId("4d32fceaccd1d53d7b010000"),
               "text" : "In other words: nothing to worry about"
         }
    ],
We also store the Replies to comments :

     {
               "author" : "LS",
               "cid" : ObjectId("4eda72376bb3f72279000009"),
               "email" : "lawrenceshapiro@gmail.com",
               "flags" : [ ],
               "ip" : "74.68.112.217",
               "rate_down" : 0,
               "rate_up" : 6,
               "raters" : {
                      "$ref" : "blog.comments.raters",
                      "$id" : ObjectId("4eda72376bb3f72279000008")
               },
               "replies" : [
                      {
                              "cid" : ObjectId("4eda800b69beddf55900004f"),
                              "author" : "Skepticus Maximus",
                              "email" : "henry1807@yahoo.com",
                              "flags" : [ ],
                              "ip" : "66.159.194.20",
                              "rate_down" : 0,
                              "rate_up" : 1,
                              "raters" : {
                                     "$ref" : "blog.comments.raters",
                                     "$id" : ObjectId("4eda800b69beddf55900004e")
                              },
                              "reply" : ObjectId("4eda72376bb3f72279000009"),
                              "reply_author" : "LS",
                              "text" : "No, it's perfectly natural - nature's way to make sure the species continues",
                              "ts" : ISODate("2011-12-03T20:01:15.930Z"),
                              "url" : "",
                              "session_id" : ObjectId("4eda76e3eab8ea9f4d00003d")
                      },

* Fast retrieval - no joins
MMS (MongoDB Monitoring Service)

* Really nice stats with the ability to “zoom” in (minute, 5min, hour etc.).
* If the data base is acting up you can go in and see where the problem may lie

-- Num Collections
-- Data Size in the DB and in storage
-- Avg. doc size
-- Index Sizes
-- Replica Set Stats
-- page faults
-- the lock queue (reads and writes)
total number of contiguously allocated chunks of
         datafile space for the database
num commands




               index access and hits
secondary shouldn’t be more than this number
                 hours behind
shows slow ops
Sharding
- Probably on our main database
- Help deal with load/num of connections

Weitere ähnliche Inhalte

Was ist angesagt?

Operational Intelligence with MongoDB Webinar
Operational Intelligence with MongoDB WebinarOperational Intelligence with MongoDB Webinar
Operational Intelligence with MongoDB Webinar
MongoDB
 
MongoDB全機能解説2
MongoDB全機能解説2MongoDB全機能解説2
MongoDB全機能解説2
Takahiro Inoue
 
MongoDBで作るソーシャルデータ新解析基盤
MongoDBで作るソーシャルデータ新解析基盤MongoDBで作るソーシャルデータ新解析基盤
MongoDBで作るソーシャルデータ新解析基盤
Takahiro Inoue
 
San Francisco Java User Group
San Francisco Java User GroupSan Francisco Java User Group
San Francisco Java User Group
kchodorow
 

Was ist angesagt? (20)

Schema design
Schema designSchema design
Schema design
 
Mongo db for c# developers
Mongo db for c# developersMongo db for c# developers
Mongo db for c# developers
 
Mongo db for C# Developers
Mongo db for C# DevelopersMongo db for C# Developers
Mongo db for C# Developers
 
Operational Intelligence with MongoDB Webinar
Operational Intelligence with MongoDB WebinarOperational Intelligence with MongoDB Webinar
Operational Intelligence with MongoDB Webinar
 
20110514 mongo dbチューニング
20110514 mongo dbチューニング20110514 mongo dbチューニング
20110514 mongo dbチューニング
 
Introduction to the new official C# Driver developed by 10gen
Introduction to the new official C# Driver developed by 10genIntroduction to the new official C# Driver developed by 10gen
Introduction to the new official C# Driver developed by 10gen
 
MongoDB World 2016: Deciphering .explain() Output
MongoDB World 2016: Deciphering .explain() OutputMongoDB World 2016: Deciphering .explain() Output
MongoDB World 2016: Deciphering .explain() Output
 
MongoDB全機能解説2
MongoDB全機能解説2MongoDB全機能解説2
MongoDB全機能解説2
 
MongoDB Europe 2016 - ETL for Pros – Getting Data Into MongoDB The Right Way
MongoDB Europe 2016 - ETL for Pros – Getting Data Into MongoDB The Right WayMongoDB Europe 2016 - ETL for Pros – Getting Data Into MongoDB The Right Way
MongoDB Europe 2016 - ETL for Pros – Getting Data Into MongoDB The Right Way
 
Agg framework selectgroup feb2015 v2
Agg framework selectgroup feb2015 v2Agg framework selectgroup feb2015 v2
Agg framework selectgroup feb2015 v2
 
MongoDBで作るソーシャルデータ新解析基盤
MongoDBで作るソーシャルデータ新解析基盤MongoDBで作るソーシャルデータ新解析基盤
MongoDBで作るソーシャルデータ新解析基盤
 
NoSQL - An introduction to CouchDB
NoSQL - An introduction to CouchDBNoSQL - An introduction to CouchDB
NoSQL - An introduction to CouchDB
 
Apache CouchDB Presentation @ Sept. 2104 GTALUG Meeting
Apache CouchDB Presentation @ Sept. 2104 GTALUG MeetingApache CouchDB Presentation @ Sept. 2104 GTALUG Meeting
Apache CouchDB Presentation @ Sept. 2104 GTALUG Meeting
 
MongoDB Europe 2016 - Enabling the Internet of Things at Proximus - Belgium's...
MongoDB Europe 2016 - Enabling the Internet of Things at Proximus - Belgium's...MongoDB Europe 2016 - Enabling the Internet of Things at Proximus - Belgium's...
MongoDB Europe 2016 - Enabling the Internet of Things at Proximus - Belgium's...
 
MongoDB San Francisco 2013: Data Modeling Examples From the Real World presen...
MongoDB San Francisco 2013: Data Modeling Examples From the Real World presen...MongoDB San Francisco 2013: Data Modeling Examples From the Real World presen...
MongoDB San Francisco 2013: Data Modeling Examples From the Real World presen...
 
Map/Confused? A practical approach to Map/Reduce with MongoDB
Map/Confused? A practical approach to Map/Reduce with MongoDBMap/Confused? A practical approach to Map/Reduce with MongoDB
Map/Confused? A practical approach to Map/Reduce with MongoDB
 
San Francisco Java User Group
San Francisco Java User GroupSan Francisco Java User Group
San Francisco Java User Group
 
Webinar: Exploring the Aggregation Framework
Webinar: Exploring the Aggregation FrameworkWebinar: Exploring the Aggregation Framework
Webinar: Exploring the Aggregation Framework
 
MongoDB - Aggregation Pipeline
MongoDB - Aggregation PipelineMongoDB - Aggregation Pipeline
MongoDB - Aggregation Pipeline
 
MongoDB
MongoDBMongoDB
MongoDB
 

Andere mochten auch

Internet of things (iot)
Internet of things (iot)Internet of things (iot)
Internet of things (iot)
sankar s
 
Redefiners: Capturing Media Growth Dollars
Redefiners: Capturing Media Growth DollarsRedefiners: Capturing Media Growth Dollars
Redefiners: Capturing Media Growth Dollars
Activate
 

Andere mochten auch (20)

Internet of things (IoT)
Internet of things (IoT)Internet of things (IoT)
Internet of things (IoT)
 
Internet of things (iot)
Internet of things (iot)Internet of things (iot)
Internet of things (iot)
 
Tech Trends 2015: The fusion of business and IT
Tech Trends 2015: The fusion of business and ITTech Trends 2015: The fusion of business and IT
Tech Trends 2015: The fusion of business and IT
 
Strategy, Not Technology, Drives Digital Transformation
Strategy, Not Technology, Drives Digital TransformationStrategy, Not Technology, Drives Digital Transformation
Strategy, Not Technology, Drives Digital Transformation
 
Moving digital transformation forward: Findings from the 2016 digital busines...
Moving digital transformation forward: Findings from the 2016 digital busines...Moving digital transformation forward: Findings from the 2016 digital busines...
Moving digital transformation forward: Findings from the 2016 digital busines...
 
101 Digital Transformation Statistics (2016)
101 Digital Transformation Statistics (2016) 101 Digital Transformation Statistics (2016)
101 Digital Transformation Statistics (2016)
 
Think Again: Media + Tech 2014
Think Again: Media + Tech 2014Think Again: Media + Tech 2014
Think Again: Media + Tech 2014
 
Redefiners: Capturing Media Growth Dollars
Redefiners: Capturing Media Growth DollarsRedefiners: Capturing Media Growth Dollars
Redefiners: Capturing Media Growth Dollars
 
Activate: What Matters
Activate: What MattersActivate: What Matters
Activate: What Matters
 
What Will Matter For Media-Tech
What Will Matter For Media-TechWhat Will Matter For Media-Tech
What Will Matter For Media-Tech
 
How to develop a digital strategy
How to develop a digital strategyHow to develop a digital strategy
How to develop a digital strategy
 
Managing your Digital Transformation
Managing your Digital TransformationManaging your Digital Transformation
Managing your Digital Transformation
 
5 questions about the IoT (Internet of Things)
5 questions about the IoT (Internet of Things) 5 questions about the IoT (Internet of Things)
5 questions about the IoT (Internet of Things)
 
Internet of Things
Internet of ThingsInternet of Things
Internet of Things
 
Exploiting The Potential Of Big Data
Exploiting The Potential Of Big DataExploiting The Potential Of Big Data
Exploiting The Potential Of Big Data
 
Words that Sell
Words that SellWords that Sell
Words that Sell
 
What is the Internet of Things?
What is the Internet of Things?What is the Internet of Things?
What is the Internet of Things?
 
What exactly is the "Internet of Things"?
What exactly is the "Internet of Things"?What exactly is the "Internet of Things"?
What exactly is the "Internet of Things"?
 
Top Digital Transformation Trends and Priorities for 2016
Top Digital Transformation Trends and Priorities for 2016Top Digital Transformation Trends and Priorities for 2016
Top Digital Transformation Trends and Priorities for 2016
 
Internet-of-things- (IOT) - a-seminar - ppt - by- mohan-kumar-g
Internet-of-things- (IOT) - a-seminar - ppt - by- mohan-kumar-gInternet-of-things- (IOT) - a-seminar - ppt - by- mohan-kumar-g
Internet-of-things- (IOT) - a-seminar - ppt - by- mohan-kumar-g
 

Ähnlich wie Mongo db presentation

MongoDB Performance Tuning
MongoDB Performance TuningMongoDB Performance Tuning
MongoDB Performance Tuning
MongoDB
 
10gen Presents Schema Design and Data Modeling
10gen Presents Schema Design and Data Modeling10gen Presents Schema Design and Data Modeling
10gen Presents Schema Design and Data Modeling
DATAVERSITY
 

Ähnlich wie Mongo db presentation (20)

Managing Social Content with MongoDB
Managing Social Content with MongoDBManaging Social Content with MongoDB
Managing Social Content with MongoDB
 
Building Apps with MongoDB
Building Apps with MongoDBBuilding Apps with MongoDB
Building Apps with MongoDB
 
Mongodb intro
Mongodb introMongodb intro
Mongodb intro
 
Latinoware
LatinowareLatinoware
Latinoware
 
MongoDB
MongoDBMongoDB
MongoDB
 
MongoDB Performance Tuning
MongoDB Performance TuningMongoDB Performance Tuning
MongoDB Performance Tuning
 
Starting with MongoDB
Starting with MongoDBStarting with MongoDB
Starting with MongoDB
 
Forbes MongoNYC 2011
Forbes MongoNYC 2011Forbes MongoNYC 2011
Forbes MongoNYC 2011
 
ActiveRecord vs Mongoid
ActiveRecord vs MongoidActiveRecord vs Mongoid
ActiveRecord vs Mongoid
 
10gen Presents Schema Design and Data Modeling
10gen Presents Schema Design and Data Modeling10gen Presents Schema Design and Data Modeling
10gen Presents Schema Design and Data Modeling
 
Building a Scalable Inbox System with MongoDB and Java
Building a Scalable Inbox System with MongoDB and JavaBuilding a Scalable Inbox System with MongoDB and Java
Building a Scalable Inbox System with MongoDB and Java
 
NoSQL & MongoDB
NoSQL & MongoDBNoSQL & MongoDB
NoSQL & MongoDB
 
Data exchange formats
Data exchange formatsData exchange formats
Data exchange formats
 
MongoDB for Coder Training (Coding Serbia 2013)
MongoDB for Coder Training (Coding Serbia 2013)MongoDB for Coder Training (Coding Serbia 2013)
MongoDB for Coder Training (Coding Serbia 2013)
 
MongoDB Aggregation
MongoDB Aggregation MongoDB Aggregation
MongoDB Aggregation
 
Montreal Elasticsearch Meetup
Montreal Elasticsearch MeetupMontreal Elasticsearch Meetup
Montreal Elasticsearch Meetup
 
Introduction to solr
Introduction to solrIntroduction to solr
Introduction to solr
 
Back to Basics Webinar 3 - Thinking in Documents
Back to Basics Webinar 3 - Thinking in DocumentsBack to Basics Webinar 3 - Thinking in Documents
Back to Basics Webinar 3 - Thinking in Documents
 
MongoDB, PHP and the cloud - php cloud summit 2011
MongoDB, PHP and the cloud - php cloud summit 2011MongoDB, PHP and the cloud - php cloud summit 2011
MongoDB, PHP and the cloud - php cloud summit 2011
 
Back to Basics Webinar 3: Schema Design Thinking in Documents
 Back to Basics Webinar 3: Schema Design Thinking in Documents Back to Basics Webinar 3: Schema Design Thinking in Documents
Back to Basics Webinar 3: Schema Design Thinking in Documents
 

Kürzlich hochgeladen

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Kürzlich hochgeladen (20)

Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 

Mongo db presentation

  • 2.
  • 3.
  • 4. DB1 primary DB3 primary businessinsider bi_analytics 64GB 16GB Web1 DB2 - Secondary arbiter businessinsider businessinsider port xxxxx arbiter bi_analytics bi_analytics port yyyyyy 32GB 16GB
  • 5. It’s very easy to add a new nodes to a replica set Start the process on the new server: mkdir /data/db mongod --port xxx --dbpath /data/db --replSet setname Add the node on the Primary DB rs.add(“[hostname]:port”);
  • 6.
  • 7. Most of the operations we perform on the analytics db are atomic in-place updates : analytics.heatmap.update( { homepage_id:"4ecfb4eefcda248b89000003", uri : "/ron-paul-slams-trump-joins-huntsman-in-sitting-out-circus-like-debate-2011-12" }, { $inc : {views : 1}, $set : {updated_at : {"sec":1329587057,"usec":175000}} }}, true // upsert )
  • 10.
  • 11.
  • 12. Example: adding a new field to an object In the console > var myObj = {name: 'julie', role: "developer"} //creates the foo collection and inserts an object > db.foo.save(myObj) > db.foo.find() { "_id" : ObjectId("4f418251f4dd8d3d88a776ea"), "name" : "julie", "role" : "developer" } // Add a new field var julie = db.foo.findOne() { "_id" : ObjectId("4f418251f4dd8d3d88a776ea"), "name" : "julie", "role" : "developer" } > julie.last_name = "sommerville' > db.foo.save(julie) > db.foo.find().pretty() { "_id" : ObjectId("4f418251f4dd8d3d88a776ea"), "name" : "julie", "role" : "developer", "last_name" : "sommerville" } (pretty just makes it pretty)
  • 13.
  • 14. Some Examples from our DB Post Object: contains comments, many posts will have way more than a couple of comments db.blog.posts.findOne({comments : {$exists:true}, comment_count : {$gte: 1}, ts : {$gte: start}}) { "_id" : ObjectId("4d4798c949e2aef0100d0000"), "attached_images" : [ ], "author" : "Ed Dolan", "author_id" : ObjectId("4d121ca0ccd1d5d337000000"), "autotweet" : false, "badges" : [ ], "browser_title" : null, "categories" : [ ], "cls" : "entry", "comment_count" : 1, "comment_thread_count" : 1, "comments" : [ { "cid" : ObjectId("4d482923cadcbb310a080000"), "ts" : ISODate("2011-02-01T15:39:15.541Z"), "ip" : "113.53.150.3", "author" : "kenhow", "email" : "info@howincorporated.com", "url" : "http://howincorporated.com", "user_id" : ObjectId("4d32fceaccd1d53d7b010000"), "text" : "In other words: nothing to worry about" } ],
  • 15. We also store the Replies to comments : { "author" : "LS", "cid" : ObjectId("4eda72376bb3f72279000009"), "email" : "lawrenceshapiro@gmail.com", "flags" : [ ], "ip" : "74.68.112.217", "rate_down" : 0, "rate_up" : 6, "raters" : { "$ref" : "blog.comments.raters", "$id" : ObjectId("4eda72376bb3f72279000008") }, "replies" : [ { "cid" : ObjectId("4eda800b69beddf55900004f"), "author" : "Skepticus Maximus", "email" : "henry1807@yahoo.com", "flags" : [ ], "ip" : "66.159.194.20", "rate_down" : 0, "rate_up" : 1, "raters" : { "$ref" : "blog.comments.raters", "$id" : ObjectId("4eda800b69beddf55900004e") }, "reply" : ObjectId("4eda72376bb3f72279000009"), "reply_author" : "LS", "text" : "No, it's perfectly natural - nature's way to make sure the species continues", "ts" : ISODate("2011-12-03T20:01:15.930Z"), "url" : "", "session_id" : ObjectId("4eda76e3eab8ea9f4d00003d") }, * Fast retrieval - no joins
  • 16.
  • 17.
  • 18.
  • 19. MMS (MongoDB Monitoring Service) * Really nice stats with the ability to “zoom” in (minute, 5min, hour etc.). * If the data base is acting up you can go in and see where the problem may lie -- Num Collections -- Data Size in the DB and in storage -- Avg. doc size -- Index Sizes -- Replica Set Stats -- page faults -- the lock queue (reads and writes)
  • 20. total number of contiguously allocated chunks of datafile space for the database
  • 21.
  • 22. num commands index access and hits
  • 23. secondary shouldn’t be more than this number hours behind
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31. Sharding - Probably on our main database - Help deal with load/num of connections

Hinweis der Redaktion

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n