Successfully reported this slideshow.

MongoDB Basics Unileon

1,384 views

Published on

MongoDB Basics. Talk at University of León, Spain. A whole description of MongoDB power, characteristics, capabilities and products. Updated to 3.2 version.

Published in: Data & Analytics
  • Be the first to comment

  • Be the first to like this

MongoDB Basics Unileon

  1. 1. León, December 4th 2015 Juan Antonio Roy Couto basicsbasics
  2. 2. #UniLEMongoDB Twitter Hashtag MongoDB Basics 2
  3. 3. Who am I? Juan Antonio Roy Couto ❏ Financial Software Developer ❏ Email: juanroycouto@gmail.com ❏ Twitter: @juanroycouto ❏ Linkedin: https://www.linkedin.com/in/juanroycouto ❏ Slideshare: slideshare.net/juanroycouto ❏ Personal blog: http://www.juanroy.es ❏ Contributor at: http://www.mongodbspain.com ❏ Charrosfera member: http://www.charrosfera.com MongoDB Basics 3
  4. 4. ❏ History ❏ Ranking, Who, Community & Metrics, Drivers ❏ Products ❏ Cluster Overview ❏ Characteristics ❏ Schema Design ❏ How does MongoDB work? ❏ Utilities ❏ Data analytics ❏ Ops Manager ❏ Cloud Manager Agenda MongoDB Basics 4
  5. 5. History MongoDB Basics MongoDB Internet of things Cloud computing Wearables Apps Smart cities ❏ Non structured data ❏ Enabling Big Data analytics ❏ Faster development ❏ Real time analytics ❏ Better strategic decisions ❏ Reduce costs and time to market 5
  6. 6. DB Ranking DB-Engines Ranking & Gartner Magic Quadrant MongoDB Basics 6
  7. 7. Who? MongoDB Basics 7 Who is using MongoDB? https://www.mongodb.com/who-uses-mongodb Who provides MongoDB? https://www.mongodb.com/partners/list
  8. 8. Community & Metrics https://www.mongodb.org/community MongoDB Basics ❏ 10 million downloads ❏ 2,000+ customers (including over one third of the Fortune 100) ❏ 100+ MongoDB User Groups and 40,000 members worldwide ❏ 300,000+ Education Registrations ❏ The only “Challenger” to relational databases in Gartner’s Operational Database Magic Quadrant ❏ Highest placed non-relational database in DB Engines rankings 8
  9. 9. Drivers https://docs.mongodb.org/ecosystem/drivers/ MongoDB Basics 9 MongoDB APP DRIVER ❏ c ❏ c++ ❏ c# ❏ Java ❏ Node.js ❏ Perl ❏ PHP ❏ Python ❏ Motor ❏ Ruby ❏ Scala ❏ Go ❏ Erlang
  10. 10. Products https://www.mongodb.com/products/overview MongoDB Basics 10 Enterprise Advanced ❏ 24-365 Support ❏ Ops or Cloud Manager ❏ Advanced Security ❏ On-Demand Training, ... Professional ❏ Expert Support ❏ Cloud Manager Cloud Manager Development ❏ Expert Support ❏ Enterprise Advanced ❏ Personal Training Ops Manager Consulting Training
  11. 11. Concepts MongoDB Basics 11 MongoDB SQL Database Database Collection Table Document Row Field Column Embedding/$lookup Join
  12. 12. Stand-alone MongoDB installation MongoDB Basics 12 MongoDB Client DRIVER Client DRIVER Client DRIVER
  13. 13. SecondarySecondary Replica Set MongoDB installation MongoDB Basics 13 Primary Client DRIVER Client DRIVER Client DRIVER Replica Set
  14. 14. Replica Set Secondary Secondary Cluster overview MongoDB Basics 14 Primary Client DRIVER Client DRIVER Client DRIVER Secondary Secondary Primary Secondary Secondary Primary Secondary Secondary Primary mongos mongos mongos config server config server config server Shard 0 Shard 1 Shard 2 Shard N-1
  15. 15. Characteristics http://www.mongodbspain.com/en/2014/08/17/mongodb-characteristics-future/ MongoDB Basics 15 MongoDB Characteristics Open Source & General Purpose NoSQL Database Document Oriented (JSON) & Schemaless High Availability (Native Replication) Automatic Failover Scalability (Auto Sharding & Load Balancing) TTL Indexes, Capped Collections, Index Intersection, full-text search, GeoSpatial Queries (2d & 2dsphere) Security (Authentication, Authorization, Users, Roles) Aggregation Framework & MapReduce Connectors for: ● Hadoop & Spark (Batch Data Processing) ● BI (Business Inteligence) Pluggable Storage Engine API (WiredTiger, MMAPv1, Encrypted,In-memory,...) Joins ($lookup) Document validation, Compass GUI, ...
  16. 16. JSON Document MongoDB Basics 16 > db.customers.findOne() { "_id" : ObjectId("54131863041cd2e6181156ba"), "first_name" : "Peter", "last_name" : "Keil", "address" : { "street" : "C/Alcalá", "number" : 123, "location" : "Madrid", }, "pets" : [ { "type" : "Dog", "breed" : "Airedale Terrier", "name" : "Linda", }, { "type" : "Dog", "breed" : "Akita", "name" : "Bruto", } ] } >
  17. 17. SQL Schema Design MongoDB Basics 17 ❏ Customer Key ❏ First Name ❏ Last Name Tables Customers ❏ Address Key ❏ Customer Key ❏ Street ❏ Number ❏ Location Addresses ❏ Pet Key ❏ Customer Key ❏ Type ❏ Breed ❏ Name Pets
  18. 18. MongoDB Schema Design MongoDB Basics 18 Customers Collection ❏ Street ❏ Number ❏ Location Addresses ❏ Type ❏ Breed ❏ Name Pets Customers Info ❏ First Name ❏ Last Name ❏ Type ❏ Breed ❏ Name > db.customers.findOne() { "_id" : ObjectId("54131863041cd2e6181156ba"), "first_name" : "Peter", "last_name" : "Keil", "address" : { "street" : "C/Alcalá", "number" : 123, "location" : "Madrid", }, "pets" : [ { "type" : "Dog", "breed" : "Airedale Terrier", "name" : "Linda", }, { "type" : "Dog", "breed" : "Akita", "name" : "Bruto", } ] } >
  19. 19. ❏ Replica set ❏ Shards ❏ config servers ❏ mongos ❏ Cluster overview Cluster overview MongoDB Basics 19
  20. 20. Cluster overview Replica Set ❏ High Availability ❏ Data Safety ❏ Asynchronous ❏ Automatic Node Recovery ❏ Read Preference ❏ Write Concern Replica Set Secondary Secondary Primary MongoDB Basics 20
  21. 21. ❏ Scale out ❏ Even data distribution across all of the shards based on a shard key ❏ A shard key range belongs to only one shard ❏ More efficient queries (performance) Cluster overview Shards Cluster Shard 0 Shard 2Shard 1 A-I J-Q R-Z MongoDB Basics 21
  22. 22. Cluster overview Config servers ❏ config database ❏ Identical information (consistency check). ❏ Metadata: ❏ Cluster shards list ❏ Data per shard (chunk ranges) ❏ ... ❏ Replica Set (3.2 version) MongoDB Basics 22
  23. 23. ❏ Receives client requests and returns results. ❏ Reads the metadata and sends the query to the necessary shard/shards. ❏ Does not store data. ❏ Keeps a cache version of the metadata. Cluster overview mongos MongoDB Basics 23
  24. 24. Definitions ❏ Range: Data division based on the values of the shard key. ❏ Chunk: They are not physical data. Chunks are just a logical grouping of data into ranges (64MB by default). ❏ Split: Chunk division (size > 64MB). No data is moved. Background. ❏ Migration: Chunk movements between shards in order to get an even distribution. Only one chunk is moved at a time. ❏ Balanced system: The same number of chunks per shard. ❏ Balancer: Checks if a migration is needed and starts it (background). ❏ Pre-split: First data is split, then it is stored. ❏ Tag-based sharding: Used when you want to pin ranges to a specific shard. MongoDB Basics 24
  25. 25. How does MongoDB work? Shard 0 Shard 1 Shard 2 Shard 3 mongos Client Migrations MongoDB Basics 25
  26. 26. Utilities Backup tools MongoDB Basics 26 Name Description mongoexport Generates a JSON or CSV file from a mongodb instance mongoimport Imports content from a JSON, CSV or TSV export mongodump Utility for creating a binary export mongorestore Writes data to a mongodb instance from a binary file
  27. 27. Utilities Track tools MongoDB Basics 27 Name Description mongostat Provides a quick overview of the status of a running mongod or mongos instance mongotop Provides a method to track the amount of time a mongodb instance spends reading or writing data. mongotop provides statistics on a collection level. By default, returns values each second.
  28. 28. Data analytics MongoDB Basics 28 ❏ Internals ❏ Aggregation Framework ❏ Map Reduce ❏ Externals ❏ Spark ❏ Hadoop ❏ Tableau (BI) ❏ ...
  29. 29. OPS Manager MongoDB Basics 29 The best way to run MongoDB within your own data center or public cloud ❏ Monitors 100+ key database and system health metrics (operations, memory, CPU,...) ❏ Customizable web dashboard ❏ Deploy new clusters (adding shards, replica set members,…) ❏ Alerts ❏ Backup (point-in-time recovery) ❏ Automation (upgrades, scaling,..)
  30. 30. Cloud Manager MongoDB Basics ❏ Simplify complex operational tasks (Reduce tedious manual steps to just a click of a button) ❏ Automated database management (deploy and upgrade with zero downtime) ❏ Continuous real-time backup (Cloud manager is disaster recovery). ❏ Full performance visibility ❏ Alerts ❏ Get the insights you need to make critical decisions fast. ❏ Cloud Manager saves you time, money, and helps you protect the customer experience by eliminating the guesswork from running MongoDB. 30
  31. 31. ❏ High Performance ❏ Flexible ❏ Automatic Scalable ❏ Automatic Failover ❏ High Availability ❏ Reduced Administrative Tasks (replica set, sharding, disaster recovery) ❏ Real Time Analytic Tools (aggregation framework, mapReduce, Hadoop, Spark, and BI connectors,...) ❏ Easy To Learn Summary MongoDB Basics 31
  32. 32. Questions? Questions? MongoDB Basics 32
  33. 33. Thank you for your attention! MongoDB Basics León, December 4th 2015 Juan Antonio Roy Couto

×