Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Intro to MongoDB (on Windows on Azure)

Intro to MongoDB (on Windows on Azure)

James Tan

May 07, 2014
Tweet

More Decks by James Tan

Other Decks in Technology

Transcript

  1. MongoDB is a ___________ database •  Document •  Open source

    •  High performance •  Horizontally scalable •  Full featured
  2. Document Database •  Not for .PDF & .DOC files • 

    A document is essentially an associative array •  Document = JSON object •  Document = PHP Array •  Document = Python Dict •  Document = Ruby Hash •  etc.
  3. Open Source •  MongoDB is an open source project • 

    On GitHub •  Licensed under the AGPL •  Started & sponsored by MongoDB Inc (formerly 10gen) •  Commercial licenses available •  Contributions welcome
  4. 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 & secondary indexes •  Document model = less work
  5. Full Featured •  Dynamic schema •  Strongly consistent (default) • 

    Complex data types and operators (e.g. arrays, sets) •  Rich queries, aggregation, and full-text search •  Geospatial features, GridFS •  Built-in replication and automatic failover (HA & DR) •  Easy scale out (sharding)
  6. Terminology RDBMS MongoDB Table, View ➜ Collection Row ➜ Document

    Index ➜ Index Join ➜ Embedded Document Foreign Key ➜ Reference Partition ➜ Shard
  7. Typical (relational) ERD User ·Name ·Email address Category ·Name ·URL

    Comment ·Comment ·Date ·Author Article ·Name ·Slug ·Publish date ·Text Tag ·Name ·URL
  8. MongoDB ERD User ·Name ·Email address Article ·Name ·Slug ·Publish

    date ·Text ·Author Comment[] ·Comment ·Date ·Author Tag[] ·Value Category[] ·Value Linking vs embedding
  9. Node 1 Secondary Config Server Node 1 Secondary Config Server

    Node 1 Secondary Config Server Shard Shard Shard Mongos App Server Mongos App Server Mongos App Server Deployment – Sharded cluster
  10. Control of reads and writes •  Read preferences: primary (default),

    primaryPreferred, secondary, secondaryPreferred, nearest •  Write concerns (e.g. w=1, w=majority, j=1, wtimeout=<ms>) •  Tagged reads and writes (to specific/subset of nodes) •  Tag aware sharding
  11. MongoDB on Azure •  Fully managed Service (SaaS) –  MongoLab,

    Azure Store (preview) –  Easiest option •  Partly managed Platform (PaaS) –  Cloud Service: MongoDB worker roles (C# + Windows only) •  Self managed Infrastructure (IaaS) –  MongoDB Azure installer (Windows only) –  Self configured (Linux or Windows) •  Most flexible, but more work
  12. Install MongoDB Windows service •  Install steps (Windows only): http://docs.mongodb.org/manual/tutorial/install-

    mongodb-on-windows/#configure-a-windows- service-for-mongodb •  Start / Stop service: –  Command prompt / Power Shell: •  net start mongodb –  Or with Windows Services GUI in Control Panel –  Check MongoDB log file for potential warning and errors
  13. MongoDB metrics with mongostat   •  Samples MongoDB metrics every

    second •  Displays metrics like operation counters (e.g. number of inserts, updates, delete), memory flushes, memory utilization, lock %, queued reads/writes, number of connections, etc.
  14. Admin GUIs •  There are many (3rd party) options • 

    Personal recommendations: RoboMongo (cross platform) and MongoVUE (Windows only) •  Full list: http://docs.mongodb.org/ecosystem/tools/ administration-interfaces/
  15. What is MMS? •  MMS: MongoDB Management Service •  Available

    Online and On-Premise •  Monitoring (online version is free) •  Database and system metrics •  Alerts (e.g. SMS, emails, HipChat, PagerDuty) •  Backup •  Automation (alpha) •  https://www.youtube.com/watch?v=nSJiVXNsPHk