MongoDB for the SQL DBA
Ever heard of MongoDB? Who works with Mongo? Who has Heard of Mongo? Who is MongoCurious? Anyone else is in the wrong room
Where does the name MongoDB come from? HU – MONGO - US represent the idea of supporting large amounts of data
Andrew Saalmann Operations DBA w\ local software company Worked with SQL Server versions 7 – 2014 (2016 soon) Worked in small (<10), large (>5000) , financial, manufacturing, software dev and e-commerce companies Work with MongoDB v 3.4 B.S. in Nuclear Medicine Technology Email: MetalDBA@gmail.com Twitter: @Saalmann
Agenda What is MongoDB Why use MongoDB Why not use MongoDB Installation of MongoDB Creating database, collections and documents Queries in MongoDB Backups & Restores Robomongo
What does MongoDB Looks like?
How does a pair of SQL DBAs start supporting MongoDB? We are not experts
What is MongoDB? MongoDB is an open source database that uses a document-oriented data model Classified as a NoSQL database program, MongoDB uses JSON-like documents
JSON – JavaScript Object Notation A human-readable, plain text format for expressing structured data with support in many programming languages
MongoDB stores data records as BSON documents. BSON is a binary representation of JSON documents, it contains more data types than JSON.
SQL Server MongoDB Database Table Collection Row Document Column Field Index Partition Sharding Clustering ReplicaSet Joining Linking & Embedding
Why use MongoDB? You must store unstructured data You have a very high write load (without transactions) You need to handle more reads & writes than a single server can handle You need a solution that can easily scale-out(sharding) You work with tables with very inconsistent schemas You need high availability solution built-in (ReplicaSets) You need high performance (most of the data is stored in ram) You need built in geospatial functions
Why you wouldn’t want to use MongoDB? No support for transactions Limited support for joins No support for triggers Document size limit (16 mb) Your data is relational You don’t want duplicate data.
Use Cases for MongoDB
Is MongoDB going to replace SQL Server? NO Know your data Know your application
Supporting 2 different databases is hard enough right?
Let’s get technical about MongoDB
Ahmad Drshen Personal blog : www.adrshen.com Over 15 years of Information Technology experience with the last 12 years focused on mastering the Microsoft SQL Server platform including Power BI ,Data Science algorithms and MongoDB. Industries served, financial, banking, mortgage, retail, healthcare & insurance Trained with industry known SQL gurus Paul Randel, Kimberly L. Tripp, Jonathan Kehayias, Glenn Berry and Brent Ozar Twitter adrshen Linkedin : adrshen
How do we get started with MongoDB? Download community edition at https://www.mongodb.com/download-center Prerequisites or Requirement https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/ Robo3T- a user friendly studio to work with mongo databases and collections https://robomongo.org/ Mongo Compass --analyze and understand the contents of your collections https://docs.mongodb.com/compass/current/
Installing MongoDB
Understanding MongoDb components Component Set Binaries Server mongod.exe Router mongos.exe Client mongo.exe Monitoring Tools mongostat.exe, mongotop.exe ImportExportTools mongodump.exe, mongorestore.exe, mongoexport.exe, mongoimport.exe MiscellaneousTools bsondump.exe, mongofiles.exe, mongooplog.exe, mongoperf.exe monoreplay.exe , mongoldap.exe The core components in the MongoDB package are: mongod, the core database process; mongos (mongo sharding service) the controller and query router for sharded clusters; and mongo the interactive MongoDB Shell. mongod is the primary process for the MongoDB system. It handles data requests, manages data access, and performs background management operations. mongo is an interactive JavaScript shell interface to MongoDB, which provides a powerful interface for systems administrators as well as a way for developers to test queries and operations directly with the database. mongo also provides a fully functional JavaScript environment for use with a MongoDB. This document addresses the basic invocation of the mongo shell and an overview of its usage. mongotop provides a method to track the amount of time a MongoDB instance spends reading and writing data. mongotop provides statistics on a per-collection level. By default, mongotop returns values every second. The mongostat utility provides a quick overview of the status of a currently running mongod and mongos instance. mongostat is functionally similar to the UNIX/Linux file system utility vmstat, but provides data regarding mongod and mongos instances.
Creating a Windows Service
Backup & Restore Demo
MongoDB Backup & Restore Back Up with Atlas Back Up with MongoDB Cloud Manager or Ops Manager Back Up by Copying Underlying Data Files Back Up with mongodump and restore with mongorestore utilities. https://adrshen.com/2017/08/01/all-about-mongo- backups-restore/
MongoDB Monitoring Demo
Robomongo Demo
More info or quick help https://docs. mongodb More info or quick help https://docs.mongodb.com/manual/core/document/ stackoverflow.com adrshen.com
Questions?