AWS RDS : Cross-Region Read Replicas for MySQL and Snapshots for PostgreSQL
Note this works only for MySQL not for Postgres DB!
Before a MySQL DB instance can serve as a replication source, we must enable automatic backups on the source DB instance by setting the backup retention period to a value other than 0. This requirement also applies to a Read Replica that is the source DB instance for another Read Replica. Automatic backups are supported only for Read Replicas running MySQL 5.6, not 5.1 or 5.5. (MySQL Read Replicas)
We can create cross-region read replicas for Amazon RDS database instances!
Cross-region replication allows a live replica to be created in one region, from a master in a different region.
We can use this feature to implement a cross-region disaster recovery model, scale out globally, or migrate an existing database to a new region:
- Migration Between Regions:
The replica could be used for the same purpose of moving a master server to a different region. In other words, the master could be migrated from one region to another with minimum downtime by first setting up a cross-region replica in the desired target region.
Once the target RDS instance had been created and synchronized to the master, we would disconnect the application from the old master, and then convert the new replica in the new region into a standalone master server, by choosing Promote Read Replica from Instance Actions in the console, which would sever the connection between the replica and its old master, and allow direct write access to it, since it would now be the new master.
- Improve Disaster Recovery:
We can operate a read replica in a region different from our master database region. In case of a regional disruption, we can promote the replica to be the new master and keep our business in operation.
- Scale Out Globally:
If our application has a user base that is spread out all over the planet, we can use Cross Region Read Replicas to serve read queries from an AWS region that is close to the user.
When we create a read replica, we specify an existing DB Instance as the source. Amazon RDS takes a snapshot of the source instance and creates a read-only instance from the snapshot. For MySQL and PostgreSQL, Amazon RDS uses those engines' native asynchronous replication to update the read replica whenever there is a change to the source DB instance. The read replica operates as a DB instance that allows only read-only connections; applications can connect to a read replica just as they would to any DB instance. Amazon RDS replicates all databases in the source DB instance.(Amazon RDS Read Replicas)
We can create up to five in-region and cross-region replicas per source with a single API call or a couple of clicks in the AWS Management Console. (Cross-Region Read Replicas for Amazon RDS for MySQL)
The cross-region replicas are very easy to create. We simply select the desired region (and optional availability zone) in the AWS Management Console:
The destination is set to "Tokyo":
We can check if we have the DB in Japan:
Reference: Cross-Region Read Replicas for Amazon RDS for MySQL.
Suppose we have Postgres DB, but the feature, Cross-Region Read Replicas, is not applicable to Postgres for copying it to another region. So, we want to take alternative approach which is to copy Amazon RDS (Relational Database Service) snapshots between AWS regions. In our case, from N. California to Japan.
Table source: Regions and Availability Zones.
We must create a DB snapshot before we can restore a DB instance from one.
We can initiate the copy from the AWS Management Console, the AWS Command Line Interface (CLI), or through the Amazon RDS APIs. Here's what we will see in the Console when we take a snapshot.
Then, go to RDS Dashboard:
Click "Copy Snapshot":
We can copy snapshots of any size, from any of the database engines (MySQL, Oracle, or SQL Server) that are supported by RDS. Copies can be moved between any of the public AWS regions, and we can copy the same snapshot to multiple Regions simultaneously by initiating more than one transfer.
As is the case with the other copy operations, the copy is done on an incremental basis, and only the data that has changed since the last snapshot of a given Database Instance will be copied. When we delete a snapshot, deletion is limited to the data that will not affect other snapshots.
As in the instruction, if we click "here", we get:
There is no charge for the copy operation itself; we pay only for the data transfer out of the source region and for the data storage in the destination region. We are not charged if the copy fails, but we are charged if we cancel a snapshot that is underway at the time.
Reference: Cross-Region Snapshot Copy for Amazon RDS.
Now, we need to restore the snapshot.
When we restore the DB instance, we provide the name of the DB snapshot to restore from, and then provide a name for the new DB instance that is created from the restore. We cannot restore from a DB snapshot to an existing DB instance; a new DB instance is created when we restore.
When we restore a DB instance, only the default DB parameter and security groups are associated with the restored instance. As soon as the restore is complete, we should associate the custom DB parameter or security group we used by the instance we restored from. We must apply these changes explicitly using the RDS console's Modify command, the ModifyDBInstance API, or the rds-modify-db-instance command line tool, once the DB instance is available.
In the navigation pane, click Snapshots, then click on the DB snapshot that we want to restore from.
Click Restore Snapshot, and the Restore DB Instance window appears as shown in the picture below
After typing the name of the restored DB instance in the DB Instance Identifier text box, click the restore DB Instance button.
AWS (Amazon Web Services)
- AWS : EKS (Elastic Container Service for Kubernetes)
- AWS : Creating a snapshot (cloning an image)
- AWS : Attaching Amazon EBS volume to an instance
- AWS : Adding swap space to an attached volume via mkswap and swapon
- AWS : Creating an EC2 instance and attaching Amazon EBS volume to the instance using Python boto module with User data
- AWS : Creating an instance to a new region by copying an AMI
- AWS : S3 (Simple Storage Service) 1
- AWS : S3 (Simple Storage Service) 2 - Creating and Deleting a Bucket
- AWS : S3 (Simple Storage Service) 3 - Bucket Versioning
- AWS : S3 (Simple Storage Service) 4 - Uploading a large file
- AWS : S3 (Simple Storage Service) 5 - Uploading folders/files recursively
- AWS : S3 (Simple Storage Service) 6 - Bucket Policy for File/Folder View/Download
- AWS : S3 (Simple Storage Service) 7 - How to Copy or Move Objects from one region to another
- AWS : S3 (Simple Storage Service) 8 - Archiving S3 Data to Glacier
- AWS : Creating a CloudFront distribution with an Amazon S3 origin
- AWS : Creating VPC with CloudFormation
- AWS : WAF (Web Application Firewall) with preconfigured CloudFormation template and Web ACL for CloudFront distribution
- AWS : CloudWatch & Logs with Lambda Function / S3
- AWS : Lambda Serverless Computing with EC2, CloudWatch Alarm, SNS
- AWS : Lambda and SNS - cross account
- AWS : CLI (Command Line Interface)
- AWS : CLI (ECS with ALB & autoscaling)
- AWS : ECS with cloudformation and json task definition
- AWS Application Load Balancer (ALB) and ECS with Flask app
- AWS : Load Balancing with HAProxy (High Availability Proxy)
- AWS : VirtualBox on EC2
- AWS : NTP setup on EC2
- AWS: jq with AWS
- AWS & OpenSSL : Creating / Installing a Server SSL Certificate
- AWS : OpenVPN Access Server 2 Install
- AWS : VPC (Virtual Private Cloud) 1 - netmask, subnets, default gateway, and CIDR
- AWS : VPC (Virtual Private Cloud) 2 - VPC Wizard
- AWS : VPC (Virtual Private Cloud) 3 - VPC Wizard with NAT
- DevOps / Sys Admin Q & A (VI) - AWS VPC setup (public/private subnets with NAT)
- AWS - OpenVPN Protocols : PPTP, L2TP/IPsec, and OpenVPN
- AWS : Autoscaling group (ASG)
- AWS : Setting up Autoscaling Alarms and Notifications via CLI and Cloudformation
- AWS : Adding a SSH User Account on Linux Instance
- AWS : Windows Servers - Remote Desktop Connections using RDP
- AWS : Scheduled stopping and starting an instance - python & cron
- AWS : Detecting stopped instance and sending an alert email using Mandrill smtp
- AWS : Elastic Beanstalk with NodeJS
- AWS : Elastic Beanstalk Inplace/Rolling Blue/Green Deploy
- AWS : Identity and Access Management (IAM) Roles for Amazon EC2
- AWS : Identity and Access Management (IAM) Policies, sts AssumeRole, and delegate access across AWS accounts
- AWS : Identity and Access Management (IAM) sts assume role via aws cli2
- AWS : Creating IAM Roles and associating them with EC2 Instances in CloudFormation
- AWS Identity and Access Management (IAM) Roles, SSO(Single Sign On), SAML(Security Assertion Markup Language), IdP(identity provider), STS(Security Token Service), and ADFS(Active Directory Federation Services)
- AWS : Amazon Route 53
- AWS : Amazon Route 53 - DNS (Domain Name Server) setup
- AWS : Amazon Route 53 - subdomain setup and virtual host on Nginx
- AWS Amazon Route 53 : Private Hosted Zone
- AWS : SNS (Simple Notification Service) example with ELB and CloudWatch
- AWS : Lambda with AWS CloudTrail
- AWS : SQS (Simple Queue Service) with NodeJS and AWS SDK
- AWS : Redshift data warehouse
- AWS : CloudFormation
- AWS : CloudFormation Bootstrap UserData/Metadata
- AWS : CloudFormation - Creating an ASG with rolling update
- AWS : Cloudformation Cross-stack reference
- AWS : OpsWorks
- AWS : Network Load Balancer (NLB) with Autoscaling group (ASG)
- AWS CodeDeploy : Deploy an Application from GitHub
- AWS EC2 Container Service (ECS)
- AWS EC2 Container Service (ECS) II
- AWS Hello World Lambda Function
- AWS Lambda Function Q & A
- AWS Node.js Lambda Function & API Gateway
- AWS API Gateway endpoint invoking Lambda function
- AWS API Gateway invoking Lambda function with Terraform
- AWS API Gateway invoking Lambda function with Terraform - Lambda Container
- Amazon Kinesis Streams
- AWS: Kinesis Data Firehose with Lambda and ElasticSearch
- Amazon DynamoDB
- Amazon DynamoDB with Lambda and CloudWatch
- Loading DynamoDB stream to AWS Elasticsearch service with Lambda
- Amazon ML (Machine Learning)
- Simple Systems Manager (SSM)
- AWS : RDS Connecting to a DB Instance Running the SQL Server Database Engine
- AWS : RDS Importing and Exporting SQL Server Data
- AWS : RDS PostgreSQL & pgAdmin III
- AWS : RDS PostgreSQL 2 - Creating/Deleting a Table
- AWS : MySQL Replication : Master-slave
- AWS : MySQL backup & restore
- AWS RDS : Cross-Region Read Replicas for MySQL and Snapshots for PostgreSQL
- AWS : Restoring Postgres on EC2 instance from S3 backup
- AWS : Q & A
- AWS : Security
- AWS : Security groups vs. network ACLs
- AWS : Scaling-Up
- AWS : Networking
- AWS : Single Sign-on (SSO) with Okta
- AWS : JIT (Just-in-Time) with Okta
Ph.D. / Golden Gate Ave, San Francisco / Seoul National Univ / Carnegie Mellon / UC Berkeley / DevOps / Deep Learning / Visualization