Percona Live Santa Clara, California April 24th 27th, 2017

Similar documents
MongoDB Shell: A Primer

ITG Software Engineering

MongoDB Distributed Write and Read

How to Scale MongoDB. Apr

The course modules of MongoDB developer and administrator online certification training:

Plug-in Configuration

MongoDB Backup & Recovery Field Guide

Group-B Assignment No. 15

Course Content MongoDB

VMWARE VREALIZE OPERATIONS MANAGEMENT PACK FOR. MongoDB. User Guide

Scaling MongoDB. Percona Webinar - Wed October 18th 11:00 AM PDT Adamo Tonete MongoDB Senior Service Technical Service Engineer.

MONGODB INTERVIEW QUESTIONS

CSE 544 Principles of Database Management Systems. Magdalena Balazinska Winter 2015 Lecture 14 NoSQL

What s new in Mongo 4.0. Vinicius Grippa Percona

MongoDB CRUD Operations

MongoDB CRUD Operations

Breaking Barriers: MongoDB Design Patterns. Nikolaos Vyzas & Christos Soulios

API Gateway 8.0 Multi-Regional Deployment

Document Object Storage with MongoDB

Reduce MongoDB Data Size. Steven Wang

MongoDB Index Types How, when and where should they be used?

MMS Backup Manual Release 1.4

Brad Dayley. Sams Teach Yourself. NoSQL with MongoDB. SAMS 800 East 96th Street, Indianapolis, Indiana, USA

Exploring the replication in MongoDB. Date: Oct

MongoDB: Replica Sets and Sharded Cluster. Monday, November 5, :30 AM - 5:00 PM - Bull

MongoDB Architecture

Why Choose Percona Server for MongoDB? Tyler Duzan

Run your own Open source. (MMS) to avoid vendor lock-in. David Murphy MongoDB Practice Manager, Percona

Your First MongoDB Environment: What You Should Know Before Choosing MongoDB as Your Database

MongoDB. Nicolas Travers Conservatoire National des Arts et Métiers. MongoDB

Time-Series Data in MongoDB on a Budget. Peter Schwaller Senior Director Server Engineering, Percona Santa Clara, California April 23th 25th, 2018

Plug-in Configuration

Scaling with mongodb

MongoDB Revs You Up: What Storage Engine is Right for You?

MongoDB Shootout: MongoDB Atlas, Azure Cosmos DB and Doing It Yourself

CLOUD-SCALE FILE SYSTEMS

SQL, NoSQL, MongoDB. CSE-291 (Cloud Computing) Fall 2016 Gregory Kesden

WiredTiger In-Memory vs WiredTiger B-Tree. October, 5, 2016 Mövenpick Hotel Amsterdam Sveta Smirnova

Consistent Reads Using ProxySQL and GTID. Santa Clara, California April 23th 25th, 2018

MongoDB Backup and Recovery Field Guide. Tim Vaillancourt Sr Technical Operations Architect, Percona

User Manual Mail Merge

NOSQL EGCO321 DATABASE SYSTEMS KANAT POOLSAWASD DEPARTMENT OF COMPUTER ENGINEERING MAHIDOL UNIVERSITY

MongoDB. David Murphy MongoDB Practice Manager, Percona

Mike Kania Truss

Advanced Database Project: Document Stores and MongoDB

Distributed Filesystem

MongoDB Tutorial for Beginners

Percona Live Updated Sharding Guidelines in MongoDB 3.x with Storage Engine Considerations. Kimberly Wilkins

EASYHA SQL SERVER V1.0

MongoTor Documentation

MongoDB in AWS (MongoDB as a DBaaS)

Group13: Siddhant Deshmukh, Sudeep Rege, Sharmila Prakash, Dhanusha Varik

The Google File System

Monitoring MySQL Performance with Percona Monitoring and Management

Managing CPS Interfaces And APIs

How to upgrade MongoDB without downtime

Cloud Computing and Hadoop Distributed File System. UCSB CS170, Spring 2018

Simba ODBC Driver with SQL Connector for MongoDB

Final Exam Review 2. Kathleen Durant CS 3200 Northeastern University Lecture 23

NPTEL Course Jan K. Gopinath Indian Institute of Science

CSC Web Programming. Introduction to SQL

CSE 124: Networked Services Lecture-16

Import, Export, Index MongoDB

Why Do Developers Prefer MongoDB?

CSE 124: Networked Services Fall 2009 Lecture-19

RADIUS Commands. Cisco IOS Security Command Reference SR

Beyond Relational Databases: MongoDB, Redis & ClickHouse. Marcos Albe - Principal Support Percona

MongoDB Schema Design

MongoDB Monitoring and Performance for The Savvy DBA

Download Studio 3T from

Big Data and Scripting mongodb map reduce

Scaling MongoDB: Avoiding Common Pitfalls. Jon Tobin Senior Systems

Live Data CLI Commands

MongoDB An Overview. 21-Oct Socrates

Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Configuring the CSS as a Client of a TACACS+ Server

MongoDB Security Checklist

MongoDB Security: Making Things Secure by Default

/ Cloud Computing. Recitation 7 October 10, 2017

ElasticSearch in Production

The Google File System (GFS)

Running MongoDB in Production, Part I

MEAN Stack. 1. Introduction. 2. Foundation a. The Node.js framework b. Installing Node.js c. Using Node.js to execute scripts

Georgia Institute of Technology ECE6102 4/20/2009 David Colvin, Jimmy Vuong

Accelerate MySQL for Demanding OLAP and OLTP Use Cases with Apache Ignite. Peter Zaitsev, Denis Magda Santa Clara, California April 25th, 2017

NDBI040: Big Data Management and NoSQL Databases

MongoDB and Mysql: Which one is a better fit for me? Room 204-2:20PM-3:10PM

Google File System, Replication. Amin Vahdat CSE 123b May 23, 2006

STIDistrict Query (Basic)

MongoDB as a NoSQL Database

Engineering Goals. Scalability Availability. Transactional behavior Security EAI... CS530 S05

The Google File System

MongoDB - a No SQL Database What you need to know as an Oracle DBA

ClickHouse Deep Dive. Aleksei Milovidov

Persistent Data Transfer Procedure

Scaling Without Sharding. Baron Schwartz Percona Inc Surge 2010

NoSQL systems: sharding, replication and consistency. Riccardo Torlone Università Roma Tre

Print and Copy Vending

CS435 Introduction to Big Data FALL 2018 Colorado State University. 11/7/2018 Week 12-B Sangmi Lee Pallickara. FAQs

Support high-performance business applications with a powerful Dell EMC, Nutanix, and Toshiba solution

Transcription:

Percona Live 2017 Santa Clara, California April 24th 27th, 2017

MongoDB Shell: A Primer Rick Golba

The Mongo Shell It is a JavaScript interface to MongoDB Part of the standard installation of MongoDB Used to query and update data, and perform administrative operations Stored by default in /usr/bin Either access the shell from /usr/bin or add the path to the PATH variable $ PATH=$PATH:/usr/bin 3

Common Mongo Shell Options --port <port> - allows you to specify the port where mongod or mongos is listening; 27017 by default --host <hostname> - allows you to specify the host where mongod or mongos is running, needed when accessing a remote host --username <username> - allows you to specify the username to authenticate if the MongoDB database uses authentication --password <password> - allows you to specify the password for the provided username. If omitted, the shell prompts for the password. --help - provides information on all of the shell options for MongoDB 4

Mongo Limit and Skip You can limit the number of documents returned by a query > db.<collection>.find().limit(number) For queries that would return a large number of documents, but only a sample set is needed You can also skip a specified number of documents returned by a query > db.<collection>.find().limit(number).skip(number) If a value for limit is not specified, all documents will be initially returned, and then the specified number of documents are skipped 5

Mongo Sorting MongoDB queries do not returned data in a sorted order unless specified >db.<collection>.find().sort({<key1>:1,<key2>:1...}) 1 specifies an ascending sort, which is the default -1 species a descending sort Be careful of multiple sort levels slowing down the query process Queries can be sped up through proper indexing 6

Mongo Aggregation Pipeline db.orders.aggregate([ {$match: {}, {$group: {_id: "$cust_id":, total: {$sum: "$amount"}}} ] ) {cust_id: "808" amount: 724 amount: 978 amount: 603 amount: 617 status: "inactive"} 7

Mongo Aggregation Pipeline - $match db.orders.aggregate([ {$match: {}, {$group: {_id: "$cust_id":, total: {$sum: "$amount"}}} ] ) {cust_id: "808" amount: 724 amount: 978 amount: 603 amount: 617 status: "inactive"} 8

Mongo Aggregation Pipeline - $group db.orders.aggregate([ {$match: {}, {$group: {_id: "$cust_id":, total: {$sum: "$amount"}}} ] ) {cust_id: "808" amount: 724 amount: 978 amount: 603 amount: 617 status: "inactive"} {_id: "412" amount: 1702} {_id: "808" amount: 603} 9

Mongo Explain Plan db.<collection>.explain().<method> Returns information on the query plan for aggregate() count() distinct() find() group() remove() update() 10

Mongo Explain Plan Inclusions > db.orders.explain().aggregate([ {$match: {status:"active"}}, {$group: {_id:"$ cust_id",total: {$sum:"$amount"}}}]) Passes information through a series of stages to completion COLLSCAN for collection scan (all documents) IXSCAN for scan of index keys (subset of documents) FETCH for retrieval of data SHARD_MERGE for merging results from multiple shards Shows information on rejected plans, if available 11

MongoDB Write Concern By default, MongoDB only requires write acknowledgement from the master You can override this and specify the number of replicas that must acknowledge prior to the write being processed to the database This can either be a specified number of nodes or a majority of nodes To specify write concern 2 on an insert > db.movies.insert( ) { title: "Logan", year : 2017, director: "James Mangold" }, { writeconcern: { w: 2 } } Use {writeconcern: {w: "majority"}} for majority option 12

Write Concern Examples Write Concern 1 Write Concern 2 (or majority) Default Write Concern 13

validate Command Checks the structures within a namespace for correctness by scanning the collection s data and indexes Returns information regarding the on-disk representation of the collection Can be slow, particularly on larger data sets While running, it holds an exclusive lock on the collection This blocks all reads and writes until the validate command finishes Output differs based on storage engine > db.collection.validate(<true>) true specifies a complete validation and will require more time 14

validate Output Summary validate.ns - full namespace name of the collection validate.nrecords - number of documents in the collection validate.nindexes - number of indexes on the collection validate.keysperindex - number of keys in each index validate.valid - returns true if all aspects of the collection are valid validate.errors - if valid returns false, this field contains a message describing the validation error validate.ok - displays 1 for successful completion of command, 0 if it fails 15

Mongo Read Preference By default, an application sends its read requests to the primary member of a replica set You can direct the read request to another member of the replica set This may return stale data due to write concerns and asynchronous replication Setting read preference mode is specific to the driver being used 16

Mongo Read Preference Options primary - default, operations read from the current replica set primary primarypreferred - operations read from the primary but if it is unavailable, operations can read from secondary members secondary - operations read from the secondary members of the replica set secondarypreferred - operations read from secondary members but if no secondary members are available, operations read from the primary nearest - operations read from member of the replica set with the least network latency regardless of type maxstalenessseconds can be specified for all but primary to determine a time threshold after which the member is not used for reads. Must be >90. 17