Synchronize DR Environment with PROD Environment Using AWS
How to synchronize the Disaster Recovery (DR) environment with the Production (PROD) environment by hosting WordPress on both environments using AWS services.
The objective of this project is to synchronize the Disaster Recovery (DR) environment with the Production (PROD) environment by hosting WordPress on both environments using AWS services.
The Services used in this project :
- Amazon Certificate Manager (ACM)
- Route53 (R53)
- Relational Database Service (RDS)
- Identity and Access Management (IAM)
- Elastic Compute Cloud (EC2)
- Elastic Load Balancer (ELB)
- Simple Storage Service (S3)
TABLE OF CONTENTS
- STEP 1: Go to ACM — Amazon Certificate Manager
- STEP 2: Go to Route53
- STEP 3: Establish a connection between ACM and Route53
- STEP 4: Create two RDS for PROD and DR
- STEP 5: Create an IAM ROLE
- STEP 6: Create two EC2 Instances
- STEP 7: Create a Load Balancer
- STEP 8: Mapping Route53 and ELB
- STEP 9: Secure Connection to website
- STEP 10: Create two buckets on S3
STEP 1: Go to ACM — Amazon Certificate Manager
· Request a Certificate — Request a public certificate
STEP 2: Go to Route53
· Hosted zone — Create Hosted Zone –
STEP 3: Establish connection between ACM and Route53
STEP 4 : Create two RDS for PROD and DR
STEP 5: Create an IAM ROLE
STEP 6: Create two EC2 Instances
userdata
#!/bin/bash
yum install httpd php-mysql -y
amazon-linux-extras install -y php7.3
cd /var/www/html
echo "healthy" > healthy.html
wget https://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz
cp -r wordpress/* /var/www/html/
rm -rf wordpress
rm -rf latest.tar.gz
chmod -R 755 wp-content
chown -R apache:apache wp-content
wget https://s3.amazonaws.com/bucketforwordpresslab-donotdelete/htaccess.txt
mv htaccess.txt .htaccess
chkconfig httpd on
service httpd start
IN PROD ENV,
IN DR ENV,
Prod url — http://13.232.153.202/wp-admin/
Dr url — http://65.0.134.254/wp-admin/
Instance IP (PROD) — http://13.232.153.202/
Instance IP (DR) — http://65.0.134.254/
STEP 7: Create two Elastic Load Balancer
FOR PROD ENV,
FOR DR ENV,
Prod LB DNS — prodlb-978367993.ap-south-1.elb.amazonaws.com
DR LB DNS — drlb-761105092.ap-south-1.elb.amazonaws.com
STEP 8: Mapping Route53 and ELB
Hit web (chaimad.in — shows prod env), (dr.chaimad.in — shows dr env)
STEP 9: Secure Connection to website
For Prod ENV,
· Load Balancer — Listeners — change HTTP to HTTPS and SSL Certificate
https://chaimad.in/ = website changes to a secured connection
For DR ENV
https://dr.chaimad.in/ = website changes to a secured connection
STEP 10: Create two buckets on S3
· One for media files
· Another for code files
IN PRODUCTION Terminal:
Crontab -e
*/2 * * * * aws s3 sync - delete /var/www/html/wp-content/uploads s3://wp-media-chaimad
*/2 * * * * aws s3 sync - delete /var/www/html/ s3://wp-code-chaimad
IN DR Terminal:
Crontab -e
*/2 * * * * aws s3 sync - delete s3://wp-media-chaimad /var/www/html/wp-content/uploads
*/2 * * * * aws s3 sync - delete s3://wp-code-chaimad /var/www/html/
THE CONTENT IN PROD ENV WILL SYNC TO DR ENV using S3
Hit DR Instance IP it show PROD IP Content
OUTPUT:
I’m actively searching for new opportunities and eager to broaden my professional network.
Linkedin: https://www.linkedin.com/in/raj-kumar-devops/
Website: https://bento.me/rajdevops
For more Projects: https://medium.com/@rajdevops