To help ensure high availability (HA), every AlloyDB primary instance has both an active node and a standby node, located in two different zones. If the active node becomes unavailable for any reason, then AlloyDB automatically fails over the primary instance to its standby node, making it the new active node.
You can manually fail over your primary instance to its standby node at any time, even if the active node is working normally. When you initiate a manual failover, AlloyDB takes these steps, in this order:
AlloyDB takes the primary node offline.
AlloyDB turns the standby node into the new active node.
AlloyDB reactivates the previous active node as the new standby node.
In effect, manual failover swaps the active and standby roles of your primary instance's two nodes. You can trigger a manual failover any time that you want this exchange to occur.
For example, imagine that you have a primary instance whose active and standby
nodes reside in the
us-central1-b zones, respectively. An
us-central1-a triggers an automatic failover, resulting in the
us-central1-b zone hosting the active node. If you prefer to keep the active
node in the
us-central1-a zone, then you can initiate a manual failover to
have AlloyDB swap the primary instance's nodes back to their
locations from before the outage.
Because manual failover is an intentional and controlled procedure, it is not intended for simulating unexpected hardware or network faults. Instead, you can test your primary instance's high availability through fault injection.
Before you begin
- The Google Cloud project you are using must have been enabled to access AlloyDB.
- You must have one of these IAM roles in the Google Cloud project you are using:
roles/alloydb.admin(the AlloyDB Admin predefined IAM role)
roles/owner(the Owner basic IAM role)
roles/editor(the Editor basic IAM role)
If you don't have any of these roles, contact your Organization Administrator to request access.
Perform a manual failover
- Go to the Clusters page.
In the Resource Name column, click a cluster name.
In the Instances in your cluster section, open your primary instance'sInstance actions menu.
In the dialog that appears, enter the instance's ID.
Click Trigger failover.
gcloud alloydb instances
gcloud alloydb instances failover INSTANCE_ID \ --region=REGION_ID \ --cluster=CLUSTER_ID \ --project=PROJECT_ID
Replace the following:
INSTANCE_ID: The ID of the instance.
REGION_ID: The region where the instance is placed.
CLUSTER_ID: The ID of the cluster where the instance is placed.
PROJECT_ID: The ID of the project where the cluster is placed.
To confirm that the failover worked, follow these steps:
Before performing the failover, note the zones of the primary instance's nodes.
After running the failover, note the two nodes' new zones.
Confirm that the zones of the active and standby nodes have switched places.