blog

Replicating MongoDB Across a Hybrid Cloud Environment

Agus Syafaat

Published

Relying only on on-premises infrastructure may limit how quickly organizations can develop and launch applications. Extending the infrastructure to utilize public cloud in a hybrid setup is a great way to achieve infrastructure agility. It is worth nothing that application performance is dependent not only on the database hardware, but also on your network connection to the database hosts. By making sure data is replicated and available between both on-prem and public cloud, it ensures applications can access data locally, at low latency.

Hybrid Cloud Database Architecture

A hybrid cloud consists of both public and private clouds functioning as a single unit. This allows organizations to take advantage of the strengths of both environments. When deploying MongoDB in a hybrid cloud environment, ClusterControl can be used as the orchestration tool to deploy and manage the MongoDB nodes. 

 

The private cloud gives you full control over the compute resources, network, storage, as well as security. You manage all the infrastructure, and you can configure everything based on your requirements.

Hybrid Cloud Architecture

While the public cloud offers scalability and agility of infrastructure. For example, you can conveniently spin up VM instances in a few minutes and in a couple of clicks. 

Many organizations mix private and public clouds, taking advantage of both environments. If the business is growing rapidly, you need to have fast scalability for your infrastructure. On the other hand, you also need to control and share the resources between them.

Replicating MongoDB in Hybrid Cloud

Preparing the environment

Servers/virtual machines on both sites need to be provisioned, and also connectivity between the nodes. Security in a hybrid cloud deployment is a major priority, both environments can be zoned off in a security group and you need to restrict communication to only specific ports. 

Latency is one of the challenges in hybrid cloud architectures, you need to ensure that latency is similar across the nodes. This is to ensure that when the MongoDB ReplicaSet is up and running, there is no replication lag caused by the network. AWS has Direct Connect that provides dedicated connectivity between cloud and other data centers.

Setting up MongoDB

Deploying MongoDB nodes in a hybrid setup can be automated using ClusterControl. ClusterControl will take care of installing all the required packages, configuring the software and making sure the entire cluster comes up. You can go to deployment page:

 

Choose the MongoDB tab (in this case, we will deploy MongoDB ReplicaSet). Specify the SSH user, password, and give a name to the Cluster as shown below: 

 

After that, choose the vendor database. Currently, the MongoDB database package is supported by MongoDB and Percona. We will use Percona Server for MongoDB with version 4.2.

Fill the admin user and password, you can change the server data directory and port for custom setting, or leave it as default. Add the target MongoDB node, we will configure 3 nodes in private cloud ( ip address 10.10.10.11, 10.10.10.12, 10.10.10.13) and 2 nodes in public cloud (ip address 10.11.10.111 and 10.11.10.112) in a MongoDB ReplicaSet architecture as shown below: 

 

Just click Deploy, it will trigger a new job for deployment in ClusterControl as shown below: 

 

At the end of deployment, you will have hybrid topology for MongoDB ReplicaSet as shown below:

The MongoDB nodes are spread across the private and public environments, which make the cluster highly available

Subscribe below to be notified of fresh posts