SpringPeople Introduction to MongoDB

Embed Size (px)

Citation preview

  • 7/22/2019 SpringPeople Introduction to MongoDB

    1/18

    SpringPeople Software Private Limited, All Rights Reserved.

    SpringPeople Software Private Limited, All Rights Reserved.

    Introduction to MongoDB

  • 7/22/2019 SpringPeople Introduction to MongoDB

    2/18

    SpringPeople Software Private Limited, All Rights Reserved.

    What is MongoDB?

    MongoDB is a NoSQL store - NoSQL revolution

    happened to solve the many issues faced with

    storing web-scale data in relational databases

    It doesn't use SQL to store and retrieve data Widely adopted in web applications these days

    No clear winner and therefore difficult to choose

    among alternatives

  • 7/22/2019 SpringPeople Introduction to MongoDB

    3/18

    SpringPeople Software Private Limited, All Rights Reserved.

    Key Features - MongoDB

    The document data model

    Ad-hoc queries

    Secondary indexes

    Replication

    Speed & Durability

    Scaling

  • 7/22/2019 SpringPeople Introduction to MongoDB

    4/18

    SpringPeople Software Private Limited, All Rights Reserved.

    MongoDB Concepts

    Database A single MongoDB server can have many databases

    Collections

    Collections are a group of Documents (sort of like RDBMS tables)

    Documents

    A record in a MongoDB collection with a maximum size of 16MB

    Fields

    One name-value pair in a document & is analogous to columns in a relational

    database

  • 7/22/2019 SpringPeople Introduction to MongoDB

    5/18

    SpringPeople Software Private Limited, All Rights Reserved.

    MongoDBHands-On

    Use-Cases

    Blog posts and Comments

    E-commerce data

    Products and categories

    Users and their orders

    Reviews of products

    LinkedIn Profile Analysis A person and his/her education and experience

  • 7/22/2019 SpringPeople Introduction to MongoDB

    6/18

    SpringPeople Software Private Limited, All Rights Reserved.

    Hands-OnCUD of CRUD

    LinkedIn case studyJSON document for Profile

    C of CRUD

    Insert documents

    Get, Change, Save U of CRUD

    Update a document

    Update multiple documents

    D of CRUD Remove

    Drop

  • 7/22/2019 SpringPeople Introduction to MongoDB

    7/18 SpringPeople Software Private Limited, All Rights Reserved.

    Hands-OnR of CRUD

    Find documents

    Find all documents - find

    Find a single document - findOne

    Specify a condition

    Specify multiple conditions

    Specifying conditions on sub-documents

  • 7/22/2019 SpringPeople Introduction to MongoDB

    8/18 SpringPeople Software Private Limited, All Rights Reserved.

    Indexing

    Understanding the need for indexing

    The explain

    Creating an index

    Creating an index with a unique field

    Indexes with multiple fields (compound indexes)

    Hashed Indexes

    Sparsed Indexes

    Removing an index

    Displaying all indexes Indexes that support covered queries

  • 7/22/2019 SpringPeople Introduction to MongoDB

    9/18 SpringPeople Software Private Limited, All Rights Reserved.

    Replication

    Why Replication?

    Redundancy

    Fail-over

    Maintenance

    Load Balancing

    Replication Setups

    Master/Slave Replication

    Replica Set Setup Arbiter

    Finding status via rs.status() on Primary

    Fail-over

  • 7/22/2019 SpringPeople Introduction to MongoDB

    10/18 SpringPeople Software Private Limited, All Rights Reserved.

    ReplicationOplogs and Heartbeat

    Oplog

    Capped Collections that is present in a database called

    local on every replicating node

    Location: Database: local, Collection: oplog.rs Changing the oplog size (via mongod config)

    Heartbeat

    A 2-second ping with other members that helps the replicaset determine if a node has gone down

  • 7/22/2019 SpringPeople Introduction to MongoDB

    11/18

    SpringPeople Software Private Limited, All Rights Reserved.

    Authentication

    Adding the admin user

    Adding individual users

    Starting the server with auth enabled

    Using authentication Replica sets and authentication

  • 7/22/2019 SpringPeople Introduction to MongoDB

    12/18

    SpringPeople Software Private Limited, All Rights Reserved.

    Sharding

    Idea of sharding

    How is sharding different from replication?

    The different servers involved

    Shards

    Routers Config Servers

    Sharding without replication

    Sharding with replication

    Sharding with security enabled

    Bad shard keys

    Choosing ideal shard keys

  • 7/22/2019 SpringPeople Introduction to MongoDB

    13/18

    SpringPeople Software Private Limited, All Rights Reserved.

    Backup, Repair, Import, Export

    Backing up the data directory

    Issue with backing up the data directory

    Using fsync and lock

    mongodump

    mongorestore

    Bsondump

    mongoimport

    mongoexport

  • 7/22/2019 SpringPeople Introduction to MongoDB

    14/18

    SpringPeople Software Private Limited, All Rights Reserved.

    Monitoring

    Admin UI

    Getting database information via the UI

    HTTP REST based interface

    Monitoring

    serverStatus

    dbStats

    collStats

    mongostat mongotop

    mongosniff

  • 7/22/2019 SpringPeople Introduction to MongoDB

    15/18

    SpringPeople Software Private Limited, All Rights Reserved.

    Leftovers

    Production Checklist

    Write concern in replica sets

    Full Text Search

    Map/Reduce

    GridFS

  • 7/22/2019 SpringPeople Introduction to MongoDB

    16/18

    SpringPeople Software Private Limited, All Rights Reserved.

    Become a MongoDB Expert In 3

    Days Flat

    Attend the 3-Days MongoDB Administration Workshop

    View Complete Details

    http://springpeople.com/courses/regular/mongodb-administration-jumpstart-workshop-training-course.phphttp://springpeople.com/courses/regular/mongodb-administration-jumpstart-workshop-training-course.php
  • 7/22/2019 SpringPeople Introduction to MongoDB

    17/18

    SpringPeople Software Private Limited, All Rights Reserved.

    Who will benefit?

    Application Developers who are currently evaluating the use of MongoDB in

    their projects

    View Complete Details

    http://springpeople.com/courses/regular/mongodb-administration-jumpstart-workshop-training-course.phphttp://springpeople.com/courses/regular/mongodb-administration-jumpstart-workshop-training-course.php
  • 7/22/2019 SpringPeople Introduction to MongoDB

    18/18

    SpringPeople Software Private Limited, All Rights Reserved.

    For further info/assistance contact

    [email protected]

    +91 80 65679700

    www.springpeople.com

    Certified Partner For

    mailto:[email protected]://www.springpeople.com/http://www.springpeople.com/mailto:[email protected]