When databases were created in AWS, they were placed on the EC2 instances. As AWS came up with RDS, a dedicated service for databases, it was preferable to maintain databases on RDS rather than on EC2s. As a result, all new databases that were created in AWS are placed in RDS.
So, what about the databases that are in EC2’s?
They should be migrated to RDS. Simple isn’t it?
Based on these scenarios, the migration plan can vary. Let us discuss a plan on how we can achieve this –
Scenario – You have your active production database on EC2 and you want to migrate it to RDS.
- Take a snapshot/backup of the database on the EC2. This can be achieved using a ‘percona’. Refer to –
- Note down the binlog position of the backup.
- Send the backup to S3, an AWS storage service.
- Now, you can ‘Restore a DB‘ to RDS from the backup stored in S3, using the AWS RDS console/CLI. Refer to –
- Once the DB is restored to RDS. Login to the DB on RDS and make it a slave to the DB on EC2 by using the binlogs you stored in STEP 2.
- Once the RDS is a slave to the DB on EC2, check if the lag time is ‘0’.
- Both DBs should be in sync.
- Ask your clients for a maintenance window where the application will be temporarily down.
- In that maintenance window -Check for ‘0’ lag time, Stop DB on EC2 and turn the traffic to the DB on RDS.
- Once your application is UP, all the traffic is now pointed to RDS.
- Confirm that the new DB is working properly as planned and shut down the DB on EC2.
Important note –
- Don’t shut down the DB on EC2 until you perform all the tests on RDS.
- Do this for a non-prod DB and then for a prod DB to eliminate risks.
- Choose the RDS parameters carefully based on the DB parameters on EC2.
There may be different strategies that can be followed to migrate based on specific scenarios. One piece of advice- ‘Be careful when playing with Databases else you will have sleepless weekends!!’
- D&D: More Than Just a Game
- In The Corners Of My Mind
- A Charming Friendship Without Borders
- Give Yourself A Reality Check
- Make Time For Yourself
- A Passion For Beauty
- Server Auditing
- Reading Between The Lines
- Things We Ought To Do
- The Thanos Effect: Avengers Endgame
- No One Wins At War
- Migrating MySQL From EC2 to RDS in AWS
- Overdoing And The Law Of Diminishing Returns
- The Power Of Music
- Promote Inclusivity – Combat Intelorance
- Appreciating Blessings To Maintain A Positive Mindset
- securing applications running on cloud
- How cancer brought our family closer
- The Little Lessons I’ll Remember Forever
- Be You
- The guilt of not seeming grateful
- Public Transportation