SlideShare uma empresa Scribd logo
1 de 92
Baixar para ler offline
MongoDB:
Advantages of an Open Source NoSQL Database:
An Introduction
FITC {spotlight on the MEAN stack}
Who am I?
The cand.IO { Candy-oh! } Platform
We've made it our mission to become the premier provider of
infrastructure, platform and operations services for big data, web and
mobile applications.
We effectively manage your operations,
allowing you to create, deploy and iterate
DevOps * SysOps * NoOps
What is NoSQL?
“...when ‘NoSQL’ is applied to a database,
it refers to an ill-defined set of mostly
open-source databases, mostly developed
in the early 21st century, and mostly not
using SQL”
Martin Fowler: NoSQL Distilled
● NoSQL databases don’t use SQL
● Generally open source projects
● Driven by need to scale and run on clusters
● Operate without a schema
● Shift away from relational model
● NoSQL models: key-value, document, column-family, graph
what is
MongoDB?
Notusedwithpermission,pleasekeeptoyourself,appreciated,thanks!
History
● Development began in 2007
● Initially conceived as a persistent data store for a larger
platform as a service offering
● In 2009, MongoDB was open sourced with an AGPL license
● Version 1.4 was released in March 2010 and considered the
first production ready version
mongodb.org/downloads
DB-Engines Ranking
MongoDB is a ______________ database
● Document
● Open Source
● High performance
● Horizontally scalable
● Full featured
PopQuiz!
Document Database
● Not for .PDF and .DOC files
● A document is essentially an associate array
○ Document = JSON object
○ Document = PHP Array
○ Document = Python Dict
○ Document = Ruby Hash
○ etc.
Open Source
● MongoDB is an open source project
● On GitHub and Jira
● Licensed under the AGPL
● Started and sponsored by 10gen (now MongoDB Inc.)
● Commercial licenses available
● Contributions welcome
High Performance
● Written in C++
● Extensive use of memory-mapped files
i.e. read-through write-through memory caching
● Runs nearly everywhere
● Data serialized as BSON (fast parsing)
● Full support for primary and secondary indexes
Full Featured
● Ad Hoc queries
● Real time aggregation
● Rich query capabilities
● Geospatial features
● Support for most programming languages
● Flexible schema
Document Database
Terminology
RDBMS MongoDB
Table, View Collection
Row Document
Index Index
Join Embedded Document
Foreign Key Reference
Partition Shard
Typical (relational) ERD
Schema Design
MongoDB has native bindings for over 12 languages
MongoDB Drivers
● Drivers connect to mongo servers
● Drivers translate BSON to native types
● mongo shell is not a driver, but works like one in some ways
● Installed using typical means (npm, pecl, gem, pip)
Running MongoDB
$ tar –xzf mongodb-linux-x86_64-2.4.7.tgz
$ cd mongodb-linux-x86_64-2.4.7/bin
$ sudo mkdir –p /data/db
$ sudo ./mongod
Mongo Shell
$ mongo
MongoDB shell version: 2.4.4
connecting to: test
> db.test.insert({text: 'Welcome to MongoDB'})
> db.test.find().pretty()
{
"_id" : ObjectId("51c34130fbd5d7261b4cdb55"),
"text" : "Welcome to MongoDB"
}
Start with an object (or array, hash, dict, etc.)
var user = {
username: ’kcearns',
first_name: ’Kevin',
last_name: ’Cearns',
}
Switch to your DB
>db
test
> use blog
switching to db blog
Insert the record (no collection creation required)
> db.users.insert(user)
Find one record
> db.users.findOne()
{
"_id" : ObjectId("50804d0bd94ccab2da652599"),
"username" : ”kcearns",
"first_name" : ”Kevin",
"last_name" : ”Cearns"
}
_id
● _id is the primary key in MongoDB
● Automatically indexed
● Automatically created as an ObjectID if not provided
● Any unique immutable value can be used
ObjectId
● ObjectId is a special 12 byte value
● Guaranteed to be unique across your cluster
● ObjectId(“50804d0bd94ccab2da652599”)
Creating a Blog Post
> db.article.insert({
title: ‘Hello World’,
body: ‘This is my first blog post’,
date: new Date(‘2013-06-20’),
username: kcearns,
tags: [‘adventure’, ‘mongodb’],
comments: [ ]
})
Finding the Post
> db.article.find().pretty()
{
"_id" : ObjectId("51c3bafafbd5d7261b4cdb5a"),
"title" : "Hello World",
"body" : "This is my first blog post",
"date" : ISODate("2013-10-20T00:00:00Z"),
"username" : "kcearns",
"tags" : [
"adventure",
"mongodb"
],
"comments" : [ ]
}
Querying An Array
> db.article.find({tags:'adventure'}).pretty()
{
"_id" : ObjectId("51c3bcddfbd5d7261b4cdb5b"),
"title" : "Hello World",
"body" : "This is my first blog post",
"date" : ISODate("2013-10-20T00:00:00Z"),
"username" : "kcearns",
"tags" : [
"adventure",
"mongodb"
],
"comments" : [ ]
}
Prime Time
What are your production options?
Roll your own...
Operations Best practices
● Setup and configuration
● Hardware
● Operating system and file system configurations
● Networking
Setup and configuration
● Only 64 bit versions of operating systems should be used
● Configuration files should be used for consistent setups
● Upgrades should be done as often as possible
● Data migration - don’t simply import your legacy dump
Hardware
● MongoDB makes extensive use of RAM (the more RAM the better)
● Shared storage is not required
● Disk access patterns are not sequential
SSD where possible, better to spend money on more RAM or SSD vs.
faster spinning drives
● RAID 10
● Faster clock speeds vs. numerous cores
Operating system and file system configurations
● Ext4 and XFS file systems are recommended
● Turn off atime for the storage volume with the database files
● Disable NUMA (non-uniform memory access) in BIOS or start
mongod with NUMA disabled
● Ensure readahead for block devices where the database files
live are small (setting readahead to 32 (16KB) )
● Modify ulimit values
Networking
● Run mongod in a trusted environment, prevent access from all
unknown entities
● MongoDB binds to all available network interfaces, bind your
mongod to the private or internal interface if you have one
Replica sets
“...a group of mongod processes that maintain the same data set.
Replica sets provide redundancy and high availability, and are the basis
for all production deployments.”
● Secondaries apply operations from the primary asynchronously
● Replica sets supports dedicated members for reporting, disaster
recovery and backup
● Automatic failover occurs when a primary does not communicate
with other members of the set for more than 10 seconds
Sharding
● MongoDB approach to scaling out
● Data is split up and stored on different machines (usually a replica set)
● Supports Autosharding
● The cluster balances data across machines automatically
DEMO
Backup
● expect failure when you feel most prepared
● any backup is better than no backup
● backup the backup
Backup Considerations:
the business recovery expectation
ALWAYS
dictates the backup method
● geography
● system Errors
● production constraints
● system capabilities
● database configuration
● actual requirements
● business requirements
geography
● OFF SITE (away from your primary infrastructure)
● MULTIPLE COPIES OFF SITE
System Errors
● ensure the integrity and availability of backups
● MULTIPLE COPIES OFF SITE
Production constraints
● backup operations themselves require system resources
● consider backup schedules and availability of resources
System capabilities:
some backup methods like LVM require the system tools to support them
Consider the database configuration:
replication and sharding affects the backup method
Actual requirements
● what needs to be backed up
● how timely does it need to be
● what's your recovery window
Backup methods
● binary dumps of the database using mongodump/mongorestore
● filesystem snapshots like lvm
Filesystem backup
● utilized with system level tools like LVM (logical volume manager)
● creates a filesystem snapshot or "block level" backup
● same premise as "hard links" - creates pointers between the live data and
the snapshot volume
● requires configuration outside of MongoDB
Snapshot limitations
● all writes to the database need to be written fully to disk (journal or data files)
● the journal must reside on the same volume as the data
● snapshots create an image of the entire disk
● Isolate data files and journal on a single logical disk that contains no other
data
Snapshots
● if mongod has journaling enabled you can use any kind of file system or
volume/block level snapshot tool
# lvcreate --size 100M --snapshot --name snap01 /dev/vg0/mongodb
● creates an LVM snapshot named snap01 of the mongodb volume in the
vg0 volume group
Snapshots
● mount the snapshot and move the data to separate storage
# mount /dev/vg0/snap01
# dd if=/dev/vg0/snap01 | gzip > snap01.gz
(block level copy of the snapshot image and compressed into a gzipped file)
# lvcreate --size 1G --name mongodb-new vg0
# gzip -d -c snap01 | dd of=/dev/vg0/mongodb-new
Mongodump & Mongorestore
● write the entire contents of the instance to a file in binary format
● can backup the entire server, database or collection
● queries allow you to backup part of a collection
# mongodump
connects to the local database instance and creates a database backup named
dump/ in the current directory
# mongodump --dbpath /data/db --out /data/backup
Connects directly to local data files with no mongod process and saves output to /data/backup. Access
to the data directory is restricted during the dump.
# mongodump --host mongodb.example.net --port 27017
Connects to host mongodb.example.net on port 27017 and saves output to a dump subdirectory of the
current working directory
# mongodump --collection collection --db test
Creates a backup of the collection name collection from the database test in a dump subdirectory of
the current working directory
--oplog
mongodump copies data from the source database as well as all of the oplog
entries from the beginning of the backup procedure until the backup procedure
completes
--oplogReplay
Mongorestore
● restores a backup created by mongodump
● by default mongorestore looks for a database backup in the dump/
directory
● can connect to an active mongod process or write to a local database path
without mongod
● can restore an entire database or subset of the backup
# mongorestore --port 27017 /data/backup
Connects to local mongodb instance on port 27017 and restores the dump from /data/backup
# mongorestore --dbpath /data/db /data/backup
Restore writes to data files inside /data/db from the dump in /data/backup
# mongorestore --filter '{"field": 1}'
Restore only adds documents from the dump located in the dump subdirectory of the current working
directory if the documents have a field name field that holds a value of 1
When things go wrong
...and they will!
Tools for Diagnostics
● Know your DB (ie., working set)
● Logs
● MMS Monitoring
● mongostat
● OS tools (ie, vmstat)
Know your DB
● Determine working set
● Database profiler
● Scale for Read or Write
● db.serverStatus()
● rs.status()
● db.stats()
Working Set
● db.runCommand( { serverStatus: 1, workingset: 1 })
"workingSet" : {
"note" : "thisIsAnEstimate",
"pagesInMemory" : 17,
"computationTimeMicros" : 10085,
"overSeconds" : 999
},
Working Set
pagesInMemory: contains a count of the total number of pages
accessed by mongod over the period displayed inoverSeconds. The
default page size is 4 kilobytes: to convert this value to the amount of
data in memory multiply this value by 4 kilobyte
overSeconds: overSeconds returns the amount of time elapsed between
the newest and oldest pages tracked in the pagesInMemory data point.
If overSeconds is decreasing, or if pagesInMemory equals physical RAM
and overSeconds is very small, the working set may be much larger than
physical RAM.When overSeconds is large, MongoDB’s data set is equal
to or smaller than physical RAM
Performance of Database Operations
● Database profiler collects fine grained data about
write operations, cursors and database commands
● Enable profiling on a per database or per instance
basis
● Minor affect on performance
● system.profile collection is a capped collection with a
default size of 1 megabyte
● db.setProfilingLevel(0)
Performance of Database Operations
● 0 - the profiler is off
● 1 - collects profiling data for slow operations only. By
default slow operations are those slower than 100
milliseconds. You can modify the threshold for slow
operations with the slowms option
● 2 - collects profiling data for all database operations
● db.getProfilingStatus()
Verbose Logs
● Set verbosity in config file
● use admin
db.runCommand( { setParameter: 1, logLevel: 2 } )
v = Alternate form or verbose
vv = Additional increase in verbosity
vvv = Additional increase in verbosity
vvvv = Additional increase in verbosity
vvvvv = Additional increse in verbosity
MMS Monitoring
mongostat
● provides an overview of the status of a currently running
mongod or mongos instance
● similar to vmstat but specific to mongodb instances
inserts: the number of objects inserted in the db per second
query: the number of query operations per second
mapped: the total amount of data mapped in megabytes
faults: the number of page faults per second
locked: the percent of time in a global write lock
qr: length of queue of clients waiting to read data
qw: length of queue of clients waiting to write data
OS tools
Network latency: ping and traceroute (especially helpful
troubleshooting replica set issues and communication
between members)
Disk throughput: iostat or vmstat (disk related issues can
cause all kinds of problems)
meetup.com/Toronto-MongoDB-User-Group
Google Plus: Toronto MongoDB Users
References
● github.com/mongodb/mongo
● jira.mongodb.org
● education.mongodb.com
● docs.mongodb.org
education.mongodb.com
Notusedwithpermission,pleasekeeptoyourself,appreciated,thanks!
Thank You!
@kcearns
@candiocloud
entuit.com cand.io
FITC {spotlight on the MEAN stack}

Mais conteúdo relacionado

Mais procurados

Streaming replication in practice
Streaming replication in practiceStreaming replication in practice
Streaming replication in practiceAlexey Lesovsky
 
MongoDB and server performance
MongoDB and server performanceMongoDB and server performance
MongoDB and server performanceAlon Horev
 
Gluster fs architecture_future_directions_tlv
Gluster fs architecture_future_directions_tlvGluster fs architecture_future_directions_tlv
Gluster fs architecture_future_directions_tlvSahina Bose
 
Storage as a Service with Gluster
Storage as a Service with GlusterStorage as a Service with Gluster
Storage as a Service with GlusterVijay Bellur
 
Filesystem Comparison: NFS vs GFS2 vs OCFS2
Filesystem Comparison: NFS vs GFS2 vs OCFS2Filesystem Comparison: NFS vs GFS2 vs OCFS2
Filesystem Comparison: NFS vs GFS2 vs OCFS2Giuseppe Paterno'
 
Scale out backups-with_bareos_and_gluster
Scale out backups-with_bareos_and_glusterScale out backups-with_bareos_and_gluster
Scale out backups-with_bareos_and_glusterGluster.org
 
Advanced Administration, Monitoring and Backup
Advanced Administration, Monitoring and BackupAdvanced Administration, Monitoring and Backup
Advanced Administration, Monitoring and BackupMongoDB
 
OSBConf 2015 | Scale out backups with bareos and gluster by niels de vos
OSBConf 2015 | Scale out backups with bareos and gluster by niels de vosOSBConf 2015 | Scale out backups with bareos and gluster by niels de vos
OSBConf 2015 | Scale out backups with bareos and gluster by niels de vosNETWAYS
 
Red Hat Gluster Storage : GlusterFS
Red Hat Gluster Storage : GlusterFSRed Hat Gluster Storage : GlusterFS
Red Hat Gluster Storage : GlusterFSbipin kunal
 
MongoDB performance tuning and load testing, NOSQL Now! 2013 Conference prese...
MongoDB performance tuning and load testing, NOSQL Now! 2013 Conference prese...MongoDB performance tuning and load testing, NOSQL Now! 2013 Conference prese...
MongoDB performance tuning and load testing, NOSQL Now! 2013 Conference prese...ronwarshawsky
 
Comparison of foss distributed storage
Comparison of foss distributed storageComparison of foss distributed storage
Comparison of foss distributed storageMarian Marinov
 
20160130 Gluster-roadmap
20160130 Gluster-roadmap20160130 Gluster-roadmap
20160130 Gluster-roadmapGluster.org
 
Gluster fs current_features_and_roadmap
Gluster fs current_features_and_roadmapGluster fs current_features_and_roadmap
Gluster fs current_features_and_roadmapGluster.org
 
LizardFS-WhitePaper-Eng-v3.9.2-web
LizardFS-WhitePaper-Eng-v3.9.2-webLizardFS-WhitePaper-Eng-v3.9.2-web
LizardFS-WhitePaper-Eng-v3.9.2-webSzymon Haly
 
Out of the box replication in postgres 9.4
Out of the box replication in postgres 9.4Out of the box replication in postgres 9.4
Out of the box replication in postgres 9.4Denish Patel
 
MongoDB memory management demystified
MongoDB memory management demystifiedMongoDB memory management demystified
MongoDB memory management demystifiedAlon Horev
 
Challenges with Gluster and Persistent Memory with Dan Lambright
Challenges with Gluster and Persistent Memory with Dan LambrightChallenges with Gluster and Persistent Memory with Dan Lambright
Challenges with Gluster and Persistent Memory with Dan LambrightGluster.org
 

Mais procurados (20)

Streaming replication in practice
Streaming replication in practiceStreaming replication in practice
Streaming replication in practice
 
MongoDB and server performance
MongoDB and server performanceMongoDB and server performance
MongoDB and server performance
 
Gluster fs architecture_future_directions_tlv
Gluster fs architecture_future_directions_tlvGluster fs architecture_future_directions_tlv
Gluster fs architecture_future_directions_tlv
 
Storage as a Service with Gluster
Storage as a Service with GlusterStorage as a Service with Gluster
Storage as a Service with Gluster
 
Filesystem Comparison: NFS vs GFS2 vs OCFS2
Filesystem Comparison: NFS vs GFS2 vs OCFS2Filesystem Comparison: NFS vs GFS2 vs OCFS2
Filesystem Comparison: NFS vs GFS2 vs OCFS2
 
Scale out backups-with_bareos_and_gluster
Scale out backups-with_bareos_and_glusterScale out backups-with_bareos_and_gluster
Scale out backups-with_bareos_and_gluster
 
Advanced Administration, Monitoring and Backup
Advanced Administration, Monitoring and BackupAdvanced Administration, Monitoring and Backup
Advanced Administration, Monitoring and Backup
 
OSBConf 2015 | Scale out backups with bareos and gluster by niels de vos
OSBConf 2015 | Scale out backups with bareos and gluster by niels de vosOSBConf 2015 | Scale out backups with bareos and gluster by niels de vos
OSBConf 2015 | Scale out backups with bareos and gluster by niels de vos
 
Red Hat Gluster Storage : GlusterFS
Red Hat Gluster Storage : GlusterFSRed Hat Gluster Storage : GlusterFS
Red Hat Gluster Storage : GlusterFS
 
MongoDB performance tuning and load testing, NOSQL Now! 2013 Conference prese...
MongoDB performance tuning and load testing, NOSQL Now! 2013 Conference prese...MongoDB performance tuning and load testing, NOSQL Now! 2013 Conference prese...
MongoDB performance tuning and load testing, NOSQL Now! 2013 Conference prese...
 
92 grand prix_2013
92 grand prix_201392 grand prix_2013
92 grand prix_2013
 
Comparison of foss distributed storage
Comparison of foss distributed storageComparison of foss distributed storage
Comparison of foss distributed storage
 
7 Ways To Crash Postgres
7 Ways To Crash Postgres7 Ways To Crash Postgres
7 Ways To Crash Postgres
 
20160130 Gluster-roadmap
20160130 Gluster-roadmap20160130 Gluster-roadmap
20160130 Gluster-roadmap
 
Gluster fs current_features_and_roadmap
Gluster fs current_features_and_roadmapGluster fs current_features_and_roadmap
Gluster fs current_features_and_roadmap
 
Containers > VMs
Containers > VMsContainers > VMs
Containers > VMs
 
LizardFS-WhitePaper-Eng-v3.9.2-web
LizardFS-WhitePaper-Eng-v3.9.2-webLizardFS-WhitePaper-Eng-v3.9.2-web
LizardFS-WhitePaper-Eng-v3.9.2-web
 
Out of the box replication in postgres 9.4
Out of the box replication in postgres 9.4Out of the box replication in postgres 9.4
Out of the box replication in postgres 9.4
 
MongoDB memory management demystified
MongoDB memory management demystifiedMongoDB memory management demystified
MongoDB memory management demystified
 
Challenges with Gluster and Persistent Memory with Dan Lambright
Challenges with Gluster and Persistent Memory with Dan LambrightChallenges with Gluster and Persistent Memory with Dan Lambright
Challenges with Gluster and Persistent Memory with Dan Lambright
 

Semelhante a MongoDB: Advantages of an Open Source NoSQL Database

Intro to XPages for Administrators (DanNotes, November 28, 2012)
Intro to XPages for Administrators (DanNotes, November 28, 2012)Intro to XPages for Administrators (DanNotes, November 28, 2012)
Intro to XPages for Administrators (DanNotes, November 28, 2012)Per Henrik Lausten
 
Back to Basics Webinar 6: Production Deployment
Back to Basics Webinar 6: Production DeploymentBack to Basics Webinar 6: Production Deployment
Back to Basics Webinar 6: Production DeploymentMongoDB
 
Running MongoDB 3.0 on AWS
Running MongoDB 3.0 on AWSRunning MongoDB 3.0 on AWS
Running MongoDB 3.0 on AWSMongoDB
 
High performance json- postgre sql vs. mongodb
High performance json- postgre sql vs. mongodbHigh performance json- postgre sql vs. mongodb
High performance json- postgre sql vs. mongodbWei Shan Ang
 
kranonit S06E01 Игорь Цинько: High load
kranonit S06E01 Игорь Цинько: High loadkranonit S06E01 Игорь Цинько: High load
kranonit S06E01 Игорь Цинько: High loadKrivoy Rog IT Community
 
PGConf APAC 2018 - High performance json postgre-sql vs. mongodb
PGConf APAC 2018 - High performance json  postgre-sql vs. mongodbPGConf APAC 2018 - High performance json  postgre-sql vs. mongodb
PGConf APAC 2018 - High performance json postgre-sql vs. mongodbPGConf APAC
 
Backup, Restore, and Disaster Recovery
Backup, Restore, and Disaster RecoveryBackup, Restore, and Disaster Recovery
Backup, Restore, and Disaster RecoveryMongoDB
 
Deployment Strategy
Deployment StrategyDeployment Strategy
Deployment StrategyMongoDB
 
Mongo db transcript
Mongo db transcriptMongo db transcript
Mongo db transcriptfoliba
 
MongoDB vs Mysql. A devops point of view
MongoDB vs Mysql. A devops point of viewMongoDB vs Mysql. A devops point of view
MongoDB vs Mysql. A devops point of viewPierre Baillet
 
Deploying Perl apps on dotCloud
Deploying Perl apps on dotCloudDeploying Perl apps on dotCloud
Deploying Perl apps on dotClouddaoswald
 
Introduction to mongo db
Introduction to mongo dbIntroduction to mongo db
Introduction to mongo dbLawrence Mwai
 
Mongo db cluster administration and Shredded Databases
Mongo db cluster administration and Shredded DatabasesMongo db cluster administration and Shredded Databases
Mongo db cluster administration and Shredded DatabasesAbhinav Jha
 
MongoDB basics & Introduction
MongoDB basics & IntroductionMongoDB basics & Introduction
MongoDB basics & IntroductionJerwin Roy
 
Deployment Strategies
Deployment StrategiesDeployment Strategies
Deployment StrategiesMongoDB
 
Deployment Strategies (Mongo Austin)
Deployment Strategies (Mongo Austin)Deployment Strategies (Mongo Austin)
Deployment Strategies (Mongo Austin)MongoDB
 

Semelhante a MongoDB: Advantages of an Open Source NoSQL Database (20)

Intro to XPages for Administrators (DanNotes, November 28, 2012)
Intro to XPages for Administrators (DanNotes, November 28, 2012)Intro to XPages for Administrators (DanNotes, November 28, 2012)
Intro to XPages for Administrators (DanNotes, November 28, 2012)
 
Back to Basics Webinar 6: Production Deployment
Back to Basics Webinar 6: Production DeploymentBack to Basics Webinar 6: Production Deployment
Back to Basics Webinar 6: Production Deployment
 
Mongo DB
Mongo DBMongo DB
Mongo DB
 
Running MongoDB 3.0 on AWS
Running MongoDB 3.0 on AWSRunning MongoDB 3.0 on AWS
Running MongoDB 3.0 on AWS
 
High performance json- postgre sql vs. mongodb
High performance json- postgre sql vs. mongodbHigh performance json- postgre sql vs. mongodb
High performance json- postgre sql vs. mongodb
 
mongodb tutorial
mongodb tutorialmongodb tutorial
mongodb tutorial
 
kranonit S06E01 Игорь Цинько: High load
kranonit S06E01 Игорь Цинько: High loadkranonit S06E01 Игорь Цинько: High load
kranonit S06E01 Игорь Цинько: High load
 
PGConf APAC 2018 - High performance json postgre-sql vs. mongodb
PGConf APAC 2018 - High performance json  postgre-sql vs. mongodbPGConf APAC 2018 - High performance json  postgre-sql vs. mongodb
PGConf APAC 2018 - High performance json postgre-sql vs. mongodb
 
Backup, Restore, and Disaster Recovery
Backup, Restore, and Disaster RecoveryBackup, Restore, and Disaster Recovery
Backup, Restore, and Disaster Recovery
 
Deployment Strategy
Deployment StrategyDeployment Strategy
Deployment Strategy
 
Mongo db transcript
Mongo db transcriptMongo db transcript
Mongo db transcript
 
MongoDB vs Mysql. A devops point of view
MongoDB vs Mysql. A devops point of viewMongoDB vs Mysql. A devops point of view
MongoDB vs Mysql. A devops point of view
 
Deploying Perl apps on dotCloud
Deploying Perl apps on dotCloudDeploying Perl apps on dotCloud
Deploying Perl apps on dotCloud
 
Introduction to mongo db
Introduction to mongo dbIntroduction to mongo db
Introduction to mongo db
 
Mongo db cluster administration and Shredded Databases
Mongo db cluster administration and Shredded DatabasesMongo db cluster administration and Shredded Databases
Mongo db cluster administration and Shredded Databases
 
MongoDB basics & Introduction
MongoDB basics & IntroductionMongoDB basics & Introduction
MongoDB basics & Introduction
 
Tuning Linux for MongoDB
Tuning Linux for MongoDBTuning Linux for MongoDB
Tuning Linux for MongoDB
 
Deployment Strategies
Deployment StrategiesDeployment Strategies
Deployment Strategies
 
Deployment Strategies (Mongo Austin)
Deployment Strategies (Mongo Austin)Deployment Strategies (Mongo Austin)
Deployment Strategies (Mongo Austin)
 
MongoDB Online Training.pdf
MongoDB Online Training.pdfMongoDB Online Training.pdf
MongoDB Online Training.pdf
 

Mais de FITC

Cut it up
Cut it upCut it up
Cut it upFITC
 
Designing for Digital Health
Designing for Digital HealthDesigning for Digital Health
Designing for Digital HealthFITC
 
Profiling JavaScript Performance
Profiling JavaScript PerformanceProfiling JavaScript Performance
Profiling JavaScript PerformanceFITC
 
Surviving Your Tech Stack
Surviving Your Tech StackSurviving Your Tech Stack
Surviving Your Tech StackFITC
 
How to Pitch Your First AR Project
How to Pitch Your First AR ProjectHow to Pitch Your First AR Project
How to Pitch Your First AR ProjectFITC
 
Start by Understanding the Problem, Not by Delivering the Answer
Start by Understanding the Problem, Not by Delivering the AnswerStart by Understanding the Problem, Not by Delivering the Answer
Start by Understanding the Problem, Not by Delivering the AnswerFITC
 
Cocaine to Carrots: The Art of Telling Someone Else’s Story
Cocaine to Carrots: The Art of Telling Someone Else’s StoryCocaine to Carrots: The Art of Telling Someone Else’s Story
Cocaine to Carrots: The Art of Telling Someone Else’s StoryFITC
 
Everyday Innovation
Everyday InnovationEveryday Innovation
Everyday InnovationFITC
 
HyperLight Websites
HyperLight WebsitesHyperLight Websites
HyperLight WebsitesFITC
 
Everything is Terrifying
Everything is TerrifyingEverything is Terrifying
Everything is TerrifyingFITC
 
Post-Earth Visions: Designing for Space and the Future Human
Post-Earth Visions: Designing for Space and the Future HumanPost-Earth Visions: Designing for Space and the Future Human
Post-Earth Visions: Designing for Space and the Future HumanFITC
 
The Rise of the Creative Social Influencer (and How to Become One)
The Rise of the Creative Social Influencer (and How to Become One)The Rise of the Creative Social Influencer (and How to Become One)
The Rise of the Creative Social Influencer (and How to Become One)FITC
 
East of the Rockies: Developing an AR Game
East of the Rockies: Developing an AR GameEast of the Rockies: Developing an AR Game
East of the Rockies: Developing an AR GameFITC
 
Creating a Proactive Healthcare System
Creating a Proactive Healthcare SystemCreating a Proactive Healthcare System
Creating a Proactive Healthcare SystemFITC
 
World Transformation: The Secret Agenda of Product Design
World Transformation: The Secret Agenda of Product DesignWorld Transformation: The Secret Agenda of Product Design
World Transformation: The Secret Agenda of Product DesignFITC
 
The Power of Now
The Power of NowThe Power of Now
The Power of NowFITC
 
High Performance PWAs
High Performance PWAsHigh Performance PWAs
High Performance PWAsFITC
 
Rise of the JAMstack
Rise of the JAMstackRise of the JAMstack
Rise of the JAMstackFITC
 
From Closed to Open: A Journey of Self Discovery
From Closed to Open: A Journey of Self DiscoveryFrom Closed to Open: A Journey of Self Discovery
From Closed to Open: A Journey of Self DiscoveryFITC
 
Projects Ain’t Nobody Got Time For
Projects Ain’t Nobody Got Time ForProjects Ain’t Nobody Got Time For
Projects Ain’t Nobody Got Time ForFITC
 

Mais de FITC (20)

Cut it up
Cut it upCut it up
Cut it up
 
Designing for Digital Health
Designing for Digital HealthDesigning for Digital Health
Designing for Digital Health
 
Profiling JavaScript Performance
Profiling JavaScript PerformanceProfiling JavaScript Performance
Profiling JavaScript Performance
 
Surviving Your Tech Stack
Surviving Your Tech StackSurviving Your Tech Stack
Surviving Your Tech Stack
 
How to Pitch Your First AR Project
How to Pitch Your First AR ProjectHow to Pitch Your First AR Project
How to Pitch Your First AR Project
 
Start by Understanding the Problem, Not by Delivering the Answer
Start by Understanding the Problem, Not by Delivering the AnswerStart by Understanding the Problem, Not by Delivering the Answer
Start by Understanding the Problem, Not by Delivering the Answer
 
Cocaine to Carrots: The Art of Telling Someone Else’s Story
Cocaine to Carrots: The Art of Telling Someone Else’s StoryCocaine to Carrots: The Art of Telling Someone Else’s Story
Cocaine to Carrots: The Art of Telling Someone Else’s Story
 
Everyday Innovation
Everyday InnovationEveryday Innovation
Everyday Innovation
 
HyperLight Websites
HyperLight WebsitesHyperLight Websites
HyperLight Websites
 
Everything is Terrifying
Everything is TerrifyingEverything is Terrifying
Everything is Terrifying
 
Post-Earth Visions: Designing for Space and the Future Human
Post-Earth Visions: Designing for Space and the Future HumanPost-Earth Visions: Designing for Space and the Future Human
Post-Earth Visions: Designing for Space and the Future Human
 
The Rise of the Creative Social Influencer (and How to Become One)
The Rise of the Creative Social Influencer (and How to Become One)The Rise of the Creative Social Influencer (and How to Become One)
The Rise of the Creative Social Influencer (and How to Become One)
 
East of the Rockies: Developing an AR Game
East of the Rockies: Developing an AR GameEast of the Rockies: Developing an AR Game
East of the Rockies: Developing an AR Game
 
Creating a Proactive Healthcare System
Creating a Proactive Healthcare SystemCreating a Proactive Healthcare System
Creating a Proactive Healthcare System
 
World Transformation: The Secret Agenda of Product Design
World Transformation: The Secret Agenda of Product DesignWorld Transformation: The Secret Agenda of Product Design
World Transformation: The Secret Agenda of Product Design
 
The Power of Now
The Power of NowThe Power of Now
The Power of Now
 
High Performance PWAs
High Performance PWAsHigh Performance PWAs
High Performance PWAs
 
Rise of the JAMstack
Rise of the JAMstackRise of the JAMstack
Rise of the JAMstack
 
From Closed to Open: A Journey of Self Discovery
From Closed to Open: A Journey of Self DiscoveryFrom Closed to Open: A Journey of Self Discovery
From Closed to Open: A Journey of Self Discovery
 
Projects Ain’t Nobody Got Time For
Projects Ain’t Nobody Got Time ForProjects Ain’t Nobody Got Time For
Projects Ain’t Nobody Got Time For
 

Último

VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call GirlVIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girladitipandeya
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Sheetaleventcompany
 
On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024APNIC
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Servicesexy call girls service in goa
 
VIP Kolkata Call Girls Salt Lake 8250192130 Available With Room
VIP Kolkata Call Girls Salt Lake 8250192130 Available With RoomVIP Kolkata Call Girls Salt Lake 8250192130 Available With Room
VIP Kolkata Call Girls Salt Lake 8250192130 Available With Roomgirls4nights
 
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With RoomVIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Roomishabajaj13
 
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$kojalkojal131
 
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts servicesonalikaur4
 
Gram Darshan PPT cyber rural in villages of india
Gram Darshan PPT cyber rural  in villages of indiaGram Darshan PPT cyber rural  in villages of india
Gram Darshan PPT cyber rural in villages of indiaimessage0108
 
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With RoomVIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Roomdivyansh0kumar0
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsThierry TROUIN ☁
 
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...APNIC
 
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607dollysharma2066
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxellan12
 
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130  Available With RoomVIP Kolkata Call Girl Alambazar 👉 8250192130  Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Roomdivyansh0kumar0
 

Último (20)

VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call GirlVIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
 
On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
 
VIP Kolkata Call Girls Salt Lake 8250192130 Available With Room
VIP Kolkata Call Girls Salt Lake 8250192130 Available With RoomVIP Kolkata Call Girls Salt Lake 8250192130 Available With Room
VIP Kolkata Call Girls Salt Lake 8250192130 Available With Room
 
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
 
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With RoomVIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Room
 
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
 
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
 
Gram Darshan PPT cyber rural in villages of india
Gram Darshan PPT cyber rural  in villages of indiaGram Darshan PPT cyber rural  in villages of india
Gram Darshan PPT cyber rural in villages of india
 
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
 
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With RoomVIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Room
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with Flows
 
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
 
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
 
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
 
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130  Available With RoomVIP Kolkata Call Girl Alambazar 👉 8250192130  Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
 

MongoDB: Advantages of an Open Source NoSQL Database

  • 1. MongoDB: Advantages of an Open Source NoSQL Database: An Introduction FITC {spotlight on the MEAN stack}
  • 3. The cand.IO { Candy-oh! } Platform We've made it our mission to become the premier provider of infrastructure, platform and operations services for big data, web and mobile applications. We effectively manage your operations, allowing you to create, deploy and iterate DevOps * SysOps * NoOps
  • 4.
  • 6. “...when ‘NoSQL’ is applied to a database, it refers to an ill-defined set of mostly open-source databases, mostly developed in the early 21st century, and mostly not using SQL” Martin Fowler: NoSQL Distilled
  • 7. ● NoSQL databases don’t use SQL ● Generally open source projects ● Driven by need to scale and run on clusters ● Operate without a schema ● Shift away from relational model ● NoSQL models: key-value, document, column-family, graph
  • 10. History ● Development began in 2007 ● Initially conceived as a persistent data store for a larger platform as a service offering ● In 2009, MongoDB was open sourced with an AGPL license ● Version 1.4 was released in March 2010 and considered the first production ready version
  • 13. MongoDB is a ______________ database ● Document ● Open Source ● High performance ● Horizontally scalable ● Full featured PopQuiz!
  • 14. Document Database ● Not for .PDF and .DOC files ● A document is essentially an associate array ○ Document = JSON object ○ Document = PHP Array ○ Document = Python Dict ○ Document = Ruby Hash ○ etc.
  • 15. Open Source ● MongoDB is an open source project ● On GitHub and Jira ● Licensed under the AGPL ● Started and sponsored by 10gen (now MongoDB Inc.) ● Commercial licenses available ● Contributions welcome
  • 16. High Performance ● Written in C++ ● Extensive use of memory-mapped files i.e. read-through write-through memory caching ● Runs nearly everywhere ● Data serialized as BSON (fast parsing) ● Full support for primary and secondary indexes
  • 17.
  • 18. Full Featured ● Ad Hoc queries ● Real time aggregation ● Rich query capabilities ● Geospatial features ● Support for most programming languages ● Flexible schema
  • 20. Terminology RDBMS MongoDB Table, View Collection Row Document Index Index Join Embedded Document Foreign Key Reference Partition Shard
  • 23. MongoDB has native bindings for over 12 languages
  • 24. MongoDB Drivers ● Drivers connect to mongo servers ● Drivers translate BSON to native types ● mongo shell is not a driver, but works like one in some ways ● Installed using typical means (npm, pecl, gem, pip)
  • 25. Running MongoDB $ tar –xzf mongodb-linux-x86_64-2.4.7.tgz $ cd mongodb-linux-x86_64-2.4.7/bin $ sudo mkdir –p /data/db $ sudo ./mongod
  • 26. Mongo Shell $ mongo MongoDB shell version: 2.4.4 connecting to: test > db.test.insert({text: 'Welcome to MongoDB'}) > db.test.find().pretty() { "_id" : ObjectId("51c34130fbd5d7261b4cdb55"), "text" : "Welcome to MongoDB" }
  • 27. Start with an object (or array, hash, dict, etc.) var user = { username: ’kcearns', first_name: ’Kevin', last_name: ’Cearns', }
  • 28. Switch to your DB >db test > use blog switching to db blog
  • 29. Insert the record (no collection creation required) > db.users.insert(user)
  • 30. Find one record > db.users.findOne() { "_id" : ObjectId("50804d0bd94ccab2da652599"), "username" : ”kcearns", "first_name" : ”Kevin", "last_name" : ”Cearns" }
  • 31. _id ● _id is the primary key in MongoDB ● Automatically indexed ● Automatically created as an ObjectID if not provided ● Any unique immutable value can be used
  • 32. ObjectId ● ObjectId is a special 12 byte value ● Guaranteed to be unique across your cluster ● ObjectId(“50804d0bd94ccab2da652599”)
  • 33. Creating a Blog Post > db.article.insert({ title: ‘Hello World’, body: ‘This is my first blog post’, date: new Date(‘2013-06-20’), username: kcearns, tags: [‘adventure’, ‘mongodb’], comments: [ ] })
  • 34. Finding the Post > db.article.find().pretty() { "_id" : ObjectId("51c3bafafbd5d7261b4cdb5a"), "title" : "Hello World", "body" : "This is my first blog post", "date" : ISODate("2013-10-20T00:00:00Z"), "username" : "kcearns", "tags" : [ "adventure", "mongodb" ], "comments" : [ ] }
  • 35. Querying An Array > db.article.find({tags:'adventure'}).pretty() { "_id" : ObjectId("51c3bcddfbd5d7261b4cdb5b"), "title" : "Hello World", "body" : "This is my first blog post", "date" : ISODate("2013-10-20T00:00:00Z"), "username" : "kcearns", "tags" : [ "adventure", "mongodb" ], "comments" : [ ] }
  • 36. Prime Time What are your production options?
  • 37.
  • 38.
  • 39.
  • 41. Operations Best practices ● Setup and configuration ● Hardware ● Operating system and file system configurations ● Networking
  • 42. Setup and configuration ● Only 64 bit versions of operating systems should be used ● Configuration files should be used for consistent setups ● Upgrades should be done as often as possible ● Data migration - don’t simply import your legacy dump
  • 43. Hardware ● MongoDB makes extensive use of RAM (the more RAM the better) ● Shared storage is not required ● Disk access patterns are not sequential SSD where possible, better to spend money on more RAM or SSD vs. faster spinning drives ● RAID 10 ● Faster clock speeds vs. numerous cores
  • 44. Operating system and file system configurations ● Ext4 and XFS file systems are recommended ● Turn off atime for the storage volume with the database files ● Disable NUMA (non-uniform memory access) in BIOS or start mongod with NUMA disabled ● Ensure readahead for block devices where the database files live are small (setting readahead to 32 (16KB) ) ● Modify ulimit values
  • 45. Networking ● Run mongod in a trusted environment, prevent access from all unknown entities ● MongoDB binds to all available network interfaces, bind your mongod to the private or internal interface if you have one
  • 46. Replica sets “...a group of mongod processes that maintain the same data set. Replica sets provide redundancy and high availability, and are the basis for all production deployments.”
  • 47.
  • 48.
  • 49.
  • 50. ● Secondaries apply operations from the primary asynchronously ● Replica sets supports dedicated members for reporting, disaster recovery and backup ● Automatic failover occurs when a primary does not communicate with other members of the set for more than 10 seconds
  • 51.
  • 52. Sharding ● MongoDB approach to scaling out ● Data is split up and stored on different machines (usually a replica set) ● Supports Autosharding ● The cluster balances data across machines automatically
  • 53.
  • 54. DEMO
  • 55. Backup ● expect failure when you feel most prepared ● any backup is better than no backup ● backup the backup
  • 56. Backup Considerations: the business recovery expectation ALWAYS dictates the backup method
  • 57. ● geography ● system Errors ● production constraints ● system capabilities ● database configuration ● actual requirements ● business requirements
  • 58. geography ● OFF SITE (away from your primary infrastructure) ● MULTIPLE COPIES OFF SITE
  • 59. System Errors ● ensure the integrity and availability of backups ● MULTIPLE COPIES OFF SITE
  • 60. Production constraints ● backup operations themselves require system resources ● consider backup schedules and availability of resources
  • 61. System capabilities: some backup methods like LVM require the system tools to support them
  • 62. Consider the database configuration: replication and sharding affects the backup method
  • 63. Actual requirements ● what needs to be backed up ● how timely does it need to be ● what's your recovery window
  • 64. Backup methods ● binary dumps of the database using mongodump/mongorestore ● filesystem snapshots like lvm
  • 65. Filesystem backup ● utilized with system level tools like LVM (logical volume manager) ● creates a filesystem snapshot or "block level" backup ● same premise as "hard links" - creates pointers between the live data and the snapshot volume ● requires configuration outside of MongoDB
  • 66. Snapshot limitations ● all writes to the database need to be written fully to disk (journal or data files) ● the journal must reside on the same volume as the data ● snapshots create an image of the entire disk ● Isolate data files and journal on a single logical disk that contains no other data
  • 67. Snapshots ● if mongod has journaling enabled you can use any kind of file system or volume/block level snapshot tool # lvcreate --size 100M --snapshot --name snap01 /dev/vg0/mongodb ● creates an LVM snapshot named snap01 of the mongodb volume in the vg0 volume group
  • 68. Snapshots ● mount the snapshot and move the data to separate storage # mount /dev/vg0/snap01 # dd if=/dev/vg0/snap01 | gzip > snap01.gz (block level copy of the snapshot image and compressed into a gzipped file) # lvcreate --size 1G --name mongodb-new vg0 # gzip -d -c snap01 | dd of=/dev/vg0/mongodb-new
  • 69. Mongodump & Mongorestore ● write the entire contents of the instance to a file in binary format ● can backup the entire server, database or collection ● queries allow you to backup part of a collection
  • 70. # mongodump connects to the local database instance and creates a database backup named dump/ in the current directory
  • 71. # mongodump --dbpath /data/db --out /data/backup Connects directly to local data files with no mongod process and saves output to /data/backup. Access to the data directory is restricted during the dump. # mongodump --host mongodb.example.net --port 27017 Connects to host mongodb.example.net on port 27017 and saves output to a dump subdirectory of the current working directory # mongodump --collection collection --db test Creates a backup of the collection name collection from the database test in a dump subdirectory of the current working directory
  • 72. --oplog mongodump copies data from the source database as well as all of the oplog entries from the beginning of the backup procedure until the backup procedure completes --oplogReplay
  • 73. Mongorestore ● restores a backup created by mongodump ● by default mongorestore looks for a database backup in the dump/ directory ● can connect to an active mongod process or write to a local database path without mongod ● can restore an entire database or subset of the backup
  • 74. # mongorestore --port 27017 /data/backup Connects to local mongodb instance on port 27017 and restores the dump from /data/backup # mongorestore --dbpath /data/db /data/backup Restore writes to data files inside /data/db from the dump in /data/backup # mongorestore --filter '{"field": 1}' Restore only adds documents from the dump located in the dump subdirectory of the current working directory if the documents have a field name field that holds a value of 1
  • 75.
  • 76. When things go wrong ...and they will!
  • 77. Tools for Diagnostics ● Know your DB (ie., working set) ● Logs ● MMS Monitoring ● mongostat ● OS tools (ie, vmstat)
  • 78. Know your DB ● Determine working set ● Database profiler ● Scale for Read or Write ● db.serverStatus() ● rs.status() ● db.stats()
  • 79. Working Set ● db.runCommand( { serverStatus: 1, workingset: 1 }) "workingSet" : { "note" : "thisIsAnEstimate", "pagesInMemory" : 17, "computationTimeMicros" : 10085, "overSeconds" : 999 },
  • 80. Working Set pagesInMemory: contains a count of the total number of pages accessed by mongod over the period displayed inoverSeconds. The default page size is 4 kilobytes: to convert this value to the amount of data in memory multiply this value by 4 kilobyte overSeconds: overSeconds returns the amount of time elapsed between the newest and oldest pages tracked in the pagesInMemory data point. If overSeconds is decreasing, or if pagesInMemory equals physical RAM and overSeconds is very small, the working set may be much larger than physical RAM.When overSeconds is large, MongoDB’s data set is equal to or smaller than physical RAM
  • 81. Performance of Database Operations ● Database profiler collects fine grained data about write operations, cursors and database commands ● Enable profiling on a per database or per instance basis ● Minor affect on performance ● system.profile collection is a capped collection with a default size of 1 megabyte ● db.setProfilingLevel(0)
  • 82. Performance of Database Operations ● 0 - the profiler is off ● 1 - collects profiling data for slow operations only. By default slow operations are those slower than 100 milliseconds. You can modify the threshold for slow operations with the slowms option ● 2 - collects profiling data for all database operations ● db.getProfilingStatus()
  • 83. Verbose Logs ● Set verbosity in config file ● use admin db.runCommand( { setParameter: 1, logLevel: 2 } ) v = Alternate form or verbose vv = Additional increase in verbosity vvv = Additional increase in verbosity vvvv = Additional increase in verbosity vvvvv = Additional increse in verbosity
  • 85. mongostat ● provides an overview of the status of a currently running mongod or mongos instance ● similar to vmstat but specific to mongodb instances inserts: the number of objects inserted in the db per second query: the number of query operations per second mapped: the total amount of data mapped in megabytes faults: the number of page faults per second locked: the percent of time in a global write lock qr: length of queue of clients waiting to read data qw: length of queue of clients waiting to write data
  • 86. OS tools Network latency: ping and traceroute (especially helpful troubleshooting replica set issues and communication between members) Disk throughput: iostat or vmstat (disk related issues can cause all kinds of problems)
  • 88. Google Plus: Toronto MongoDB Users
  • 89. References ● github.com/mongodb/mongo ● jira.mongodb.org ● education.mongodb.com ● docs.mongodb.org