How to apply multi AZ and read replicas in RDS

Table of Contents

  1. Multi – AZ deployment
  2. Read Replicas
  3. Video Tutorial

In this blog, we are going to apply multi AZs and read replicas. In the previous session, we only used one AZ when creating a database instance

  1. Applying multi -AZ

First, search for the RDS in aws console and select it.

Figure 1: Searching for the RDS service

Then we will be prompted into the RDS dashboard. Under the resources select DB Instances.

Figure 2: Selecting DB Instances

Then select Create database

Figure 3: Selecting Create database

For the database creation method, select Standard Create.

Figure 4: Selecting a database creation method

Since we selected MySQL as the engine type in the previous session. For this session let’s select PostgreSQL.

Figure 5: Selecting an engine type

Then select a PostgreSQL version. We have selected PostgreSQL 11.6-R1. Then for the template type select Dev/Test.

Figure 6: Selecting the version and template type

Under settings you will be asked to give a DB instance identifier. Give a name of your preference.

Figure 7: Giving a DB instance identifier

For the credential settings, give a password and then confirm the password by retyping it.

Figure 8: Credential settings

As you may remember in the previous session, we selected the free tier. Hence, we only had the Burstable classes option. But, now we have 3 options. Let’s select Standard classes option and under this option select db.m4. large, which has a 5GiB RAM.

Figure 9: Selecting a DB instance size

Select General Purpose(SSD) as the Storage type. Then put 20GiB as the allocated storage. Disable Storage autoscaling.

Figure 10: Configuring storage settings

In order to deploy multi AZ, select the Create a standby instance option.

Next, let’s configure the additional connectivity settings. For the subnet, the group keeps the default subnet group. Then tick Yes for the public accessibility option. Then create a new VPC security group as we discussed in the previous session.

Figure 11: Availability and durability settings
Figure-12

Set Password authentication as the Database authentication method

Figure 13: Database authentication method selection

Then let’s configure the additional options. Give a name to the database in the initial database name. Keep the default option for the DB parameter group.

Figure 14: The database options

Enable the automatic backup and set it for 7 days. Select no preference as the backup window option. Tick the copy tags to the snapshots option.

Figure-15

Enable encryption by ticking the option. Then for the master key, keep the default value.

Figure 16: Enable encryption

Disable the performance insights, monitoring and log exports. But if you prefer these, make sure to enable them by ticking the relevant options.

Figure 17: Disabling the performance insights, monitoring and log exports facilities

Then for the maintenance settings, enable the auto updating by ticking the Enable auto minor version upgrade option. Select no preference as the maintenance window option.

At the end of the configurations, the estimated monthly costs are displayed. Then click the Create database icon.

Figure-18
Figure 19: Estimated monthly costs

Then you can see from the dashboard, that the database is creating. Refresh it, and you can see how the status is shown as modifying, then it will be displayed as configuring-enhanced –monitoring, and, finally, it will become available. This process is shown in figure 20

Figure 20: The process of database creation

 Look at our newly created database summary. It will show you the region and the AZ as us-east-1f.

Figure 21: The summary of newly created database

 Then click on Actions and select reboot.

Figure-22

Then it will ask about Reboot DB instances. Tick the Reboot with failover option and click Reboot.

Figure 23: Rebooting the database instance

Then again go to the summary and check the Region and AZ. Now it has changed to us-east-1a from us-east-1f.

This happened because we deployed multi-AZ. Amazon creates a primary DB Instance that will replicate the data to a standby instance. They both are synched, but they are at different availability zones. This will ensure the reliability of the DB instances.

Figure 24: The availability zone has changed

2. Read replicas

Real replicas also maintain a copy of the database instances same as Multi-AZ. But rather than high availability purposes, Read replicas are used read scalability.

Go to the database dashboard and select a database. Then go to the summary section. Click actions and select create read replica.

Figure 25: Creating read replica

First, we have to specify the instance. Then select db.t2.micro as the DB instance class and select no for the Multi-AZ deployment. Select General Purpose (SSD) as the storage type as shown in figure 26.

Figure-26

The next section is network and security. For this practical, we will select US East(N. Virginia) as the destination region. Keep the default destination DB subnet group as it is. Select the availability zone as us-east-1b. Select the no for the public accessibility. Let’s select an existing VPC security group.

Figure 27: Network and security configurations

The encryption is automatically enabled.

Figure 28: Encryption is automatically enabled

Select the replica source as the previously created database instance and give a name for your DB instance replica.

Figure 29:  Specifying the DB instance identifier

Enable the performance insights. Change the retention period as you prefer. Then select, create replica.

Figure 30: Performance insights

Now you can see the replica that we created is displayed in the dashboard. Check for the role. The database instances’ role is master, for the replica it’s replica.

Figure-31

Since the replica is still creating, until it is created we will make a connection between RDS and the DB instance. For this purpose, let’s use MySQL client. Select mypsg and copy the endpoint URL.

Figure 32:  Copying the endpoint URL

Then using the Add button, add mypsg. Give the URL as the server address. For the database type, select PostgreSQL. Give a password and test it. Once the test is successful, click save.

Figure-33

Open sqlectron and you can see the added server. Click connect

Figure 34: Mypsg is added

In the same way, add the replica as well. The steps are shown by the figure 35, 36 and 37.

Figure 35: Copying the replica endpoint
Figure 36: Adding the replica
Figure 37: Adding the server information
Figure 38:  Both the master and replica are added

Then open mypsg. You can see that the initial database we created: MyFirstpsg is inside mypsg.

Figure-39

Then open mypsg-replica. You can see that the initial database we created: MyFirstpsg is inside. So, the replica contains all the files in the master.

Figure 40: The replica

Video Tutorial

Leave a Reply

Your email address will not be published. Required fields are marked *