Deploy and Failover to Secondary Cluster
In this article, we explore how to deploy a secondary cluster and failover with ClusterControl. A secondary cluster provides high availability and disaster recovery, ensuring minimal downtime in case of primary cluster failure.
Use cases
Deploying and failing over to a secondary cluster is useful in the following scenarios:
- Ensuring high availability in case of primary cluster failure.
- Implementing disaster recovery strategies for business continuity.
- Performing planned maintenance without downtime.
- Distributing read traffic across multiple clusters.
- Enabling quick recovery from unexpected infrastructure issues.
Deploying a Secondary Cluster
To deploy a Secondary Cluster from ClusterControl, first, you need to have a Primary cluster in place.
For this, follow the corresponding instructions here: Create Database Cluster.
After you have the Primary cluster deployed, go to ClusterControl GUI → Clusters → Cluster Actions → Clone/Replicate the cluster → Create replica cluster.
There, you can choose if you want to get data from a primary cluster or from an existing backup.
Replicate from Primary
- When replicating from a primary cluster, choose the node from where you are going to replicate data from and specify if it is a bidirectional replication.
- Configure the SSH credentials and security configuration.
- Specify the node configuration like server port, data directory, version, etc.
- Add the node IP address or hostname to be added to the secondary cluster.
Replicate from Backups
- When replicating from backups, choose the backup to be restored in the new cluster and specify if it is a bidirectional replication.
- Configure the SSH credentials and security configuration.
- Specify the node configuration like server port, data directory, version, etc.
- Add the node IP address or hostname to be added to the secondary cluster.
Clone cluster
In case you don't want to have the latest data replicated to the new cluster, you can just clone the existing cluster and keep it as a separated cluster for testing or datawarehousing.
For this, after you have the primary cluster deployed, go to ClusterControl → Clusters → Cluster Actions → Clone/Replicate the cluster → Clone cluster.
This will create a exact copy of the primary cluster without configuring a replication between the primary and the new cluster.
Failover
To failover to the Secondary cluster, you need to disable read-only to be able to write data on it, and change the endpoint to use the new cluster.
Note
If you are using a load balancer, depending on the configuration, most probably the endpoint change won't be necessary.
When the Primary cluster is back, if the replication configured between the clusters was bi-directional, the cluster will get the latest data when the replication lag reach 0. Otherwise, you have to rebuild the Primary cluster from the Secondary one and enable read-only after failover back, then update the endpoint again.
Cluster Replication Status using CLI
To see the Cluster replication status in the CLI, run:
You will get an output like this: