MongoDB 4.2 Management & Monitoring Without Vendor Lockin

Bart Oles

With the release of a new version of ClusterControl (1.7.5), we can see several new features, one of the main ones being the support for MongoDB 4.2.

MongoDB 4.2 is on the market for a while. It was initially announced at MongoDB World in June 2019, with GA ready in August. Since then, a lot of you have been putting it through its paces. It brings many awaited features, which makes NoSQL a more straightforward choice over RDBMS.

The most significant feature in 4.X was transaction support. It dramatically reduces the gap between RDBMS and NoSQL systems. MongoDB transactions were added in version 4.0, but that didn't work with the most powerful feature of MongoDB clusters. Now MongoDB extends multi-document ACID, which is now guaranteed from the replica set to sharded clusters, enabling you to serve an even broader range of use cases.

The most prominent features of version 4.2 are:

  • On-Demand Materialized Views using the new $merge operator. 
  • Distributed transactions
  • Wildcard Indexes
  • Server-side updates 
  • MongoDB Query Language enhancements
  • Field-level encryption to selectively protect sensitive files

To install MongoDB 4.2 manually, we must first add the repositories or download the necessary packages for the installation, install them, and configure them correctly, depending on our infrastructure. All these steps take time, so let's see how we could speed it up.

In this blog, we will see how to deploy this new MongoDB version with a few clicks using ClusterControl and how to manage it. As a prerequisite, please install the 1.7.5 version of ClusterControl on a dedicated host or VM.

Deploying a MongoDB 4.2 Replica Shard

To perform a new installation from ClusterControl, select the option "Deploy" and follow the instructions that appear. Note that if you already have a MongoDB 4.2 instance running, then you need to choose the 'Import Existing Server/Database' instead.

Deploy MongoDB 4.2

ClusterControl Deployment Options

When selecting MongoDB, we must specify User, Key or Password and port to connect by SSH to our MongoDB nodes. We also need the name for our new cluster and if we want ClusterControl to install the corresponding software and configurations for us.

After setting up the SSH access information, we must define the database user, version, and datadir (optional). We can also specify which repository to use. In this case, we want to deploy MongoDB 4.2, so select it and continue.

In the next step, we need to add our servers to the cluster we are going to create.

ClusterControl Percona 4.2 MongoDB Deployment

When adding our servers, we can enter IP or hostname.

ClusterControl MongoDB 4.2 Deployment

We can monitor the status of the creation of our new cluster from the ClusterControl activity monitor.

ClusterControl Job Details

Once the task is finished, we can see our new MongoDB replicaSet in the main ClusterControl screen.

ClusterContorol Dashboard Status

Once we have our cluster created, we can perform several tasks on it, like adding a backup job

Scaling MongoDB 4.2 

If we go to cluster actions and select "Add  Node", we can either create a new replica from scratch or add an existing MongoDB database as a replica.

ClusterControl MongoDB 4.2 Add a Node

As you can see in the image, we only need to choose our new or existing server, enter the IP address for our new slave server and the database port. Then, we can choose if we want ClusterControl to install the software for us and configure cluster.

The other option is to convert replica set clusters to MongoDB shard. CusterControl will walk you through the process. We need to provide details about Configuration Server and Routers as you can see on the below screen.  

ClusterControl Convert MongoDB 4.2 ReplicaSet to Shard

Conclusion

As we have seen above, you can now deploy the latest MongoDB (version 4.2) using ClusterControl. Once deployed, ClusterControl provides a whole range of features, from monitoring, alerting, automatic failover, backup, point-in-time recovery, backup verification, to scaling of reading replicas.

ClusterControl
The only management system you’ll ever need to take control of your open source database infrastructure.