GarlicBread
GarlicBread

Reputation: 2009

AWS Aurora: upgrading to serverless v2 from v1

I've been tasked with upgrading our AWS Aurora engine version from 11.16 to 15.2. We're running a Postgres-compatible engine.

As part of this upgrade, it's also been suggested that we upgrade from Serverless version 1 to Serverless version 2.

From https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-serverless-v2.upgrade.html#aurora-serverless-v2.upgrade-from-serverless-v1-procedure, it looks like I need to do the following:

  1. Upgrade Aurora from 11.16 to 13.9;
  2. Convert the Serverless v1 cluster to a provisioned Aurora PostgreSQL cluster;
  3. Modify the writer DB instance of the provisioned DB cluster to use the Serverless v2 DB instance class;
  4. Do a second upgrade of Aurora from 13.9 to 15.2.

I've read through the AWS documentation and it all seems to make sense until I get to point (3) above. The documentation sends me to https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-serverless-v2-administration.html#aurora-serverless-v2-converting-from-provisioned but within that section, it doesn't actually seem to explain what steps I need to take in order to modify the writer instance. There are links to other pages but I get increasingly lost.

Would anyone have an example of how to do step (3) above, please? Perhaps I'm looking for the wrong thing but I can find no examples of how to do this outside of the AWS documentation either.

Thanks in advance for any assistance.

Upvotes: 0

Views: 1991

Answers (2)

GarlicBread
GarlicBread

Reputation: 2009

In the end, we only upgraded to Aurora Postgres 13.9 with Serverless v2 due to restrictions in our region.

The process that we found worked was as follows:

  • Convert Postgres cluster from 11.16 to 13.9 (serverless v1)
  • Remove the Postgres 13.9 (serverless v1) cluster
  • Create a new Postgres 13.9 provisioned cluster
  • Add 3 provisioned DB instances (1 writer, 2 readers) to the provisioned cluster
  • Convert all three of the provisioned DB instances to serverless v2

Upvotes: 0

Jeremy Thompson
Jeremy Thompson

Reputation: 65654

I've spent a lot of time writing a library because RDS is tricky! They way the RDS console automates things takes ages to work out. Because deleting and restoring databases can take time and when you involve clusters the order of things gets even trickier, see the DeleteClusterAndInstance method in: https://github.com/MeaningOfLights/AWSUtils/blob/main/RDSOpsForPowershell.ps1

This is a rough guide of how to upgrade your Aurora cluster:

# Create a DB snapshot
aws rds create-db-snapshot --db-cluster-identifier <your-cluster-identifier> --db-snapshot-identifier <snapshot-identifier>

# Create a new Aurora cluster with version 13.9
aws rds create-db-cluster --db-cluster-identifier <new-cluster-identifier> --engine aurora-postgresql --engine-version 13.9 --snapshot-identifier <snapshot-identifier>

# Wait for the new cluster to be available
aws rds wait db-cluster-available --db-cluster-identifier <new-cluster-identifier>

# Restore data from the snapshot into the new cluster
aws rds restore-db-cluster-from-snapshot --db-cluster-identifier <new-cluster-identifier> --snapshot-identifier <snapshot-identifier>

Create a new RDS Cluster with the --engine-version 13.9 arg:

aws rds create-db-cluster --db-cluster-identifier <provisioned-cluster-identifier> --engine aurora-postgresql --engine-version 13.9 --engine-mode provisioned --db-instance-class <instance-class> --master-username <username> --master-user-password <password> --vpc-security-group-ids <security-group-ids> --availability-zones <availability-zones>

Then modify the writer DB instance of the provisioned cluster

aws rds modify-db-instance --db-instance-identifier <writer-instance-identifier> --db-cluster-identifier <provisioned-cluster-identifier> --db-instance-class <serverless-v2-instance-class>

You'll need to use a data migration tool like AWS Database Migration Service (DMS) or pg_dump/pg_restore to migrate the data, you'll see in my RDS Library I've got a script function InstallPostgresTools($S3Name), here's a DMS example:

# Create a DMS replication instance (if not already created)
aws dms create-replication-instance --replication-instance-identifier <replication-instance-identifier> --replication-instance-class <instance-class> --allocated-storage <storage-size>

# Create a DMS replication task
aws dms create-replication-task --replication-task-identifier <task-identifier> --source-endpoint-arn <source-endpoint-arn> --target-endpoint-arn <target-endpoint-arn> --migration-type full-load-and-cdc --table-mappings file://table-mappings.json

# Start the DMS replication task
aws dms start-replication-task --replication-task-arn <replication-task-arn>

Upvotes: 0

Related Questions