Table of Contents
- Multi – AZ deployment
- Read Replicas
- 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
- Applying multi -AZ
First, search for the RDS in aws console and select it.
Then we will be prompted into the RDS dashboard. Under the resources select DB Instances.
Then select Create database
For the database creation method, select Standard Create.
Since we selected MySQL as the engine type in the previous session. For this session let’s select PostgreSQL.
Then select a PostgreSQL version. We have selected PostgreSQL 11.6-R1. Then for the template type select Dev/Test.
Under settings you will be asked to give a DB instance identifier. Give a name of your preference.
For the credential settings, give a password and then confirm the password by retyping it.
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.
Select General Purpose(SSD) as the Storage type. Then put 20GiB as the allocated storage. Disable Storage autoscaling.
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.
Set Password authentication as the Database authentication method
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.
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.
Enable encryption by ticking the option. Then for the master key, keep the default value.
Disable the performance insights, monitoring and log exports. But if you prefer these, make sure to enable them by ticking the relevant options.
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.
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
Look at our newly created database summary. It will show you the region and the AZ as us-east-1f.
Then click on Actions and select reboot.
Then it will ask about Reboot DB instances. Tick the Reboot with failover option and click Reboot.
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.
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.
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.
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.
The encryption is automatically enabled.
Select the replica source as the previously created database instance and give a name for your DB instance replica.
Enable the performance insights. Change the retention period as you prefer. Then select, create replica.
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.
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.
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.
Open sqlectron and you can see the added server. Click connect
In the same way, add the replica as well. The steps are shown by the figure 35, 36 and 37.
Then open mypsg. You can see that the initial database we created: MyFirstpsg is inside mypsg.
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.