Adding and removing member clusters
In a database cluster group for Aurora, you add and remove member clusters one at a time. A cluster joins as it is: the group copies no data, and the cluster's endpoints don't change. When it leaves, it keeps its data and storage. On Aurora MySQL version 8.4.900, it has no DB instances outside a group. To move data onto or off a member cluster, you move collocations, as described in Moving data between member clusters and Rebalancing member clusters.
Adding a member cluster
You add an existing cluster or a new cluster with AddDBClusterToDBClusterGroup. On Aurora MySQL version 8.4.900, a DB cluster outside a group can't have DB instances, so it joins the group with none. The add restarts nothing, replaces nothing, and drops no connections.
Create the writer and readers after the cluster joins. To bring an existing Aurora MySQL 8.4 cluster, restore a snapshot of it onto version 8.4.900, then add the restored cluster. A restore onto 8.4.900 from an earlier major version, such as Aurora MySQL version 3, isn't supported.
Adding a member cluster is how you add capacity to the group. You size each member cluster with the same Aurora tools as a standalone cluster, and its instance classes, instance count, and readers stay under your control. AWS manages the routing layer and scales it automatically. Routed statements go to the writer instance of each member cluster, so readers that you add serve direct connections. A new member cluster holds no data that the routing layer uses until you map data to it or move data onto it. To spread load across member clusters, see Rebalancing member clusters.
Before you add a member cluster
Before you add a cluster, check the following:
-
Location and engine. The cluster is in the group's account and AWS Region, on the group's engine, at or above the group's minimum engine version, and not part of an Aurora global database. A cluster belongs to at most one group. If the engine version is earlier than that minimum, the add request fails with an
InvalidParameterValueerror. For the number of member clusters that a group can have, see Quotas for database cluster groups for Aurora. -
Network and encryption. Joining doesn't change the cluster's network settings or its KMS key. The group has no KMS key of its own. Every member cluster is in one zone group of the AWS Region, and adding a cluster from another zone group fails. A member cluster's Availability Zones also set where the routing layer runs, as described in Routing layer and routing endpoint. A new member cluster can also change the group's restorable window, as described in Backing up and restoring a database cluster group for Aurora.
-
Permissions. Adding a cluster needs permission on both the group and the cluster. For more information, see IAM and API permissions.
-
Users. Its member cluster users and grants match those on the other member clusters. For more information, see Router users and routing layer privileges.
-
Windows. Its maintenance window doesn't overlap the group's backup window.
-
Backup retention period. The cluster's backup retention period is at least the group's. An Aurora Serverless v2 cluster has a minimum capacity above 0 Aurora capacity units (ACUs). The cluster is
availableorcreating, isn't an Aurora Limitless Database cluster, and has no data groups. -
Parameter groups. The group doesn't check or align parameter groups. Through the routing endpoint, the routing layer sets
sql_mode,time_zone,autocommit,transaction_isolation,auto_increment_increment, character set, and the session timeoutswait_timeout,interactive_timeout, andnet_write_timeouton every member session. Member cluster parameter group values for these settings don't apply to routed sessions. Keep other parameters that affect how a statement is interpreted the same on every member cluster yourself.
Adding a cluster in place
Add one cluster at a time, and confirm each join before you map or move data onto it.
To add a member cluster in place
-
On the cluster and on each member cluster (direct, through each cluster endpoint), read the settings that must match. The statements follow this procedure.
-
With the AWS CLI, if the cluster's maintenance window overlaps the group's
PreferredBackupWindow, callModifyDBClusterwith--preferred-maintenance-window. -
With the console, the AWS CLI, or the Amazon RDS API, add the cluster to the group with its upgrade wave, from 1 to 10, as shown in the first set of tabs. A cluster that you don't assign to a wave goes in the first wave.
-
With routing, at the routing endpoint, read
dbclustergroup_sys.member_cluster_mappingsuntil the new cluster's row appears. Use that row'smember_cluster_alias, never the cluster identifier, in every mapping, pin, and move. Until the row appears, the routing layer refuses a data mapping that names the new member cluster.SELECT member_cluster_alias, db_cluster_identifier FROM dbclustergroup_sys.member_cluster_mappings; -
With routing, at the routing endpoint and outside a transaction, pin a session to the new alias, run one statement, and clear the pin.
-
At the routing endpoint, place data on the new member cluster: write data mappings for the objects that it holds, as described in Data mappings and collocations, or move collocations onto it, as described in Moving data between member clusters.
Step 1. On each cluster (direct), read the settings that must match.
SELECT @@aurora_version, @@sql_mode, @@time_zone, @@character_set_server, @@collation_server, @@lower_case_table_names, @@log_bin, @@binlog_format, @@binlog_row_image;
Step 5. At the routing endpoint, pin, read the host name, and clear the pin.
SET SESSION router_cluster_pin = 'MEMBER_CLUSTER_ALIAS'; SELECT @@hostname; SET SESSION router_cluster_pin = DEFAULT;
The add is complete when DescribeDBClusterGroups lists the cluster, the group reads available, and, with routing, a pin to the alias answers.
Removing a member cluster
A member cluster can leave the group. The cluster keeps its storage, its data, and its own automated backups. Group snapshots taken before the removal keep the cluster's data. The cluster's own automated backups expire according to the cluster's retention period, and deleting the group's automated backups later doesn't delete them.
A removal closes each open routed session whose last routed statement went to the removed member cluster, without an error. The client sees a closed connection on its next statement, for example error 2013 on Aurora MySQL. Routed sessions whose last statement went to another member cluster stay open. Reconnect the closed sessions.
A removal makes no check on data movement, data mappings, or routing rules, and it always acts as a forced removal. It interrupts a data movement in progress on the cluster. The data mappings that name the cluster stay in the group, and a statement that reaches one of them fails, because no member cluster resolves for it. Prepare the cluster's data before you remove it, as the following section describes.
If the member cluster runs Aurora MySQL version 8.4.900, the removal fails with an InvalidDBClusterStateFault error until you delete the cluster's DB instances. The cluster then leaves the group with its storage and backups but no DB instances.
Removing a cluster from a group
If the cluster holds data that applications reach through the routing endpoint, handle that data first in one of the following ways:
-
Keep the data on the cluster. Point those applications at the cluster's own endpoints, then delete the data mappings that name its member cluster alias. The delete removes the routing entry, not the data. For more information, see Sending traffic through the routing layer.
-
Keep the data in the group. Move the cluster's collocations to other member clusters with data movement. The move drops the source copy when it completes. For more information, see Moving data between member clusters.
You can't delete a scaleout table's mapping rows while the scaleout table exists. If the cluster holds member tables of a scaleout table, move those collocations to other member clusters. Before you begin, take a backup, and export the data mappings, member cluster list, and scaleout definitions, as described in Exporting the mappings before and after a change. Without routing, or if no data mapping names the cluster, go straight to step 6.
To remove a member cluster
-
With routing, at the routing endpoint, check that no job in
dbclustergroup_data_movement.move_inforeadsRunning. -
At the routing endpoint, list the rows that name the cluster's alias, by
router_collocation_group.SELECT * FROM dbclustergroup_sys.data_mappings WHERE member_cluster_alias = 'MEMBER_CLUSTER_ALIAS'; -
At the routing endpoint, move each collocation that stays in the group to a remaining member cluster with capacity for it, one job at a time, scaleout collocations included. A statement that reaches two collocations stops working when they're on different member clusters.
-
For the data that you keep on the cluster, in each application's configuration, point the connections at the cluster's own endpoints.
-
At the routing endpoint, read the data mappings again, and delete each remaining row that names the alias, one at a time, with an exact single-row
WHERE. The statements follow this procedure. -
With the console, the AWS CLI, or the Amazon RDS API, remove the cluster from the group, as shown in the first set of tabs after this procedure.
Step 3. At the routing endpoint, move one collocation.
ALTER DBCLUSTERGROUP MOVE COLLOCATION `COLLOCATION_GROUP` FROM `MEMBER_CLUSTER_ALIAS` TO `TARGET_ALIAS`;
Step 5. At the routing endpoint, delete one database-level mapping row that names the alias.
DELETE FROM dbclustergroup_sys.data_mappings WHERE router_db_name = 'ROUTER_DB';
After the removal, keep the cluster, delete it as described in Deleting Aurora DB clusters and DB instances, or add it to a group again. You can't delete a cluster while it's a member of a group. At the routing endpoint, check that a routed read for each moved collocation returns the expected data. If a move is refused, see Troubleshooting data moves and schema changes.
Tearing down a database cluster group for Aurora
Before you begin, export the data mappings and definitions, as described in Exporting the mappings before and after a change. Take a snapshot of each member cluster that you might need, and stop application traffic to the routing endpoint.
To tear down a database cluster group for Aurora
-
At the routing endpoint, drop the scaleout tables, children before parents, and then the routing functions. The member tables and their data stay.
DROP SCALEOUT TABLEROUTER_DB.TABLE; DROP SCALEOUT ROUTING FUNCTIONROUTING_FUNCTION; -
At the routing endpoint, delete the remaining data mapping rows one at a time, with an exact match, until
dbclustergroup_sys.data_mappingsreturns no rows. ADELETEwithoutWHEREremoves every mapping that no scaleout table uses, up to 1,000 rows per statement. Mappings that scaleout tables use stay. Always give aDELETEaWHEREclause. -
With the AWS CLI, remove each member cluster, one at a time, as described in Removing a cluster from a group, until the group lists no member clusters.
-
With the AWS CLI, delete the group, as described in Deleting a database cluster group for Aurora.
-
On each member cluster (direct), drop any databases that you created only for the group. Delete the clusters that you don't need, as described in Deleting Aurora DB clusters and DB instances.
You can't delete a mapping row that a scaleout table uses until you drop that scaleout table.
API reference
For the parameters, see the Amazon RDS API Reference.