Creating, modifying, and deleting a database cluster group for Aurora
A database cluster group for Aurora is an Amazon RDS resource with its own settings: routing, the routing endpoint, backup retention, backup and maintenance windows, deletion protection, and tags. You create it with CreateDBClusterGroup, read it with DescribeDBClusterGroups, change it with ModifyDBClusterGroup, and delete it with DeleteDBClusterGroup. An engine version change runs in the group's maintenance window, not in each member cluster's window, unless you apply it immediately. Other setting changes take effect when Aurora accepts the request. For a minimal first group, see Getting started with database cluster groups for Aurora.
Creating a database cluster group for Aurora
Create the group first, because every member cluster attaches to it. Then add member clusters, as described in Adding and removing member clusters. If you use routing, enable it when you create the group or after you add member clusters.
Before you create a group
Check the following before you create the group:
-
Clusters. The clusters that you plan to add are in one AWS account and one AWS Region, and each runs a supported engine version. For the requirements, see Prerequisites for database cluster groups for Aurora.
-
Network layout and encryption. A cluster keeps its network settings and its KMS key when it joins, so place each cluster in the network layout that you want it to keep. The group has no KMS key of its own.
-
Routing endpoint subnets. If you plan to enable routing, choose the subnets, and with them the Availability Zones, of the routing endpoint first. You can't change the subnets after the routing endpoint exists. For more information, see Routing endpoint networking.
-
Versions and parameters. Align the engine versions and the parameters of the clusters that you plan to route to. The group doesn't change a member cluster to match the others.
-
Router users. A group without routing has no routing endpoint and needs no router user.
Create options
You can enable routing when you create the group, or later with ModifyDBClusterGroup. The following table lists the options of CreateDBClusterGroup (aws rds create-db-cluster-group).
| Option | What it sets |
|---|---|
--db-cluster-group-identifier (required) |
The group's name. The routing endpoint name is based on it. |
--engine (required) |
The member clusters' engine: aurora-mysql. |
--enable-routing |
Enables routing and creates the routing endpoint. For more information, see Enabling or disabling routing and changing the routing endpoint. |
--admin-username, --admin-user-password |
The group's admin user and its password. Both are required when you enable routing for the first time, and the request fails if you supply either one while routing is off. Always send them together. Pass the password in a --cli-input-json file so that it doesn't appear in your shell history. For the name and password rules, see Router users and routing layer privileges. |
--routing-endpoint-configuration |
The routing endpoint's network settings and its Parameters map. When you enable routing, include VpcSubnetIds. For the network settings, see Routing endpoint networking. For the parameters, see Configuring the routing endpoint. |
--backup-retention-period |
Days to keep the group's automated backups. The minimum is 1 day, and the value can't be longer than the backup retention period of any member cluster. The group's automated backups are on from the time that you create the group, and you can't turn them off. |
--preferred-backup-window |
The group's daily backup window. It can't overlap the maintenance window of the group or of any member cluster. |
--preferred-maintenance-window |
The weekly window in which pending group changes, such as an upgrade without --apply-immediately, start. |
--deletion-protection |
Protects the group from deletion. It's off by default for a new group. In the console, select Enable deletion protection when you create the group, or choose Modify to change it later. To require it on every new group, see Identity-based policy examples. |
--copy-tags-to-snapshot |
Copies the group's tags to its group snapshots. |
--tags |
Tags for the group. |
To create a database cluster group for Aurora
-
If you enable routing, put the administrator password in a JSON file that only you can read, on the host where you run the AWS CLI. For example, create
group-admin-password.jsonwith{"AdminUserPassword": ".PASSWORD"} -
With the console, the AWS CLI, or the Amazon RDS API, create the group, as shown in the tabs that follow this procedure. To create a group without routing, leave out
--enable-routing, the administrator options, and the routing endpoint configuration. -
On the same host, delete the password file.
-
With the AWS CLI, wait until the group reads
available, as described in Viewing a database cluster group for Aurora. Note the group's ARN fromDBClusterGroupArn. If you enabled routing, confirm the routing endpoint's subnets and security groups inRoutingEndpointConfigurationInfo.
To set routing endpoint parameters when you create the group, add a Parameters map to --routing-endpoint-configuration, as described in Configuring the routing endpoint. For the group's automated backups, see Backing up and restoring a database cluster group for Aurora.
Viewing a database cluster group for Aurora
Call DescribeDBClusterGroups (aws rds describe-db-cluster-groups).
aws rds describe-db-cluster-groups --regionREGION--db-cluster-group-identifierGROUP_IDENTIFIER
The response includes the following fields:
-
Status,PendingModifiedValues,DBClusterGroupArn, andDBClusterGroupResourceId -
RoutingEnabledandRoutingEndpointConfigurationInfo, with the routing endpoint'sVpcId,VpcSubnetIds,VpcSecurityGroupIds,Status,Port,NetworkType,Endpoint, andParameters. For an example, see Connectivity within a VPC. -
DBClusterGroupMembers, with each member cluster's ARN -
MinEngineVersionandMaxEngineVersion, the range of the member clusters' engine versions -
BackupRetentionPeriod,EarliestRestorableTime,LatestRestorableTime,AdminUsername, and the group's other settings
To read each member cluster's identifier, status, engine version, and upgrade wave (DBClusterGroupUpgradeWave), call DescribeDBClusters with --db-cluster-group-identifier.
Checking a group before applications use it
Run the following checks before you point an application at a new group, or after you add or remove a member cluster.
To check a database cluster group for Aurora
-
With the AWS CLI, call
DescribeDBClusterGroups, and check thatDBClusterGroupMemberslists every cluster that you added. -
In the same response, compare
MinEngineVersionandMaxEngineVersion. If they differ, see Upgrading a database cluster group for Aurora in waves. -
With routing, at the routing endpoint, read
dbclustergroup_sys.member_cluster_mappings, and check that it returns one row for each member cluster.SELECT member_cluster_alias, db_cluster_identifier FROM dbclustergroup_sys.member_cluster_mappings; -
With routing, at the routing endpoint, pin a session to one member cluster alias, and read a table that the member cluster holds. The pin statements follow this procedure.
At the routing endpoint, pin to the alias, read a table by its database name on the member cluster, and clear the pin.
SET SESSION router_cluster_pin = 'MEMBER_CLUSTER_ALIAS'; SELECT COUNT(*) FROMDATABASE.TABLE; SET SESSION router_cluster_pin = DEFAULT;
A pin needs no privilege for database cluster groups for Aurora, and it works as soon as routing is enabled, before you write any data mapping. The pinned session runs on the member cluster with the grants of the member cluster user of the same name. For more information, see Session pinning.
Changing group settings
To change the windows, backup retention, deletion protection, or snapshot tag copying, call ModifyDBClusterGroup (aws rds modify-db-cluster-group). The group reads modifying, then available. The same operation also changes routing (see the following section), the engine version (see Upgrading a database cluster group for Aurora in waves), and the admin user's password with AdminUserPassword (see Router users and routing layer privileges). Group settings don't change the member clusters' own backup and maintenance settings.
Modify the group only while its status is available; you can change deletion protection in any status except deleting. Send an engine version change, a routing change, and an admin user password change as separate requests. When you enable routing on a group that has no admin user, include the admin user name and password in the same request.
The operation that first gives the group an admin user requires both --admin-username and --admin-user-password, and the name can't be changed afterward.
Group setting changes apply to the group record. Only an engine version change runs on each member cluster, in waves. The group checks its settings against its member clusters: the backup retention period can't be longer than any member cluster's, and the backup window can't overlap a member cluster's maintenance window. To change the routing endpoint parameters, see Configuring the routing endpoint. A member cluster's upgrade wave is a setting of the member cluster, not of the group. You set it with --db-cluster-group-upgrade-wave when you add the cluster to the group. You can also change it later with ModifyDBCluster while the cluster is a member, as described in Assigning upgrade waves. The wave must be from 1 to 10.
--apply-immediately affects only an engine version change. With it, the upgrade starts as soon as Aurora accepts the request. Without it, the upgrade starts in the group's maintenance window. Every other group setting takes effect as soon as Aurora accepts the request, whether or not you pass --apply-immediately.
Moving the maintenance window also moves any pending change, so the pending change waits for the new window rather than the old one.
Enabling or disabling routing and changing the routing endpoint
Routing and the routing endpoint are group settings. AWS manages the routing layer and scales it automatically with your workload, so you don't size or configure it. The routing layer holds none of your table data.
Enabling or disabling routing
You can enable routing when you create the group, with --enable-routing on CreateDBClusterGroup, or later with --enable-routing on ModifyDBClusterGroup. When you enable routing, include VpcSubnetIds in --routing-endpoint-configuration. To disable routing, call ModifyDBClusterGroup with --no-enable-routing. Enabling routing doesn't move any connection: applications that connect directly to member clusters keep doing so until you change their connection settings.
When you disable routing, the group removes its routing endpoint settings, including the routing endpoint parameters, so supply them again when you enable routing. Disabling routing doesn't affect the member clusters, and applications can still connect to each member cluster through its own endpoint. Disabling routing ends every routed session.
Before you disable routing, wait for data movement jobs to finish, or cancel them. For more information, see Moving data between member clusters.
While Aurora enables or disables routing, the group reads modifying, then available when the change finishes. The routing endpoint has its own status in RoutingEndpointConfigurationInfo, which reads creating while routing is being enabled and deleting while it's being disabled.
Disabling routing and enabling it again keeps your data mappings, routing functions, scaleout tables, member cluster aliases, and router users.
To disable or enable routing
-
Before you disable routing, check that no application still uses it. At the routing endpoint, read the routing layer's session list (
dbclustergroup_sys.router_processlist). -
With the console, the AWS CLI, or the Amazon RDS API, change the routing setting, as shown in the tabs that follow this procedure.
-
With the AWS CLI, wait until the group reads
availablewith theRoutingEnabledvalue you set, before you make the next group change.aws rds describe-db-cluster-groups --regionREGION--db-cluster-group-identifierGROUP_IDENTIFIER\ --query 'DBClusterGroups[0].{Status:Status,RoutingEnabled:RoutingEnabled}' -
At the routing endpoint, after you enable routing and before traffic returns, pin a session to each member cluster alias and run one statement in the pinned session. Then clear the pin, and run one routed read per data mapping. The pin statements follow this procedure.
At the routing endpoint, pin to one alias, read its host name, clear the pin, and run one routed read.
SET SESSION router_cluster_pin = 'MEMBER_CLUSTER_ALIAS'; SELECT @@hostname; SET SESSION router_cluster_pin = DEFAULT; SELECT * FROMROUTER_DB.ROUTER_TABLELIMIT 1;
After you enable routing
After the group reads available with routing enabled, do the following before applications use the routing endpoint:
-
Find the routing endpoint. Read its name from
EndpointinRoutingEndpointConfigurationInfo. Don't build the name yourself. For more information, see Connecting with a client. -
Note the member cluster aliases. At the routing endpoint, read
dbclustergroup_sys.member_cluster_mappings, as in Viewing a database cluster group for Aurora. Every data mapping, pin, and move names a member cluster by its alias. A member cluster appears in the listing after the group finishes adding it, and the routing layer refuses a data mapping that names an alias that the listing doesn't show. Write no mapping until the listing shows every member cluster. -
Create router users. At the routing endpoint, create a router user for each database user that your applications connect with. Each router user needs a user of the same name on every member cluster that it must reach. For more information, see Router users and routing layer privileges.
-
Make objects reachable by name. Until a data mapping names the member cluster that holds an object, you reach that object only by pinning a session. A routed statement that the routing layer can't resolve doesn't run. An application that already partitions its own data can use pinned sessions before you write any mapping. To map your objects, see Data mappings and collocations.
Configuring the routing endpoint
You configure the routing endpoint with --routing-endpoint-configuration on CreateDBClusterGroup, ModifyDBClusterGroup, and the group restore operations, and read it back from RoutingEndpointConfigurationInfo in DescribeDBClusterGroups. For its network settings, see Routing endpoint networking. For the endpoint name, see Connecting to the routing endpoint.
Routing endpoint parameters
The Parameters field of --routing-endpoint-configuration sets how the routing layer behaves, for example which of its logs the group publishes. Each key is a parameter name and each value is a string. The map holds at most 100 entries. The routing layer has no parameter group: each parameter has one value for the whole group, with no value per user or per session. The parameter names and values are in Routing endpoint parameters.
The following rules apply to the Parameters map:
-
Partial updates. On
ModifyDBClusterGroup, the parameters that you name change, and the others keep their values, so send only what you change. To return a parameter to its default, set it to its default value. An empty map counts as not sent. -
Restores. A restored group doesn't take the source group's parameters. Pass them again on the restore operation. For more information, see Backing up and restoring a database cluster group for Aurora.
-
Invalid requests. A request with a name that the engine doesn't have, or a value outside the valid values, fails and changes nothing. The error lists every invalid name, and names the parameter and the reason for every invalid value.
-
JSON values. Use JSON, not AWS CLI shorthand, for a value that contains a comma or a space, such as a list of two or more members. Shorthand splits the value at the comma.
-
Stored form. The service stores a normalized value, which
DescribeDBClusterGroupsreturns. It removes leading and trailing spaces, and it sorts list members. It stores names and list members in the spelling shown in the parameter table, and numbers in plain form (010as10). For a parameter that takes0or1, it storestrue,false,on, andoffas1or0. The service refuses a list with a repeated or an empty member, such asaudit,auditoraudit,.
The following commands set a parameter when you create an Aurora MySQL group, and change one later.
aws rds create-db-cluster-group --regionREGION\ --db-cluster-group-identifierGROUP_IDENTIFIER--engine aurora-mysql \ --enable-routing --admin-usernameADMIN_USER\ --routing-endpoint-configuration '{"VpcSubnetIds":["SUBNET_1","SUBNET_2"],"Parameters":{"server_audit_events":"CONNECT,QUERY"}}' \ --cli-input-json file://group-admin-password.json aws rds modify-db-cluster-group --regionREGION--db-cluster-group-identifierGROUP_IDENTIFIER\ --routing-endpoint-configuration '{"Parameters":{"long_query_time":"5"}}'
DescribeDBClusterGroups returns the new values in RoutingEndpointConfigurationInfo.Parameters as soon as the modify call returns. The routing layer applies the change asynchronously, and the API doesn't report when it does.
DescribeDBClusterGroups returns every routing endpoint parameter of the engine, with the default value for each parameter that you didn't set. Changes to autocommit, sql_mode, time_zone, transaction_isolation, and long_query_time apply to connections that open after the routing layer applies the change, and open connections keep the values that they started with. Changes to enable_cloudwatch_logs_exports, server_audit_events, server_audit_excl_users, and server_audit_incl_users apply to open connections from their next statement.
Routing endpoint parameters apply to the routing layer only, in the following ways:
-
They don't change any member cluster parameter. Each member cluster keeps the values in its own DB cluster parameter group. For more information, see Parameter groups for Amazon Aurora.
-
enable_cloudwatch_logs_exportsin the map selects the routing layer logs that the group publishes. It isn't the--enable-cloudwatch-logs-exportsoption ofModifyDBCluster, which selects the logs of one member cluster, and neither setting changes the other. -
The map carries no statements to run when a session starts. An application that needs a session setting sends its own
SETstatement after it connects, or in its connection pool's initialization command. For the session variables, see Supported system variables. -
No parameter sets whether a session is pinned, and no parameter controls data movement. A data movement statement needs the
dbclustergroup_move_adminordbclustergroup_super_adminprivilege. For more information, see Session pinning and Moving data between member clusters.
Tagging a database cluster group for Aurora
Set tags with --tags when you create a group. To tag the group's automated backup in the same call, use --tag-specifications with the resource type cluster-group-auto-backup. That is the only resource type the create and group restore operations accept. To view or change tags later, call AddTagsToResource, ListTagsForResource, or RemoveTagsFromResource with the group's ARN from DBClusterGroupArn. With --copy-tags-to-snapshot, group snapshots get the group's tags. Member clusters keep their own tags. For more information, see Tagging Amazon Aurora andAmazon RDS resources.
Deleting a database cluster group for Aurora
Before you delete a group, remove every member cluster. If the group still has a member cluster, the delete fails. Deleting the group doesn't delete any cluster that was a member, and those clusters keep their data. On Aurora MySQL version 8.4.900, they have no DB instances outside a group. For the full order, see Tearing down a database cluster group for Aurora.
Neither a removal nor a delete checks the state of your data, so prepare the group first. Move the data that applications still need to member clusters that you keep, as described in Removing a cluster from a group, and check that no data movement runs. Deleting a group with routing also removes its routing endpoint, so point every application that uses it at the cluster endpoints of its member clusters. Decide which former member clusters you keep and whether you keep the group's automated backups.
To delete a database cluster group for Aurora
-
With the AWS CLI, check that
DescribeDBClusterGroupslists no member clusters, and that each removal is complete, as described in Removing a cluster from a group. If deletion protection is on, callModifyDBClusterGroupwith--no-deletion-protection. Otherwise the delete fails with the messageAurora can't delete cluster group with deletion protection enabled. -
With the console, the AWS CLI, or the Amazon RDS API, delete the group, as shown in the following tabs. By default, the delete also removes the group's automated backups. To keep them, add
--no-delete-automated-backups. For retained backups, see Retained automated backups.
Unless you keep them with --no-delete-automated-backups, the delete removes the group's automated backups, and with them every point in time that a group restore can use. You can't undo this.
For how long a kept automated backup lasts and how to restore it, see Retained automated backups. The delete doesn't remove or delete the member clusters or their instances, and it doesn't take a final snapshot of the group.
Manual group snapshots don't expire until you delete them. When you delete the group, the manual group snapshots that you took earlier continue to exist.
Routing endpoint parameters
The member clusters run Aurora MySQL, with engine value aurora-mysql and default port 3306. The routing layer's session list and the pin statements are in Enabling or disabling routing.
The routing endpoint parameters are shown in the following table. In the table, '' is the empty value, and a list parameter accepts any combination of its members, separated by commas. For how to set them, see Configuring the routing endpoint.
| Parameter | Valid values | Default | Description |
|---|---|---|---|
autocommit |
0 or 1 |
1 |
The autocommit mode that a session on the routing layer starts with. |
enable_cloudwatch_logs_exports |
'', audit, slowquery, or audit,slowquery |
'' |
The routing layer logs that the group publishes to Amazon CloudWatch Logs. '' publishes neither log. |
long_query_time |
0 to 31536000, to six decimal places |
10 |
The seconds that a statement must run before the routing layer records it in its slow query log. |
server_audit_events |
Any combination of CONNECT, QUERY, QUERY_DCL, QUERY_DDL, and QUERY_DML |
CONNECT,QUERY |
The statement classes that the routing layer records in its audit log. |
server_audit_excl_users |
'', or a comma-separated list of user names, up to 1,024 characters |
'' |
The users that the routing layer audit log leaves out. |
server_audit_incl_users |
'', or a comma-separated list of user names, up to 1,024 characters |
'' |
The users that the routing layer audit log records. The log records a user that's in both lists. When both lists are empty, it records every user. |
sql_mode |
'', or any combination of the MySQL SQL modes except NO_BACKSLASH_ESCAPES |
'' |
The SQL mode that a session on the routing layer starts with. |
time_zone |
A named time zone, such as UTC or America/New_York, or an offset such as +00:00. SYSTEM isn't accepted. |
+00:00 |
The time zone that a session on the routing layer starts with. |
transaction_isolation |
READ-UNCOMMITTED, READ-COMMITTED, REPEATABLE-READ, or SERIALIZABLE |
REPEATABLE-READ |
The isolation level that a session on the routing layer starts with. |
The routing layer records a statement in its slow query log when the statement runs longer than long_query_time. The group publishes the slow query log when enable_cloudwatch_logs_exports includes slowquery, and the audit log when it includes audit.
API reference
For the parameters, see the Amazon RDS API Reference.