AWS RDS MySQL on Multi-AZ Test Failover

This is a diagram that I have used to deploy this lab.

Create your VPC with two different subnets on different AZs.

Create a Linux instance.

Copy it into the User data setting.

#!/bin/bash
yum update -y
yum install httpd -y
wget https://wordpress.org/latest.tar.gz
tar -zxf latest.tar.gz
amazon-linux-extras install php7.4 -y

Create a WordPress-SG Security Group.

SSH to the Linux instance, and check httpd, php is installed on the machine.

rpm -qa | grep httpd
rpm -qa | grep php
sudo yum install php -y
sudo systemctl start httpd
sudo systemctl enable httpd
netstat -antp

Copy all files on WordPress directory to /var/www/html.

cd wordpress
sudo cp -r * /var/www/html
cd /var/www/html

Check HTTP service is running on the Linux instance.

Next, create a database subnet on your Amazon RDS by using both AZs.

Create a new DS database.

Enable “Multi-AZ DB instance”.

Create a wordpress database, username, and passowrd.

Open http://44.205.13.154 on your web browser to set up WordPress.

Create a new wp-config.php under /var/www/html directory, and paste the information on the screen to this file. Click “Run the installation”

The master RDS MySQL instance is on the IP address 10.0.1.187 on Availability zone 2.

Run the command below to verify RDS MYSQL failover.

while true; do host wordpress.c60vdekov0up.us-east-1.rds.amazonaws.com ; sleep 1; done

Then select Actions-Reboot to reboot the RDS instance. Enable the “Reboot with Failover” option.

Wait for around 1 to 2 minutes and refresh the WP web link. The WordPress site will be offline for around 1 minute when doing RDS failover. It can be seen that the RDS MySQL Endpoint has changed from 10.0.2.187 to 10.0.0.254.

RDS Endpoint has updated with the new address is 10.0.0.254 on us-east-1a.

The master RDS MySQL instance is on the IP address 10.0.0.254 on Availability zone 1.

Checking the WordPress site.