SQL (Structured Query Language) databases have been the primary data storage mechanism for more than four decades. In relational databases, data is stored in tables and uses Structured Query Language (SQL) for data access. Database schema is pre-defined based on application requirements and rules are setup to establish relationship between fields in tables. To fetch the related data from many tables, JOIN is used.
However with the explosion of data to be stored and variety of data, non-relational databases also known as NoSQL databases such as MongoDB are becoming very popular option for new applications.
MongoDB Introduction
MongoDB is NoSQL open source database that saves data in JSON-like document format that can vary in structure. All related information is saved in single document for fast query access through MongoDB query language. MongoDB allows creating dynamic schemas, which means records, can be created without defining schema first. Simply by adding new fields or by deleting existing, it is possible to modify the structure of records or documents. This data model gives ability to store even hierarchical relationship, array storage and more complex structures easily without much of changes.
MongoDB Atlas – Hosted MongoDB as a service
MongoDB Atlas is a cloud service for running, monitoring and maintaining MongoDB deployments, including the provisioning of dedicated servers for MongoDB instances. By default, Atlas uses MongoDB 3.4.
MongoDB Atlas makes it easy to set up, operate and scale MongoDB deployments in cloud. MongoDB Atlas provides all the features of MongoDB and it is available on-demand and billed on an hourly basis.
Setting up MongoDB Atlas
- To get started with Atlas, create your user account and log in to
- After you log in to Atlas, create a new Atlas The name of the group should be globally unique.
- Create a “Cluster” – can be either a replica set or a sharded Click on “Build New Cluster” and select the configuration options such as name, version, AWS region and instance size. By default, Atlas uses MongoDB 3.4.
- Create MongoDB Admin user with username and
- If backups are enabled at this point then Atlas can take backup at regular intervals and retain them as per retention
- Click on “Confirm and Deploy” and enter payment
Security Features and Setup
Data security is most important for any database services. MongoDB Atlas provides following features for controlling access to database. To ensure security- authentication and IP whitelisting is automatically enabled.
- User Rights Management: We can create different users and roles. Assign the privileges for each user depending on the need. Specify the role and database associated with for each user for controlled access. To access the database, the user must have the permission and must be authenticated.
- IP Whitelisting: Clients need to register their IP address in IP Whitelist for MongoDB atlas group in order to access For unregistered IP- access is prevented.
- Encryption: Atlas uses TLS/SSL to encrypt the connection to
- VPC Peering: Atlas supports optional security feature – VPC peering with other AWS VPC in same region. This allows connectivity without specifying public IP Address and there is no need to whitelist every client in MongoDB Atlas
Connect to a Cluster
You can connect to a cluster via mongo shell or MongoDB driver. Client must support TLS/SSL to connect to Atlas cluster. To access cluster – client IP address must be added to Atlas group’s whitelist.
Connection specific details are provided in “Clusters” view – for the cluster you wish to connect, click on “Connect”. Use the displayed connection details to connect to the cluster via a mongo shell or via a MongoDB Driver.
Import data into Cluster
Existing MongoDB data can be imported into cluster using following methods: mongorestore – Using BSON dump backup of existing MongoDB mongoimport – to load data from JSON or CSV file.
Backup a Cluster
Atlas backup service takes snapshots of data at specified intervals and retains it as per retention policy. Backups can be enabled when cluster is created or by modifying existing cluster. Enabling backup for the cluster allows restoring cluster from the saved snapshot.
Atlas also provides functionality to query specific snapshot.
Restore a Cluster
Atlas allows to restore data from a scheduled snapshot or selected point between snapshots. To restore a cluster- go to backup view. In the Options dropdown, click on Restore.
Monitoring and alerts
Atlas provides following ways to monitor clusters performance.
- Performance Metrics – Atlas collects and displays metrics such as state of cluster database and server
- Alerts – When certain database operations or server usage reaches a threshold value that affects cluster performance, notifications are generated. User can configure alert settings to specify which conditions trigger alerts and how users should be
- Logs – Each mongo instance keeps log of all activity in its own log Log messages are retained for last 5 days.
Conclusion
MongoDB Atlas automates the operational task so that users can focus more on applications with simple and convenient “Pay for what you use” billing model. MongoDB atlas can quickly scale up and down as per the need with no downtime. It provides full security and high performance. Stay tuned for more on this subject from Team IrisLogic!