How do I create a read replica for an Amazon Aurora MySQL DB instance?

Last updated: 2020-12-09

I have an Amazon Aurora MySQL cluster. I would like to create either an in-Region or cross-region read replica for my Aurora DB cluster. How can I do this?

Short description

You can use Amazon Aurora replicas as failover targets. This means that if your primary DB instance fails, an Aurora replica is then promoted to the primary instance. Creating a cross-Region read replica improves your availability in case of a rare Amazon RDS Region failure.

Aurora replicas also work well for read scaling because they are fully dedicated to read operations on your cluster volume. The primary instance manages write operations. Because all of the DB instances in your cluster share the cluster volume, copying the data for each Aurora replica requires minimal work.

Note: Aurora replicas do not use binary log replication (which is used by RDS MySQL read replicas). Because of this, lag is usually less than 100 milliseconds after the primary instance has written an update. This is an advantage of using Amazon Aurora, because replication lag is typically low and predictable compared to MySQL based replication. If you have diverse read traffic across Regions, the cross-Region replicate feature is useful.

Use the steps in this article to create either an in-Region or cross-Region read replica for your Aurora MySQL DB cluster.

Note: These steps do not apply to Aurora Serverless or Aurora multi-master clusters.


Note: If you receive errors when running AWS Command Line Interface (AWS CLI) commands, make sure that you’re using the most recent AWS CLI version.

Create an in-Region read replica for an Aurora MySQL cluster using the Amazon RDS console

Note: You can't create an encrypted Aurora Replica for an unencrypted Aurora DB cluster. You can't create an unencrypted Aurora Replica for an encrypted Aurora DB cluster.

1.    Open the Amazon RDS console, and choose Databases from the navigation pane.

2.    Choose the DB cluster that you want to add the new DB instance to.

3.    In the Actions section, choose Add reader.

4.    On the Add reader page, customize the options for your Aurora replica.

5.    Choose Add reader to create the replica.

Create an in-Region read replica for an Aurora MySQL cluster using the AWS CLI

To create an Aurora Replica in your DB cluster using the AWS CLI, run the create-db-instance command. Include the name of the DB cluster using the --db-cluster-identifier option. You can also specify an Availability Zone (AZ) for the Aurora replica using the availability-zone parameter.

This example command creates a read replica for Aurora MySQL (same Region and Aurora MySQL 5.7 compatible).

Linux, macOS, or Unix:

aws rds create-db-instance --db-instance-identifier sample-instance-us-west-2a \
    --db-cluster-identifier sample-cluster --engine aurora-mysql --db-instance-class db.r4.large \
    --availability-zone us-west-2a


aws rds create-db-instance --db-instance-identifier sample-instance-us-west-2a ^
    --db-cluster-identifier sample-cluster --engine aurora-mysql --db-instance-class db.r4.large ^
    --availability-zone us-west-2a

Note: If you want to create a read replica for an Aurora MySQL 5.6 compatible cluster, modify the --engine parameter to --engine aurora in this command.

Create a cross-Region read replica for an Aurora MySQL cluster

Creating a read replica in an AWS Region that is different to the source DB cluster has some advantages. This can improve your disaster recovery capabilities and let you scale read operations into a Region closer to your users. It can also make it easier for you to migrate from one AWS Region to another.

Note: Before you can create a cross-Region read replica, enable binary logging on your source Aurora MySQL DB cluster. Cross Region-replication uses MySQL binary replication to replay changes on the cross-Region read replica cluster.

Enable binary logging on your DB cluster

1.    To enable binary logging on your DB cluster,

2.    Update the binlog_format parameter for your source DB cluster. This is a cluster-level parameter that is in the default cluster parameter group.

3.    If your DB cluster uses the default DB cluster parameter group, create a new DB cluster parameter group to modify the binlog_format settings.

4.    It's a best practice to set the binlog_format to MIXED. You can also set binlog_format to ROW or STATEMENT if you need a specific binlog format.

5.    Reboot your Aurora DB cluster for changes to take effect.

Create a cross-Region cluster using the Amazon RDS console

1.    Open the Amazon RDS console and then choose the AWS Region that hosts your source DB cluster.

2.    From the navigation pane, choose Instances.

3.    Choose the check box for the DB instance that you want to create a cross-Region read replica for.

4.    For Actions, choose Create cross region read replica.

5.    On the Create cross region read replica page, choose the option settings for your cross-Region read replica DB cluster.

Create a cross-Region cluster using AWS CLI

Creating a cross-Region cluster using the AWS CLI is a two step process. First, create the cluster itself in the target Region using the create-db-cluster call. Then, use the create-db-instance call to create the reader instance.

This example creates a cross Region replica using Linux, macOS or Unix and is Aurora MySQL 5.6 compatible.

1.    Create the cluster by running a command similar to the following:

aws rds create-db-cluster \
  --db-cluster-identifier sample-replica-cluster \
  --engine aurora \
  --replication-source-identifier arn:aws:rds:us-west-2:123456789012:cluster:sample-master-cluster

2.    Verify if the cluster is available:

aws rds describe-db-clusters --db-cluster-identifier sample-replica-cluster

3.    Create the reader:

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

To create the same using CLI on Windows, use the same steps, but use the ^ symbol as line delimiter instead of \.