Create Amazon Aurora DB Cluster for MySQL

Amazon Aurora is a fully managed relational database engine that is compatible with MySQL and PostgreSQL. Aurora has high-performance storage sub-systems, Hence MySQL and PostgreSQL databases engines can take advantage of fast distributed storage. The storage can automatically go up to 64 TB. Amazon Aurora also provides DB clustering and replication.

High Availability
When we set up the Aurora cluster, We will be having two endpoints.

Writer endpoint — which is used for reading and writing connections.
Reader endpoint — which is used for read-only connections.
We will also get the instance endpoints while we set up the aurora cluster.

If we are using instance endpoints in our applications, In case of failure we need to manually change the endpoints in the application code.

But with the Writer & reader endpoints, It is capable of managing DB instance failover automatically and also better than the instance endpoints.

If the primary DB instance fails, Aurora automatically failover to a new primary DB instance. It will either create a new primary DB instance or will promote the existing aurora replica to a new primary DB instance.

Creating amazon aurora DB cluster
Amazon Aurora DB cluster is compatible with both MySQL and PostgreSQL DB engines.

In this tutorial, We will set up the aurora DB cluster for the MySQL DB engine.

While creating a cluster, The DB cluster contains a primary writer DB instance and up to 15 reader DB instances (Read replica)

Read replicas can be either created in the same region as of master or we can create a read replica in different AWS regions with a latency of less than 1 second.

We can either use the existing VPC and the subnet group to create the Aurora DB cluster. Else we can,
1. Create a VPC with Public and Private subnets.

2. Create a Custom subnet group from the new VPC.

3. To create subnet groups, Login to the RDS console.

4. In the navigation pane, Choose Subnet groups

5. Click Create DB Subnet group provide a name for the subnet group and then choose the VPC that you have created.

For Add subnets, We must choose at least 1 subnet from different availability zones and then click Create

Now we start creating the aurora DB cluster for MySQL.

In the navigation panel, Choose Databases, Click Create database

In the Create database page, Choose a database creation method, For this guide, I am choosing Standard Create

For Engine options, Choose Amazon Aurora

For Edition, Choose Amazon Aurora with MySQL compatibility

For version, Choose the version of Aurora (MySQL) that is compatible with the application.

For Database Location,

If we choose Regional, Both the Writer and the reader endpoints will be created in the same AWS region.

If We choose Global, We have to Write the endpoint in one region and the replica (reader) in the different AWS regions.

For Database features,

One writer and multiple readers, In this scenario, We can maintain high availability by locating aurora replicas in different availability zones. Hence aurora automatically failover to new primary DB instance by promoting the read replica to the primary DB instance, In case of the primary DB instance failure.

Also, all the reader instance connects to the same storage volume.

Multiple Writers, All the DB instances will have read and write capability and they will be connecting to the same storage volume. If continuous write availability is required, This option is preferred.

Serverless, It automatically scales up and down the DB instances as per the application needs. It will also help to stop and start the DB cluster automatically when not required.

In this guide, I choose One writer and multiple readers

For Templates, Choose Production, For high availability, fast and consistent performance.

Under Settings, For DB cluster identifier, Provide a name for the DB cluster

For Credentials settings, Set a Master username and password.

For DB instance size, Choose the DB instance class as per your requirement.

For Availability & durability, As a DB cluster, We have to create a replica in a different availability zone, which will be a standby replica.

It will automatically failover in case of the primary failure.

For Connectivity, Choose the VPC that you have created.

Under Additional connectivity configuration, Choose the Subnet group that you have created.

For Publicly accessible, Choose No, It is always recommended to host the databases private. As we don’t want to expose the databases to the public network.

For the VPC security group, Create a new security group, Allowing port 3306 only to certain Instances or subnets.

For Database authentication, Choose Password authentication

Under Additional configuration

If required, We can configure the Backup strategy, Encryption, Monitoring, and Logging.

And finally, click Create database

The Aurora MySQL DB cluster is created.

If you click the identifier of the regional Role, Under Connectivity & Security, We can find Writer and reader endpoints.

We can use the reader and the writer endpoints with the applications.

Again from the main console, If you click the DB identifier of the Writer, We can find the Writer Instance endpoint.

If you click the DB identifier of the Reader (which will be in a different availability zone), We can find the Reader Instance endpoint.

To manually test the failover for the DB cluster.

Choose the identifier of Writer Role and Under Actions, Choose Failover

It will ask for confirmation, Choose Failover

You can find the Role of the instances is changed, But the endpoints remain the same.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store