SlideShare una empresa de Scribd logo
1 de 29
Mongo Admin’ing
             Jesse Wolgamott
twitter: @jwo slides: http://github.com/jwo
Quick Install

• Dev: brew install mongodb
• Server: apt-get install mongodb
  • http://www.mongodb.org/display/
    DOCS/Ubuntu+and+Debian+packages
Don’t Fear the
Command Line
   Mongoid / Mongo Mapper


         Ruby Driver


Command Line Javascript (mongo)
Quick Server Status

db
db.system.namespaces.find()
db.serverStatus()
db.currentOp()
Command Line Basics
use dba
db.collection.find({json params})
db.collection.findOne({json params})
db.collection.mapReduce(map,reduce)
db.collection.save({json})
Why Bother?
• Mongo queries enhance Mongoid queries
• Drop to command line when needed
• Game.where(:outcome=>{‘$in’=>[‘winning’
  ,‘tie’]})
• Game.collection.update({:outcome=>‘win
  ning’, ‘$set’=>{:winning=>true}})
All Admin is
     Command Line

• Setup Replica Sets
• Check on Status
Replica / Slave /
       Journaling

“If you aren’t running a replica set, you don’t
            care about your data”
                            -- Mongo DB dude
Master / Slave
  What You’d Expect


           M


  Slave   Slave   Slave
Master / Slave
  What You’d Expect


           M              Writes Go Here



  Slave   Slave   Slave
Master / Slave
  What You’d Expect


            M              Writes Go Here



  Slave    Slave   Slave


          Reads CAN Go
              Here
Replica Sets
    The new Hotness (and Recommended)


Primary   Secondary   Secondary   Secondary



                                   Arbiter
Replica Sets
       The new Hotness (and Recommended)


   Primary   Secondary   Secondary   Secondary



Writes Go Here                        Arbiter
Replica Sets
       The new Hotness (and Recommended)


   Primary   Secondary   Secondary   Secondary



Writes Go Here      CAN Read          Arbiter
Replica Sets
       The new Hotness (and Recommended)


   Primary   Secondary   Secondary   Secondary



Writes Go Here      CAN Read          Arbiter


                               Nothing Goes
                                  Here
Arbiter?

• Arbiters exist when even number of hosts
• They cast votes on primary elections
• Can exist on your app server
Journaling

• Added in 1.8
• mongod -- journal
• Will write out changes to a journal
  directory
• You can restore from journal
Replica Set Fun
config = {
   _id: 'houstonrb',
   members: [
     {_id: 0, host: 'localhost:20000'},
     {_id: 1, host: 'localhost:20001'},
     {_id: 2, host: 'localhost:20002', arbiterOnly: true}]
}

// Start it up
rs.initiate(config);

// Check it Out
rs.status()

// Who’s your daddy?
rs.isMaster()
Non-Master Reads
error: { "$err" : "not master", "code" : 10107 }

               OK, so we’ll do:

         db.getMongo().setSlaveOk()

                 // Awesome
Backup / Restore
mongodump --db houstonrb

mongorestore --db houstonrb -c
collections --drop --indexesLast
DirectoryName

* Have all your .bson files in a
directory named your database
Repairing

• The Data Gobbler -- mongodb likes hard-
  drive space and won’t give it back

• Use mongod    --repair to reclaim your
  space!
Nightly Plan
service mongodb stop && mongod --repair --dbpath /var/
lib/mongodb && service mongodb start

rm -f /data/mongodump-backup.tar.bz2 && mongodump -
o /data/backups && tar -jcf /data/mongodump-
backup.tar.bz2 /data/backups && rm -rf /data/backups/
Catch Up!
• When a Replica Set gets ‘stale’
• rs.status will remain “5” (Recovering)
• On Master, will say “Error RS102 too stale
  to catch up”
• stop mongo on all servers, copy over all
  data files, including local.*, start all
Table Scans == Devil
• When you get to 500,000 records, your
  DB may slow to crawl.
• /var/log/mongodb/mongodb.log for logged
  queries (table scans)

• db.collection.getIndexKeys()
• Mongoid: rake
  db:mongoid:create_indexes
No, Really

• I’ve been surprised LOTS at how often a
  table scan happens.
• Test it out: mongod --notablescan
• Stuff will break.
Sharding

• Don’t Shard Early
• Helps in map-reduce
• You define a “shard-key”, like lastname
  from A-H on this shard
Scaling (Secret Sauce)

• Many Shard Masters, even more slaves
• Add Shards for write and data size scaling
• Add Slaves for read scaling (map-reduce)
  and redundancy
• Sharding is Hard
Neat Snippets

            Replication Setup
             Sharding Setup

https://github.com/mongodb/mongo-snippets
EC2 Notes

• Reformat drive to EXT4 or XFS
• Don’t use EBS for long term backups
• Can use EBS for setting up replica sets

Más contenido relacionado

La actualidad más candente

#OktoCampus - Workshop : An introduction to Ansible
#OktoCampus - Workshop : An introduction to Ansible#OktoCampus - Workshop : An introduction to Ansible
#OktoCampus - Workshop : An introduction to AnsibleCédric Delgehier
 
Ansible, Simplicity, and the Zen of Python
Ansible, Simplicity, and the Zen of PythonAnsible, Simplicity, and the Zen of Python
Ansible, Simplicity, and the Zen of Pythontoddmowen
 
puppet @techlifecookpad
puppet @techlifecookpadpuppet @techlifecookpad
puppet @techlifecookpadNaoya Nakazawa
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentationKumar Y
 
Microarmy - by J2 Labs
Microarmy - by J2 LabsMicroarmy - by J2 Labs
Microarmy - by J2 LabsJames Dennis
 
Ansible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife OrchestrationAnsible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife Orchestrationbcoca
 
Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to AnsibleCoreStack
 
Jenkins and ansible reference
Jenkins and ansible referenceJenkins and ansible reference
Jenkins and ansible referencelaonap166
 
Ansible for beginners ...?
Ansible for beginners ...?Ansible for beginners ...?
Ansible for beginners ...?shirou wakayama
 
Automating everything with PowerShell, Terraform, and AWS
Automating everything with PowerShell, Terraform, and AWSAutomating everything with PowerShell, Terraform, and AWS
Automating everything with PowerShell, Terraform, and AWSChris Brown
 
Basics of Ansible - Sahil Davawala
Basics of Ansible - Sahil DavawalaBasics of Ansible - Sahil Davawala
Basics of Ansible - Sahil DavawalaSahil Davawala
 
Building Windows Images with Packer
Building Windows Images with PackerBuilding Windows Images with Packer
Building Windows Images with PackerMatt Wrock
 
Monitoring and tuning your chef server - chef conf talk
Monitoring and tuning your chef server - chef conf talk Monitoring and tuning your chef server - chef conf talk
Monitoring and tuning your chef server - chef conf talk Andrew DuFour
 
Redis persistence in practice
Redis persistence in practiceRedis persistence in practice
Redis persistence in practiceEugene Fidelin
 
Apache HBase - Lab Assignment
Apache HBase - Lab AssignmentApache HBase - Lab Assignment
Apache HBase - Lab AssignmentFarzad Nozarian
 
Automation with ansible
Automation with ansibleAutomation with ansible
Automation with ansibleKhizer Naeem
 

La actualidad más candente (20)

#OktoCampus - Workshop : An introduction to Ansible
#OktoCampus - Workshop : An introduction to Ansible#OktoCampus - Workshop : An introduction to Ansible
#OktoCampus - Workshop : An introduction to Ansible
 
Ansible, Simplicity, and the Zen of Python
Ansible, Simplicity, and the Zen of PythonAnsible, Simplicity, and the Zen of Python
Ansible, Simplicity, and the Zen of Python
 
Linux basic3
Linux basic3Linux basic3
Linux basic3
 
puppet @techlifecookpad
puppet @techlifecookpadpuppet @techlifecookpad
puppet @techlifecookpad
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
Microarmy - by J2 Labs
Microarmy - by J2 LabsMicroarmy - by J2 Labs
Microarmy - by J2 Labs
 
Ansible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife OrchestrationAnsible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife Orchestration
 
Introducing Ansible
Introducing AnsibleIntroducing Ansible
Introducing Ansible
 
Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to Ansible
 
Jenkins and ansible reference
Jenkins and ansible referenceJenkins and ansible reference
Jenkins and ansible reference
 
Ansible for beginners ...?
Ansible for beginners ...?Ansible for beginners ...?
Ansible for beginners ...?
 
Automating everything with PowerShell, Terraform, and AWS
Automating everything with PowerShell, Terraform, and AWSAutomating everything with PowerShell, Terraform, and AWS
Automating everything with PowerShell, Terraform, and AWS
 
Basics of Ansible - Sahil Davawala
Basics of Ansible - Sahil DavawalaBasics of Ansible - Sahil Davawala
Basics of Ansible - Sahil Davawala
 
Building Windows Images with Packer
Building Windows Images with PackerBuilding Windows Images with Packer
Building Windows Images with Packer
 
Ansible intro
Ansible introAnsible intro
Ansible intro
 
Monitoring and tuning your chef server - chef conf talk
Monitoring and tuning your chef server - chef conf talk Monitoring and tuning your chef server - chef conf talk
Monitoring and tuning your chef server - chef conf talk
 
Redis persistence in practice
Redis persistence in practiceRedis persistence in practice
Redis persistence in practice
 
Apache HBase - Lab Assignment
Apache HBase - Lab AssignmentApache HBase - Lab Assignment
Apache HBase - Lab Assignment
 
Ansible Crash Course
Ansible Crash CourseAnsible Crash Course
Ansible Crash Course
 
Automation with ansible
Automation with ansibleAutomation with ansible
Automation with ansible
 

Similar a Mongo admin'ing

Replication, Durability, and Disaster Recovery
Replication, Durability, and Disaster RecoveryReplication, Durability, and Disaster Recovery
Replication, Durability, and Disaster RecoverySteven Francia
 
MongoDB Best Practices in AWS
MongoDB Best Practices in AWS MongoDB Best Practices in AWS
MongoDB Best Practices in AWS Chris Harris
 
Functional Hostnames and Why they are Bad
Functional Hostnames and Why they are BadFunctional Hostnames and Why they are Bad
Functional Hostnames and Why they are BadPuppet
 
Replica Sets (NYC NoSQL Meetup)
Replica Sets (NYC NoSQL Meetup)Replica Sets (NYC NoSQL Meetup)
Replica Sets (NYC NoSQL Meetup)MongoDB
 
MongoDB Replica Sets
MongoDB Replica SetsMongoDB Replica Sets
MongoDB Replica SetsMongoDB
 
Thoughts on Transaction and Consistency Models
Thoughts on Transaction and Consistency ModelsThoughts on Transaction and Consistency Models
Thoughts on Transaction and Consistency Modelsiammutex
 
Scaling with MongoDB
Scaling with MongoDBScaling with MongoDB
Scaling with MongoDBMongoDB
 
MongoDB and AWS Best Practices
MongoDB and AWS Best PracticesMongoDB and AWS Best Practices
MongoDB and AWS Best PracticesMongoDB
 
NoSQL Infrastructure - Late 2013
NoSQL Infrastructure - Late 2013NoSQL Infrastructure - Late 2013
NoSQL Infrastructure - Late 2013Server Density
 
Python mongo db-training-europython-2011
Python mongo db-training-europython-2011Python mongo db-training-europython-2011
Python mongo db-training-europython-2011Andreas Jung
 
MongoDB: Optimising for Performance, Scale & Analytics
MongoDB: Optimising for Performance, Scale & AnalyticsMongoDB: Optimising for Performance, Scale & Analytics
MongoDB: Optimising for Performance, Scale & AnalyticsServer Density
 
OSDC 2012 | Scaling with MongoDB by Ross Lawley
OSDC 2012 | Scaling with MongoDB by Ross LawleyOSDC 2012 | Scaling with MongoDB by Ross Lawley
OSDC 2012 | Scaling with MongoDB by Ross LawleyNETWAYS
 
Postgres Vienna DB Meetup 2014
Postgres Vienna DB Meetup 2014Postgres Vienna DB Meetup 2014
Postgres Vienna DB Meetup 2014Michael Renner
 
MapReduce with Hadoop and Ruby
MapReduce with Hadoop and RubyMapReduce with Hadoop and Ruby
MapReduce with Hadoop and RubySwanand Pagnis
 
Modeling Tricks My Relational Database Never Taught Me
Modeling Tricks My Relational Database Never Taught MeModeling Tricks My Relational Database Never Taught Me
Modeling Tricks My Relational Database Never Taught MeDavid Boike
 
Free The Enterprise With Ruby & Master Your Own Domain
Free The Enterprise With Ruby & Master Your Own DomainFree The Enterprise With Ruby & Master Your Own Domain
Free The Enterprise With Ruby & Master Your Own DomainKen Collins
 
Configuring MongoDB HA Replica Set on AWS EC2
Configuring MongoDB HA Replica Set on AWS EC2Configuring MongoDB HA Replica Set on AWS EC2
Configuring MongoDB HA Replica Set on AWS EC2ShepHertz
 

Similar a Mongo admin'ing (20)

Replication, Durability, and Disaster Recovery
Replication, Durability, and Disaster RecoveryReplication, Durability, and Disaster Recovery
Replication, Durability, and Disaster Recovery
 
MongoDB Best Practices in AWS
MongoDB Best Practices in AWS MongoDB Best Practices in AWS
MongoDB Best Practices in AWS
 
Mongodb replication
Mongodb replicationMongodb replication
Mongodb replication
 
Functional Hostnames and Why they are Bad
Functional Hostnames and Why they are BadFunctional Hostnames and Why they are Bad
Functional Hostnames and Why they are Bad
 
Replica Sets (NYC NoSQL Meetup)
Replica Sets (NYC NoSQL Meetup)Replica Sets (NYC NoSQL Meetup)
Replica Sets (NYC NoSQL Meetup)
 
MongoDB Replica Sets
MongoDB Replica SetsMongoDB Replica Sets
MongoDB Replica Sets
 
Thoughts on Transaction and Consistency Models
Thoughts on Transaction and Consistency ModelsThoughts on Transaction and Consistency Models
Thoughts on Transaction and Consistency Models
 
Scaling with MongoDB
Scaling with MongoDBScaling with MongoDB
Scaling with MongoDB
 
Mongodb workshop
Mongodb workshopMongodb workshop
Mongodb workshop
 
MongoDB and AWS Best Practices
MongoDB and AWS Best PracticesMongoDB and AWS Best Practices
MongoDB and AWS Best Practices
 
NoSQL Infrastructure - Late 2013
NoSQL Infrastructure - Late 2013NoSQL Infrastructure - Late 2013
NoSQL Infrastructure - Late 2013
 
Python mongo db-training-europython-2011
Python mongo db-training-europython-2011Python mongo db-training-europython-2011
Python mongo db-training-europython-2011
 
MongoDB: Optimising for Performance, Scale & Analytics
MongoDB: Optimising for Performance, Scale & AnalyticsMongoDB: Optimising for Performance, Scale & Analytics
MongoDB: Optimising for Performance, Scale & Analytics
 
Mongo db japan
Mongo db japanMongo db japan
Mongo db japan
 
OSDC 2012 | Scaling with MongoDB by Ross Lawley
OSDC 2012 | Scaling with MongoDB by Ross LawleyOSDC 2012 | Scaling with MongoDB by Ross Lawley
OSDC 2012 | Scaling with MongoDB by Ross Lawley
 
Postgres Vienna DB Meetup 2014
Postgres Vienna DB Meetup 2014Postgres Vienna DB Meetup 2014
Postgres Vienna DB Meetup 2014
 
MapReduce with Hadoop and Ruby
MapReduce with Hadoop and RubyMapReduce with Hadoop and Ruby
MapReduce with Hadoop and Ruby
 
Modeling Tricks My Relational Database Never Taught Me
Modeling Tricks My Relational Database Never Taught MeModeling Tricks My Relational Database Never Taught Me
Modeling Tricks My Relational Database Never Taught Me
 
Free The Enterprise With Ruby & Master Your Own Domain
Free The Enterprise With Ruby & Master Your Own DomainFree The Enterprise With Ruby & Master Your Own Domain
Free The Enterprise With Ruby & Master Your Own Domain
 
Configuring MongoDB HA Replica Set on AWS EC2
Configuring MongoDB HA Replica Set on AWS EC2Configuring MongoDB HA Replica Set on AWS EC2
Configuring MongoDB HA Replica Set on AWS EC2
 

Último

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 

Último (20)

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 

Mongo admin'ing

  • 1. Mongo Admin’ing Jesse Wolgamott twitter: @jwo slides: http://github.com/jwo
  • 2. Quick Install • Dev: brew install mongodb • Server: apt-get install mongodb • http://www.mongodb.org/display/ DOCS/Ubuntu+and+Debian+packages
  • 3. Don’t Fear the Command Line Mongoid / Mongo Mapper Ruby Driver Command Line Javascript (mongo)
  • 5. Command Line Basics use dba db.collection.find({json params}) db.collection.findOne({json params}) db.collection.mapReduce(map,reduce) db.collection.save({json})
  • 6. Why Bother? • Mongo queries enhance Mongoid queries • Drop to command line when needed • Game.where(:outcome=>{‘$in’=>[‘winning’ ,‘tie’]}) • Game.collection.update({:outcome=>‘win ning’, ‘$set’=>{:winning=>true}})
  • 7. All Admin is Command Line • Setup Replica Sets • Check on Status
  • 8. Replica / Slave / Journaling “If you aren’t running a replica set, you don’t care about your data” -- Mongo DB dude
  • 9. Master / Slave What You’d Expect M Slave Slave Slave
  • 10. Master / Slave What You’d Expect M Writes Go Here Slave Slave Slave
  • 11. Master / Slave What You’d Expect M Writes Go Here Slave Slave Slave Reads CAN Go Here
  • 12. Replica Sets The new Hotness (and Recommended) Primary Secondary Secondary Secondary Arbiter
  • 13. Replica Sets The new Hotness (and Recommended) Primary Secondary Secondary Secondary Writes Go Here Arbiter
  • 14. Replica Sets The new Hotness (and Recommended) Primary Secondary Secondary Secondary Writes Go Here CAN Read Arbiter
  • 15. Replica Sets The new Hotness (and Recommended) Primary Secondary Secondary Secondary Writes Go Here CAN Read Arbiter Nothing Goes Here
  • 16. Arbiter? • Arbiters exist when even number of hosts • They cast votes on primary elections • Can exist on your app server
  • 17. Journaling • Added in 1.8 • mongod -- journal • Will write out changes to a journal directory • You can restore from journal
  • 18. Replica Set Fun config = { _id: 'houstonrb', members: [ {_id: 0, host: 'localhost:20000'}, {_id: 1, host: 'localhost:20001'}, {_id: 2, host: 'localhost:20002', arbiterOnly: true}] } // Start it up rs.initiate(config); // Check it Out rs.status() // Who’s your daddy? rs.isMaster()
  • 19. Non-Master Reads error: { "$err" : "not master", "code" : 10107 } OK, so we’ll do: db.getMongo().setSlaveOk() // Awesome
  • 20. Backup / Restore mongodump --db houstonrb mongorestore --db houstonrb -c collections --drop --indexesLast DirectoryName * Have all your .bson files in a directory named your database
  • 21. Repairing • The Data Gobbler -- mongodb likes hard- drive space and won’t give it back • Use mongod --repair to reclaim your space!
  • 22. Nightly Plan service mongodb stop && mongod --repair --dbpath /var/ lib/mongodb && service mongodb start rm -f /data/mongodump-backup.tar.bz2 && mongodump - o /data/backups && tar -jcf /data/mongodump- backup.tar.bz2 /data/backups && rm -rf /data/backups/
  • 23. Catch Up! • When a Replica Set gets ‘stale’ • rs.status will remain “5” (Recovering) • On Master, will say “Error RS102 too stale to catch up” • stop mongo on all servers, copy over all data files, including local.*, start all
  • 24. Table Scans == Devil • When you get to 500,000 records, your DB may slow to crawl. • /var/log/mongodb/mongodb.log for logged queries (table scans) • db.collection.getIndexKeys() • Mongoid: rake db:mongoid:create_indexes
  • 25. No, Really • I’ve been surprised LOTS at how often a table scan happens. • Test it out: mongod --notablescan • Stuff will break.
  • 26. Sharding • Don’t Shard Early • Helps in map-reduce • You define a “shard-key”, like lastname from A-H on this shard
  • 27. Scaling (Secret Sauce) • Many Shard Masters, even more slaves • Add Shards for write and data size scaling • Add Slaves for read scaling (map-reduce) and redundancy • Sharding is Hard
  • 28. Neat Snippets Replication Setup Sharding Setup https://github.com/mongodb/mongo-snippets
  • 29. EC2 Notes • Reformat drive to EXT4 or XFS • Don’t use EBS for long term backups • Can use EBS for setting up replica sets

Notas del editor

  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