You can add standby nodes to an existing cluster to scale your read workloads or increase high availability. You can also remove specific database nodes for targeted maintenance or permanent decommissioning to reduce cluster capacity.
Before you begin
- Make sure your cluster is in a healthy state and that
status.phaseisReady. - If you add a new node, verify that it meets the System requirements and has the required AlloyDB Omni components installed.
Add a database node
To add a new standby database node to your cluster, you must update both your deployment specification, also known as the inventory, and your database cluster resource specification.
To update the deployment specification, open your
deployment_spec.yamlfile and add the new node's IP address or hostname under theprimary_instance_nodesgroup.alloydbomni: children: primary_instance_nodes: hosts: db-node-1: db-node-2: NEW_NODE:Replace
NEW_NODEwith the IP address or hostname of the new standby node that you are adding.To update the resource specification, open your
DBClusterresource specification file and increment thenumberOfStandbysvalue by the number of nodes you are adding:DBCluster: metadata: name: DB_CLUSTER_NAME spec: # Other configurations omitted for brevity. # Modify the availability block in your existing DBCluster resource spec: availability: numberOfStandbys: NEW_STANDBY_COUNT # Remaining configurations omitted.Replace the following variables:
DB_CLUSTER_NAME: the name of your database cluster.NEW_STANDBY_COUNT: the new, incremented total number of standby nodes in your cluster.
Apply the updated resource specifications using either of the following methods. The RPM orchestrator automatically provisions the new node:
alloydbctlalloydbctl apply -d "DEPLOYMENT_SPEC_PATH" -r "DBCLUSTER_SPECIFICATION"Ansible
To apply the changes using Ansible, complete the following steps:
Create an
add.ymlplaybook with the following content:--- # Add AlloyDB Omni database nodes - name: Add AlloyDB Omni database nodes hosts: all become: true vars: ansible_user: ANSIBLE_USER ansible_ssh_private_key_file: PRIVATE_SSH_KEY_PATH roles: - role: google.alloydbomni_orchestrator.addReplace the following variables:
ANSIBLE_USER: the user with passwordless access to all nodes andsudopermissions.PRIVATE_SSH_KEY_PATH: the path to the private SSH key for passwordless authentication.
Run the created playbook:
ansible-playbook -i "DEPLOYMENT_SPEC_PATH" add.yml \ -e resource_spec="DBCLUSTER_SPECIFICATION"
Replace the following variables:
DEPLOYMENT_SPEC_PATH: the path to your deployment specification directory.DBCLUSTER_SPECIFICATION: the path to theDBClustermanifest that you modified.
Remove a specific database node
To remove a specific standby node from your cluster, you must remove it from the deployment specification and decrement the standby count.
To update the deployment specification, open your
deployment_spec.yamlfile and remove the target node's IP address or hostname from theprimary_instance_nodesgroup.To update the resource specification, open your
DBClusterresource specification file and decrement thenumberOfStandbysvalue:DBCluster: metadata: name: DB_CLUSTER_NAME spec: # Other configurations omitted for brevity. # Modify the availability block in your existing DBCluster resource spec: availability: numberOfStandbys: NEW_STANDBY_COUNT # Remaining configurations omitted.Replace the following variables:
DB_CLUSTER_NAME: the name of your database cluster.NEW_STANDBY_COUNT: the new, decremented total number of standby nodes in your cluster.
Apply the updated manifests using either of the following methods:
alloydbctlalloydbctl apply -d "DEPLOYMENT_SPEC_PATH" -r "DBCLUSTER_SPECIFICATION"Ansible
To apply the changes using Ansible, complete the following steps:
Create a
remove.ymlplaybook with the following content:--- # Scale-in database nodes from AlloyDB Omni cluster - name: Scale-In AlloyDB Omni Cluster (Logical Discovery & De-registration) hosts: all become: true vars: ansible_user: ANSIBLE_USER ansible_ssh_private_key_file: PRIVATE_SSH_KEY_PATH roles: - role: google.alloydbomni_orchestrator.removeReplace the following variables:
ANSIBLE_USER: the user with passwordless access to all nodes andsudopermissions.PRIVATE_SSH_KEY_PATH: the path to the private SSH key for passwordless authentication.
Run the playbook:
ansible-playbook -i "DEPLOYMENT_SPEC_PATH" remove.yml \ -e resource_spec="DBCLUSTER_SPECIFICATION"
Replace the following variables:
DEPLOYMENT_SPEC_PATH: the path to your deployment specification directory.DBCLUSTER_SPECIFICATION: the path to theDBClustermanifest that you modified.
Optional: Clean up the components on the removed node.
alloydbctlManually uninstall the AlloyDB Omni components to clean up the removed node.
Ansible
The Ansible orchestrator automatically cleans up the following components on the VM, if they are present:
- AlloyDB Omni
- AlloyDB Omni Monitor
- Node Manager
pgBackRestPgBouncerKeepalived