Deploying Amazon RDS Multi-AZ and Read Replica, Simulate Failover

In this practice lab, I am going to learn how to deploy an RDS Multi-AZ architecture. I will then create read replicas and simulate a failover of the RDS instance.

The objective of this practice lab is to help me understand how to make a database architect highly available through the use of read replicas and multi-AZ deployment.

I am therefore going to launch an Amazon Aurora RDS DB instance with multi-AZ enabled. After which I will simulate a database failover from one AZ to another.

NB: AWS Region selected for practice is: US East (N. Virginia) us-east-1

Possible causes of database failover

  • Failure of the host server
  • Modification of the database instance class
  • Rebooting of the database instance
  • Failure of an Availability Zone
  • RDS maintenance

Task Details

  • Sign into the AWS Management Console.
  • Launch an EC2 Instance
  • Create a Security Group for RDS instance
  • Create an Amazon Aurora database with Multi-AZ enabled
  • Connecting to the Aurora (MySQL) database on RDS
  • Connecting the EC2 Server to RDS
  • Execute Database Operations via SSH
  • Forcing a Failover to Test Multi-AZ
  • Testing the Failover Condition
  • Deleting AWS resources

Task 1: Signing in to AWS Management Console

Sign in with your log in details and set the region to US East (N. Virginia) us-east-1

Task 2: Launch an EC2 Instance

Navigate to EC2 on the management console. You can do that by using the search bar and just typing EC2 into it. You can also find EC2 by clicking on services and looking for "Compute" services. EC2 will be found under the list of compute services. You can then click on it.

  • Click on 'instances' and click on the Launch instance button.

  • Type MyRdsEc2server into the name input box.

image.png

  • Choose Amazon Linux 2 as your AMI

image.png

  • Select t2.micro as your instance type

image.png

  • Create new key pairs

image.png

Details should be as illustrated below. Click the create key pair button once you are done.

image.png

Your key pair will successfully be downloaded once it's done.

  • Under the Network settings, click on edit and make the following changes
    • Auto-assign public IP: Enable
    • Select Create new Security group
    • Security group name : Enter MyEC2Server_SG
    • Description : Enter Security for ec2 server to connect with RDS

image.png

  • Under the Advanced tab, look for user data and paste the code below into it
#!/bin/bash -ex 
yum install mysql -y
  • Leave all other things as default and click on launch instance. After a successful creation of the instance, you will find an interface like below. Click on the view all instances button to see the instance you just created.

image.png

You will then see the instance that you have created, as shown in the image below.

image.png

Create a security group for the RDS instance

  • Locate EC2 services as described earlier
  • On the left side bar, look for Network and Security

image.png

  • Click on Security Groups

image.png

  • Click on create security group button and provide details of the security group as below:

image.png

  • Under inbound rule, click on add rule button

image.png

  • Choose"MySQL/Aurora" for the type and enter 0.0.0.0/0 into the textbox after source.

image.png

  • Leave everything as default and click on the Create security group button

image.png

Task 4: Create an Amazon Aurora database with Multi-AZ enabled

  • Navigate to RDS under database services or just search for RDS in the search bar
  • Click on Databases on the left pane

image.png

  • Click on create database button. You will be greeted with a screen like below

image.png

  • Select standard create and make the choices as shown in the image below

image.png

  • Select Dev/Test as the template
  • Go ahead and make the following settings
    - Set a name for your DB cluster. In my case, I use **MyAuroraCluster** as the DB cluster identifier
    - Master Username: Enter **obedehoneah**
    - Master password: Enter **password123**
    - Confirm password: Enter **password123**
    

Note: This is the username and password used to log into your database. Please make note of them.

image.png

For the DB instance class, choose Burstable classes (includes t classes) and select db.t3.small instance.

image.png

  • For availability and durability, choose Create an Aurora Replica or Reader node in a different AZ image.png

  • Under connectivity, choose YES for public access

  • For security group, choose Existing Group then select the security group you created for the RDS instance. Remove the default security group that was created.

image.png

  • Under additional information, provide initial database name (eg: mylabrds) and uncheck encryption.

image.png

  • Leave all other settings as default and click on create database button

image.png

image.png

Task 5: Connecting to the Aurora (MySQL) database on RDS

We need to create an endpoint to enable us connect to the Aurora database.

  • Click on the RDS cluster name and then navigate to Connectivity & security to find the endpoint of your Master(Writer) and Reader instances, with which you can connect to your DB instance.

image.png

To be continued.

0
Subscribe to my newsletter

Read articles from Dr. Ehoneah Obed directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Dr. Ehoneah Obed
Dr. Ehoneah Obed

Heya! One thing I love doing is helping people and I believe one of the key ways I do this is through sharing of my knowledge and personal experiences. I have therefore decided to use this platform to share my knowledge and experience to people who may decide to take the path that I have taken. So, the question is, what is this path? I am professionally trained as a pharmacist but I have been an ardent lover and user of various technologies. During my practice at a tertiary hospital in the Northern Region of Ghana, I discovered a number of pertinent health problems and how technology can be used to solve those problems. In my quest for finding ways to solve some of these health problems with technology, I discovered the field of digital health and how that is transforming the way healthcare is being delivered. I am so much interested in the field and look forward to building a career in digital health and hopefully starting a company (startup) in that field. To make this career transition, I have to pursue further education and I have come across several paths that can lead to that career goal of mine. I have therefore decided to explore almost all the options that I have. For further studies, some of the courses which I came across that can help me achieve that career goal include a masters program or PHD in any of the following: Digital Health, Health technology, Health Informatics, Information Technology, Computer Science and Computational Science. I have therefore started applying to various schools offering any of the programs above. In the time being, I decided to start learning more about emerging technologies and that led me to take a three months course in Amazon Web Services (AWS). I am currently an AWS Certified Cloud Practitioner. During the 3 months training that I undertook at Ghana Tech Lab, Accra, I was introduced to a lot of things which excited me the more. I came to realize the potential of things I could do if I had the right knowledge especially in software development. Prior to this time, I had taught myself a number programming languages, libraries and frameworks for web development. I could consider myself as a fullstack developer with knowledge in HTML, CSS, Javascript, PHP, MySQL, WordPress, React, Laravel, and Codeigniter. However, I practiced less and didn't feel confident enough about my knowledge. I just knew I needed more. More learning, more practice, more projects and more connections with people in the industry. I started taking the Odin project to become a better web developer and a few days into it, I came across the ALX Software Engineering programme for Africans. Once I realized it was free to join, I was going to do everything in my capacity to qualify for it. I discovered the programme about 3 days to the deadline for the May 2022 Cohort. I therefore, sat through that night to finish my application to ALX. Fortunately for me, I got accepted into the program and a new phase of my life has started. I am now a Software Engineering Student looking forward to building a career in digital health. I know that this is just the beginning. As part of this programme, we spend about 70 hours a week learning, practicing, completing projects and building new relationships with our peers. As part of this journey, I am going to use this platform to document what I learn and share my journey to becoming a Software Engineer with you. Therefore, anyone at all looking to transition from their current career to software engineering will find what I post here relevant. Also, if you are a self-taught developer or you are thinking of teaching yourself software development, then you will also enjoy the content I publish here. Throughout my short journey of life, I have realized that we tend to give up on things easily when there is no form of accountability. I am therefore by this platform signing a deal to become accountable to you through sharing with you whatever I learn. Do share your thoughts and comments with me whenever you come across any of my post so I can truly remain accountable to you and never give up on this new found dream of mine.