AWS MySQL RDS to RDS Migration (No Downtime)
Migrating a database is a daunting task. No engineer wants to the responsibility of taking down an application. So how does one migrate a large database with zero to minimal downtime?
There may be many solutions out there, here is my approach.
This is a great trick for migrating between AWS accounts, specifically.
Problem
A MySQL database used mostly for collecting raw metrics needs to be migrated with minimal downtime. On average there are two hours in the day when no new records are being written. The database is around 3 TB in size, and it needs to be migrated to a new AWS account.
We’ll call the source MySQL RDS (S1) and target MySQL RDS (T1).
Assumptions
- You have some bidirectional network setup between the two accounts, VPC Peering or Transit Gateway.
- Security groups on both RDS allow traffic to each other.
Easiest Solution (RDS -> MySQLDump -> RDS)
- Enable RDS binlog rention.
- Take a mysqldump
--master-data
option from S1 from an EC2 instance. - Import dump file from EC2 instance to T1.
- Enable Master/Slave replication from T1 to S1.
- Cut over the application to write to T1 instead when downtown is available. Note: You could also adopt this strategy with…