일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- data analyze
- webcrawling
- 크롤링
- data
- adaptive life cycle
- opencv
- 다나와
- 자바스크립트
- pandas
- visualizing
- keras
- python
- 프로젝트
- Crawling
- algorithm
- Agile
- AWS
- javascript
- Method
- ECS
- tensorflow
- Project
- matplotlib
- DANAWA
- TypeScript
- angular
- instance
- 애자일
- analyzing
- Scrum
- Today
- Total
LiJell's 성장기
Migrating from MySQL to Amazon Aurora 본문
I have migrated RDS from MySQL to Amazon Aurora Serverless V2 by using Aurora read replica and blue/green deployment. It was a big challenge for me, but I made it! I hope my experience will help you out :)
What is Amazon Aurora (Aurora)?
- AWS Aurora is a cloud based relational database engine that compatible with MySQL and PostgreSQL.
Why Aurora?
- Up to five times faster than regular MySQL
- Optimized on cloud environment
- The database storage and compute are separated
- The data remains safe, even if all of the DB instances in the cluster become unavailable.
- Aurora use Quorum model
Aurora data
- In a single AWS Region, aurora stores copies of the date in a DB cluster across multiple AZ
- When the primary DB instance gets a request write, Aurora synchronously replicates the data across AZ to six storage nodes associated with cluster volume. According to AWS, it will provide data redundancy, eliminate I/O freezes, and minimizes latency spikes during system backups.
Aurora DB instances
- You can create up to 15 read-only Aurora Replicas for single-master replication.
- Fail over
- One of the reader instances, usually tier 0–1, takes over as the primary instance when the primary instance gets in trouble.
Aurora global databases
- Setting up Aurora global databases on multiple AWS Regions enables low latency global reads and disaster recovery from outages across an AWS Region.
Fault tolerance
- DB clusters can tolerate a failure of an Availability Zone without any loss of data and only a brief interruption of service since each AZ contains a copy of the cluster volume data.
- According to AWS, there are two ways.
By promoting an existing Aurora Replica to the new primary instance
By creating a new primary instance
Plan
My goal was migration to AWS Aurora Serverless V2, and the workflow was like below.
- RDS >> Aurora Provisioned >> Aurora Serverless V2
- Create RDS Aurora read replica
- Promote Aurora cluster
- Update MySQL version to 8.0 by Blue/Green deployment method
- Reader instance of provisioned aurora cluster convert to Serverless V2
- Make reader Serverless V2 to writer
- Modify left over instance to Serverless V2
Prerequisite for migration
Region and version availability
You have to check AWS Aurora is available in your region.
MySQL version
If you are willing to end up with Aurora Serverless V2, Mysql 8.0 is required. Otherwise, MySQL 5.7 will work.
I used to use MySQL 5.7, so I had to make sure all the queries were working with MySQL 8.0. Therefore, I created Docker Mysql 8.0 and tested it on my local environment first.
Check instance class
You need to check instance class that supports Aurora Provisioned & MySQL 8.0.
I choose to use db.46g.2xlarge instance and I checked as below.
aws rds describe-orderable-db-instance-options\
--engine aurora-mysql\
--db-instance-class db.r6g.2xlarge\
--region ap-northeast-2\
--query 'OrderableDBInstanceOptions[].[EngineVersion]'\
--output text --profile mfa
5.7.mysql_aurora.2.09.2
5.7.mysql_aurora.2.09.3
5.7.mysql_aurora.2.10.0
5.7.mysql_aurora.2.10.1
5.7.mysql_aurora.2.10.2
5.7.mysql_aurora.2.10.3
5.7.mysql_aurora.2.11.0
8.0.mysql_aurora.3.01.0
8.0.mysql_aurora.3.01.1
8.0.mysql_aurora.3.02.0
8.0.mysql_aurora.3.02.1
8.0.mysql_aurora.3.02.2
Check cross-region
If you have a read replica master on cross-region, you can not make Aurora read replica.
Step 1. Create Aurora Read Replica
When you create Aurora Read Replica, it will create a snapshot of a selected instance, and will apply on a cluster. Then, the cluster will catch up targeted instance again to fulfill replica lag.
How to Create
- Select instance you are willing to migrate
- Action
- Create Aurora read replica
Setting
- It is better to set as your origin instance config
- If you want to make it public access, you have to choose public. Default is private
After Creation
When you have finished your Aurora read replica creation, it should be like this.
Step 2. Promote Aurora cluster
Before promoting Aurora cluster, you have to make sure replica lag is settled down to ZERO. To make sure of it, access cluster endpoint via mysql on terminal, and Type as below
mysql -h [cluster endpoint address] -P [PortNum] -u[userID] -p[passward]
SHOW SLAVE STATUS\G
If you find Seconds_Behind_Master is 0, you are good to go!!
- Select cluster
- Action
- Promote
After done promotion, you can delete past one since connection is detached.
When your lag doesn’t hit zero, you can make your instance read-only by modifying the parameter group.
Step 3. Update MySQL version to 8.0 by Blue/Green deployment method
If your goal was Aurora provisioned, you are done. Aurora provisioned support a lot of good Aurora features, while some features are not supported on Aurora Serverless V1 and V2.
To get Serverless V2, MySQL version 8.0 is required as I said. However, there will be a long downtime to update instance MySQL engine version to 8.0. For this reason, I used Blue/Green deployment. This feature is hot off the press on RDS. It will minimize your downtime.
- Select cluster
- Action
- Create Blue/Green Deployment
- Set your target version!
- Create
- Switch over
- Delete old cluster and Blue/Green Deployment if you want
You can choose Switch over in the Actions drop down menu to promote the staging environment marked as Green to be the new production system after testing and qualification of changes are complete.
If Blue/Green Deployment is not supported in your region, then you can convert the version by instance modification
Step 4. Modify reader instance to Serverless V2
We are almost done!
- Select reader instance
- Modify
- Go to Instance configuration
- Click Serverless V2
- ACUs set as much you want — it is not important since pay as you go
0.5 ACUs is default, and it will prevent cold start.
Set Minimum ACUs as below if you need
Performance Insights — 2 ACUs
Aurora global databases — 8 ACUs
Step 5. Make reader Serverless V2 to writer
Once your reader is converted into Serverless V2, you can make it a writer by using failover writer.
Step 6. Modify left over instances to Serverless V2
Now, you can modify left over instances just like what you did on Step 4 and 5.
Conclusion
We have created Aurora read replica and promoted to make Aurora provisioned cluster. Then, we made provisioned cluster to Serverless V2 successfully. Well done!
Even if I tried to make downtime close to zero, it was tough due to versioning up MySQL 8.0. Fortunately, however, Blue/Green deployment has been released on RDS lately so that I was able to make downtime close to zero.
I hope this article helps you. Thanks.
'Cloud' 카테고리의 다른 글
웹 애플리케이션 서비스 개요 (0) | 2023.08.06 |
---|---|
NAT GateWay와 이중화의 중요성 (0) | 2023.08.06 |
AWS Security Group (0) | 2023.04.11 |
Oracle Cloud Infrastructure에 Instance 만들기 (0) | 2022.04.14 |
Oracle Could - VCN (0) | 2022.04.13 |