A hybrid cloud database is a mix of active hosts residing on both on-premises and cloud infrastructures, working as a single operational system. It helps implement a high availability environment, and since both database and applications need to be portable in order to work on on-prem and cloud, it also reduces dependency on a particular cloud vendor (cloud vendor lock-in). Deploying this kind of environment is not that straightforward though.
In this blog post, we are going to look into using ClusterControl to Deploy a Hybrid Cloud MySQL Database, between on-premises and cloud infrastructure running on AWS. This setup allows us to bring the database closer to the clients and applications residing in a cloud environment, and we will be keeping a replica of the database on the on-premises for disaster recovery and live backup purposes.
Architecture
Our deployment consists of four nodes - One node for ClusterControl and one node for master server other two nodes are in slave servers, where 2 of the database nodes are located in the AWS data center as the primary datacenter (as well as ClusterControl), while the third node is located in the on-premises datacenter. The following diagram illustrates our final architecture.
Preparing Your Cloud Environment
First, you need to create your environment with your main Cloud Provider. In this case, we will use AWS with three EC2 instances.
Then, go to the on-premises environment and create one virtual machine or host that will be the standby node.
ClusterControl - 52.14.222.75
Master - 3.17.190.53
Slave 1 - 3.14.146.131
Slave 2 - 192.168.33.15
We will assume you have a ClusterControl installation running and have already created Cloud Provider accounts. Note that we are using cloud instances with public IPs for the purpose of the blog. For a production-grade setup, you have to secure your environment, for instance cloud VMs should be within a VPC with just private IP addresses. You would have a secure connection between on-prem and the VPC.
Deploying MySQL using ClusterControl
Go to your ClusterControl GUI, and select the option “Deploy”. If you already have a MySQL instance running, then you need to select the “Import Existing Server/Database” instead.
Here we are going to do a new deployment so we are selecting the “Deploy” option.When selecting MySQL, you must specify User, Key or Password, and port to connect by SSH to your MySQL nodes.
For more details about the SSH connectivity please check the ClusterControl user requirements.
After setting up the SSH access, you must define the database user and version. Datadir is optional. You can also specify which repository to use. Here we are choosing MySQL 8.0 version.
Make sure you get a green tick icon indicating ClusterControl is able to connect to the database nodes to perform the deployment. Click on the "Deploy" button to start the deployment and you can monitor the deployment progress under Activity -> Jobs -> Create Cluster. You can monitor the creation status in the ClusterControl activity monitor.
Once the task is finished, you can see your new MySQL setup in the main ClusterControl screen.
And check your final topology in the Topology View Section.
Conclusion
ClusterControl features will allow you to quickly set up replication in a Hybrid Cloud environment, between different Cloud Providers, or even between a cloud provider and an On-prem environment. About the communication between the cloud providers, or between private and public cloud, for security reasons, you must restrict the traffic only from known sources, to reduce the risk of unauthorized access to your network.