Menu
Amazon Relational Database Service
User Guide (API Version 2014-10-31)

Migrating Data from a MySQL DB Instance to an Amazon Aurora DB Cluster by Using a Read Replica

Amazon RDS uses the MySQL DB engines' binary log replication functionality to create a special type of DB cluster called an Aurora Read Replica for a source MySQL DB instance. Updates made to the source MySQL DB instance are asynchronously replicated to the Aurora Read Replica.

We recommend using this functionality to migrate from a MySQL DB instance to an Aurora DB cluster by creating an Aurora Read Replica of your source MySQL DB instance. When the replica lag between the MySQL DB instance and the Aurora Read Replica is 0, you can direct your client applications to the Aurora Read Replica and then stop replication to make the Aurora Read Replica a standalone Aurora DB cluster. Be prepared for migration to take a while, roughly several hours per terabyte (TB) of data.

For a list of regions where Aurora is available, see Availability.

When you create an Aurora Read Replica of a MySQL DB instance, Amazon RDS creates a DB snapshot of your source MySQL DB instance (private to Amazon RDS, and incurring no charges). Amazon RDS then migrates the data from the DB snapshot to the Aurora Read Replica. After the data from the DB snapshot has been migrated to the new Aurora DB cluster, Amazon RDS starts replication between your MySQL DB instance and the Aurora DB cluster. If your MySQL DB instance contains tables that use storage engines other than InnoDB, or that use compressed row format, you can speed up the process of creating an Aurora Read Replica by altering those tables to use the InnoDB storage engine and dynamic row format before you create your Aurora Read Replica. For more information about the process of copying a MySQL DB snapshot to an Aurora DB cluster, see Migrating an RDS MySQL Snapshot to Aurora.

You can only have one Aurora Read Replica for a MySQL DB instance. You can only create Aurora Read Replicas for unencrypted MySQL DB instances.

Note

Replication issues can arise due to feature differences between Amazon Aurora and the MySQL database engine version of your RDS MySQL DB instance that is the replication master. If you encounter an error, you can find help in the Amazon RDS Community Forum or by contacting AWS Support.

For more information on MySQL Read Replicas, see Working with PostgreSQL, MySQL, and MariaDB Read Replicas.

Creating an Aurora Read Replica

You can create an Aurora Read Replica for a MySQL DB instance by using the console or the AWS CLI.

AWS Management Console

To create an Aurora Read Replica from a source MySQL DB instance

  1. Sign in to the AWS Management Console and open the Amazon RDS console at https://console.aws.amazon.com/rds/.

  2. In the navigation pane, choose Instances.

  3. Choose the MySQL DB instance that you want to use as the source for your Aurora Read Replica and choose Create Aurora Read Replica from Instance Actions.

    
                                Create Aurora Read Replica
  4. Choose the DB cluster specifications you want to use for the Aurora Read Replica, as described in the following table.

    Option Description

    DB Instance Class

    Choose a DB instance class that defines the processing and memory requirements for the primary instance in the DB cluster. For more information about DB instance class options, see DB Instance Class.

    Multi-AZ Deployment

    Choose Create Replica in Different Zone to create a standby replica of the new DB cluster in another Availability Zone in the target region for failover support. For more information about multiple Availability Zones, see Regions and Availability Zones.

    DB Instance Identifier

    Type a name for the primary instance in your Aurora Read Replica DB cluster. This identifier is used in the endpoint address for the primary instance of the new DB cluster.

    The DB instance identifier has the following constraints:

    • It must contain from 1 to 63 alphanumeric characters or hyphens.

    • Its first character must be a letter.

    • It cannot end with a hyphen or contain two consecutive hyphens.

    • It must be unique for all DB instances for each AWS account, for each region.

    Because the Aurora Read Replica DB cluster is created from a snapshot of the source DB instance, the master user name and master password for the Aurora Read Replica are the same as the master user name and master password for the source DB instance.

    VPC

    Select the VPC that will host the DB cluster. Select Create a New VPC to have Amazon RDS create a VPC for you. For more information, see DB Cluster Prerequisites.

    Subnet Group

    Select the DB subnet group to use for the DB cluster. Select Create a New DB Subnet Group to have Amazon RDS create a DB subnet group for you. For more information, see DB Cluster Prerequisites.

    Publicly Accessible

    Select Yes to give the DB cluster a public IP address; otherwise, select No. The instances in your DB cluster can be a mix of both public and private DB instances. For more information about hiding instances from public access, see Hiding a DB Instance in a VPC from the Internet.

    Availability Zone

    Determine if you want to specify a particular Availability Zone. For more information about Availability Zones, see Regions and Availability Zones.

    VPC Security Group(s)

    Select one or more VPC security groups to secure network access to the DB cluster. Select Create a New VPC Security Group to have Amazon RDS create a VPC security group for you. For more information, see DB Cluster Prerequisites.

    DB Cluster Identifier

    Type a name for your Aurora Read Replica DB cluster that is unique for your account in the target AWS Region for your replica. This identifier will be used in the cluster endpoint address for your DB cluster. For information on the cluster endpoint, see Aurora Endpoints.

    The DB cluster identifier has the following constraints:

    • It must contain from 1 to 63 alphanumeric characters or hyphens.

    • Its first character must be a letter.

    • It cannot end with a hyphen or contain two consecutive hyphens.

    • It must be unique for all DB clusters for each AWS account, for each region.

    Database Port

    Specify the port that applications and utilities will use to access the database. Aurora DB clusters default to the default MySQL port, 3306. Firewalls at some companies block connections to this port. If your company firewall blocks the default port, choose another port for the new DB cluster.

    DB Parameter Group

    Select a DB parameter group for the Aurora DB cluster. Aurora has a default DB parameter group you can use, or you can create your own DB parameter group. For more information about DB parameter groups, see Working with DB Parameter Groups.

    DB Cluster Parameter Group

    Select a DB cluster parameter group for the Aurora DB cluster. Aurora has a default DB cluster parameter group you can use, or you can create your own DB cluster parameter group. For more information about DB cluster parameter groups, see Working with DB Parameter Groups.

    Enable Encryption

    Not available.

    Priority

    Choose a failover priority for the DB cluster. If you don't select a value, the default is tier-1. This priority determines the order in which Aurora Replicas are promoted when recovering from a primary instance failure. For more information, see Fault Tolerance for an Aurora DB Cluster.

    Backup Retention Period

    Select the length of time, from 1 to 35 days, that Aurora will retain backup copies of the database. Backup copies can be used for point-in-time restores (PITR) of your database down to the second.

    Enable Enhanced Monitoring

    Choose Yes to enable gathering metrics in real time for the operating system that your DB cluster runs on. For more information, see Enhanced Monitoring.

    Monitoring Role

    The IAM role to use for Enhanced Monitoring. For more information, see Setting Up for and Enabling Enhanced Monitoring.

    Granularity

    Only available if Enable Enhanced Monitoring is set to Yes. Set the interval, in seconds, between when metrics are collected for your DB cluster.

    Auto Minor Version Upgrade

    Select Yes if you want to enable your Aurora DB cluster to receive minor MySQL DB Engine version upgrades automatically when they become available.

    The Auto Minor Version Upgrade option only applies to upgrades to MySQL minor engine versions for your Amazon Aurora DB cluster. It doesn't apply to regular patches applied to maintain system stability.

    Maintenance Window

    Select the weekly time range during which system maintenance can occur.

  5. Choose Create Read Replica.

AWS CLI

To create an Aurora Read Replica from a source MySQL DB instance, use the create-db-cluster and create-db-instance AWS CLI commands to create a new Aurora DB cluster. When you call the create-db-cluster command, include the --replication-source-identifier parameter to identify the Amazon Resource Name (ARN) for the source MySQL DB instance. For more information about Amazon RDS ARNs, see Amazon Relational Database Service (Amazon RDS).

Don't specify the master username, master password, or database name as the Aurora Read Replica uses the same master username, master password, and database name as the source MySQL DB instance.

For Linux, OS X, or Unix:

Copy
aws rds create-db-cluster --db-cluster-identifier sample-replica-cluster --engine aurora \ --db-subnet-group-name mysubnetgroup --vpc-security-group-ids sg-c7e5b0d2 \ --replication-source-identifier arn:aws:rds:us-west-2:123456789012:db:master-mysql-instance

For Windows:

Copy
aws rds create-db-cluster --db-cluster-identifier sample-replica-cluster --engine aurora ^ --db-subnet-group-name mysubnetgroup --vpc-security-group-ids sg-c7e5b0d2 ^ --replication-source-identifier arn:aws:rds:us-west-2:123456789012:db:master-mysql-instance

If you use the console to create an Aurora Read Replica, then Amazon RDS automatically creates the primary instance for your DB cluster Aurora Read Replica. If you use the AWS CLI to create an Aurora Read Replica, you must explicitly create the primary instance for your DB cluster Aurora Read Replica. The primary instance is the first instance that is created in a DB cluster.

Call the create-db-instance AWS CLI command to create the primary instance for your DB cluster. Include the name of the DB cluster as the --db-cluster-identifier parameter value.

For Linux, OS X, or Unix:

Copy
aws rds create-db-instance --db-instance-identifier sample-replica-instance \ --db-cluster-identifier sample-replica-cluster --engine aurora --db-instance-class db.r3.large

For Windows:

Copy
aws rds create-db-instance --db-instance-identifier sample-replica-instance ^ --db-cluster-identifier sample-replica-cluster --engine aurora --db-instance-class db.r3.large

Viewing an Aurora Read Replica

You can view the MySQL to Aurora replication relationships for your Aurora DB clusters by using the console or the AWS CLI.

AWS Management Console

To view the Aurora Read Replica for a MySQL DB instance

  1. Sign in to the AWS Management Console and open the Amazon RDS console at https://console.aws.amazon.com/rds/.

  2. In the navigation pane, choose Instances.

  3. Expand the MySQL DB instance and choose the Replication tab. The Aurora Read Replica information will be in the Deployment DB Clusters table in the row with a role of replica.

    
                                View Aurora Read Replica

To view the master MySQL DB instance for an Aurora Read Replica

  1. Sign in to the AWS Management Console and open the Amazon RDS console at https://console.aws.amazon.com/rds/.

  2. In the navigation pane, choose Clusters.

  3. Expand the DB cluster for the Aurora Read Replica and choose the Replication tab. The master MySQL DB instance information will be in the Replication Source field.

    
                                View MySQL master

AWS CLI

To view the MySQL to Aurora replication relationships for your Aurora DB clusters by using the AWS CLI, use the describe-db-clusters and describe-db-instances commands.

To determine which MySQL DB instance is the master, use the describe-db-clusters and specify the cluster identifier of the Aurora Read Replica for the --db-cluster-identifier option. Refer to the ReplicationSourceIdentifier element in the output for the ARN of the DB instance that is the replication master.

To determine which DB cluster is the Aurora Read Replica, use the describe-db-instances and specify the instance identifier of the MySQL DB instance for the --db-instance-identifier option. Refer to the ReadReplicaDBClusterIdentifiers element in the output for the DB cluster identifier of the Aurora Read Replica.

Example

For Linux, OS X, or Unix:

Copy
aws rds describe-db-clusters \ --db-cluster-identifier myreadreplicacluster
Copy
aws rds describe-db-instances \ --db-instance-identifier mysqlmaster

For Windows:

Copy
aws rds describe-db-clusters ^ --db-cluster-identifier myreadreplicacluster
Copy
aws rds describe-db-instances ^ --db-instance-identifier mysqlmaster

Promoting an Aurora Read Replica

After migration completes, you can promote the Aurora Read Replica to a stand-alone DB cluster and direct your client applications to the endpoint for the Aurora Read Replica. For more information on the Aurora endpoints, see Aurora Endpoints. Promotion should complete fairly quickly, and you can read from and write to the Aurora Read Replica during promotion. However, you can't delete the master MySQL DB instance or unlink the DB Instance and the Aurora Read Replica during this time.

Before you promote your Aurora Read Replica, stop any transactions from being written to the source MySQL DB instance, and then wait for the replica lag on the Aurora Read Replica to reach 0. You can view the replica lag for an Aurora Read Replica by calling the SHOW SLAVE STATUS command on your Aurora Read Replica and reading the Seconds behind master value.

You can start writing to the Aurora Read Replica after write transactions to the master have stopped and replica lag is 0. If you write to the Aurora Read Replica before this and you modify tables that are also being modified on the MySQL master, you risk breaking replication to Aurora. If this happens, you must delete and recreate your Aurora Read Replica.

After you promote, confirm that the promotion has completed by choosing Instances in the navigation pane and confirming that there is a Promoted Read Replica cluster to stand-alone database cluster event for the Aurora Read Replica. After promotion is complete, the master MySQL DB Instance and the Aurora Read Replica are unlinked, and you can safely delete the DB instance if you want to.

AWS Management Console

To promote an Aurora Read Replica to a DB cluster

  1. Sign in to the AWS Management Console and open the Amazon RDS console at https://console.aws.amazon.com/rds/.

  2. In the navigation pane, choose Instances.

  3. Choose the DB instance for the Aurora Read Replica and choose Promote Read Replica from Instance Actions.

    
                                Create Aurora Read Replica
  4. Choose Promote Read Replica.

AWS CLI

To promote an Aurora Read Replica to a DB cluster, use the promote-read-replica-db-cluster AWS CLI command.

Example

For Linux, OS X, or Unix:

Copy
aws rds promote-read-replica-db-cluster \ --db-cluster-identifier myreadreplicacluster

For Windows:

Copy
aws rds promote-read-replica-db-cluster ^ --db-cluster-identifier myreadreplicacluster

Related Topics