Site icon i2tutorials

Best practices for MongoDB deployment and administration

 

MongoDB, a NoSQL database management system, has become extremely popular. Its popularity has come with problems, especially in unsupported versions. Some of the largest organizations using MongoDB are featured in a new Datavail white paper. Datavail’s MongoDB Database Engineers and Administrators share their best practices in this blog post.

Different Flavors of MongoDB

The MongoDB community supports open-source software. In the community version, it is unsupported, or it is supported with the enterprise edition. There is also a hosted version, Atlas, which provides both storage and software.

“MongoDB is popular for content management systems (CMSs), which frequently include a wide range of content, such as images, text, tables, and advertisements. Data hubs and other big-data operations use it. MongoDB is excellent for mobile and social data management.” – Datavail white paper.

The community version is free, but you’re responsible for patching and upgrading it yourself. A support contract is recommended if you use the community version.

MongoDB enterprise requires a license per database. Support comes with license

MongoDB Atlas offers database-as-a-service for those who wish to host their databases. In Atlas, users are dependent on the software running in the cloud to perform their tasks. As a result, it’s a lot less flexible than being able to control your own configuration, which gives you more control. Nevertheless, it is an appealing option for companies with fewer employees or for those in need of a backup system.

Best Practices for MongoDB Operations

Here are some best practices for operating MongoDB that Datavail’s clients and DBAs suggest.

  1. Assigning Roles and Responsibilities

The roles are assigned based on the new configuration expectations. Often, end users are closely involved in configuration discussions, along with system administrators, data architects, and DBAs.

  1. Preparing for a MongoDB Deployment  

Storage engine solutions

Schema design

A great strength of NoSQL databases is that they don’t impose schemas. It is possible to merge data in a wide variety of different formats with ease. The format in which they are merged becomes a schema and its design should be carefully considered.

It is important for database architects and schema designers to consider the type and number of documents that will be stored, how they will be grouped into collections, and how they will be indexed and validated.

MongoDB Compass allows these rules to be turned into a visual schema, making database queries easier and faster.

Data lifecycle management

By building MongoDB Zones, DBAs can create tiered storage solutions that support the data lifecycle, storing frequently-used data in memory, less-used data on the server, and archived data offline.

Managing indexes

Indexes play an important role in optimizing a database system. As well as taking up a great deal of space, they must also be removed when they are no longer required. The following are some best practices for modeling data as documents. Your application’s objectives will determine the appropriate approach.

  1. MongoDB Setup and Configuration
  1. Continuous Availability with MongoDB  

In the same way that your power supply has a battery backup or a series of backups, your MongoDB software can be configured with data redundancy and system redundancy to ensure continuous availability.

  1. Scaling a MongoDB System

MongoDB offers the advantage of being able to scale your database as your needs grow. In this technique, MongoDB automatically balances data across shards, or replica data sets, so that there is always capacity and rarely a bottleneck.

There are many ways to shard a database, depending on how the data is stored and retrieved. When a database is sharded by range, it is organized according to a key value that is present in all the documents within the database. To determine the distribution of shards, hash sharding uses an MD5 of the shard key value. Sharding policies can be seen and modified using MongoDB Zones, a sharding program. There are new helpers in MongoDB 3.4 that work with Zones to provide better control over sharding.

Among the things to watch for when scaling your system are file sizes running up against the limits mentioned earlier, exceeding RAM limitations of the system, the need to write to shards can exceed disk I/O limits, and the need to specify the location of the shards.

  1. Managing MongoDB

MongoDB can be managed via the Ops Manager if you are using the on-premises version, the Cloud Manager if you are using the cloud version, or MongoDB Enterprise Advanced, which uses both Cloud Manager and Ops Manager. The database can be manually maintained or automated using the following procedures:

Monitoring. In order to monitor how actual performance differs from what is expected or required, it is important to establish performance baselines. With Ops Manager, you can monitor over 100 metrics in easy-to-customize dashboards that show you how your database is performing at a glance. Permissions can be mapped to dashboards to restrict access to data sets. When performance varies from a desired parameter, custom alerts can be configured to trigger warnings.

Backup and recovery. You should have a backup-and-recovery plan for your MongoDB systems to ensure system uptime, to prevent data loss, and to meet regulatory requirements. Using Ops Manager and Cloud Manager, your data is continuously backed up just seconds behind the master database. In the event of a problem, you can restore the system to a specific point in time. Using the mongodump tool included with MongoDB, you can perform live backups, scheduled backups, or point-in-time backups.

  1. Security for MongoDB

In order to keep your database secure and enable best practices, you should use MongoDB to manage your database and upgrade to the latest version. Contact Datavail today or download the white paper to learn how you might benefit from a MongoDB upgrade or managed services contract. In North America, Datavail is the largest database services provider with more than 800 database administrators. Regardless of your organization’s build, Datavail provides 24×7 managed services for applications, BI/Analytics, and databases.

 

Exit mobile version