In this blog post , We will learn how to create amazon aurora db cluster for MySQL using aws console.
Create RDS instances using aws console
Create RDS Instance using Terraform
Create Read replica for RDS DB instances
What is Aurora?
Amazon Aurora is a fully managed relational database engine which is compatible of MySQL and PostgreSQL.
Aurora has a high performance storage sub-systems, Hence MySQL and PostgreSQL databases engines can take advantages of fast distributed storage.
The storage can automatically scale up to 64 TB.
Amazon Aurora also provides DB clustering and replication.
When we setup Aurora cluster , We will be having two endpoints.
- Writer endpoint – which is used for read and write connections.
- Reader endpoint – which is used for read-only connections.
We will also get the instance endpoints while we setup 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 fail over to a new primary DB instance.It will either create a new primary DB instance or It will promote the existing aurora replica to 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 setup aurora DB cluster for MySQL DB engine.
While creating a cluster , The DB cluster contains a primary writer DB instance and upto 15 reader DB instances (Read replica)
Read replicas can be either created in the same region as of master or we can create red replica in different AWS region with the 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,
Create a VPC with Public and Private subnets
Create Custom subnet group from new VPC.
To create subnet groups , Login to RDS console.
In the navigation pane , Choose Subnet groups
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 atleast 1 subnet from different availability zones and then click Create
Now we start creating the aurora DB cluster for MySQL.
In the navigation pane , 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 have Write endpoint in one region and the replica (reader) in the different aws region.
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 fail over to new primary DB instance by promoting the read replica to 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 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 helps to stop and start 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 different availability zone , which will be a standby replica.
It will automatically fail over 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 VPC security group , Create a new security group , Allowing port 3306 only to the certain Instances or subnets.
For Database authentication , Choose Password authentication
Under Additional configuration
If required , We can configure 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 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 the confirmation , Choose Failover
You can find the Role of the instances are changed , But the endpoints remain the same.
We have successfully created the Aurora DB cluster for MySQL using AWS console and also we have manually tested the fail over of the DB instances.
Hope you find it helpful.
Please check out my other articles.