AWS DMS - Database Migration to AWS
Shubham Kumar
Posted on August 24, 2023
Moving databases to the cloud can be confusing, but AWS Data Migration Service (DMS) is here to help. It's like a guide that makes moving your data to Amazon Web Services (AWS) simple. Whether you're new to this or already know a bit, AWS DMS is here to make things easier. In this guide, we'll show you what AWS DMS is, what it does, and why it's important for modern IT. Come with us to learn about AWS DMS and see how it can help you smoothly shift to the cloud. Let's start this exciting journey into AWS DMS together!We are going to explore AWS DMS. We will se how AWS Data migration service work in real project.
As shown in the diagram to explore AWS DMS we are going to migrate one DB hosted on EC2 to the AWS RDS using AWS DMS.
But what is AWS DMS?
AWS Data Migration Service (DMS) is a specialized tool by Amazon Web Services that simplifies moving your databases from one place to another, like from your own computers to the powerful cloud servers of AWS. It's like a skilled mover for your data, ensuring it gets to its new home safely and quickly. Whether you're shifting lots of data or just a bit, DMS takes care of the tricky parts, making database migration a breeze.
Now let's see the implementation step by step
Step 1: Configure one MySQL database on EC2 which will act as a source database in our case.
1.1. Create one EC2 instance and configure MySQL database on it. Please note the DB endpoint, username and password. We will need it in the further step to migrate data from this server to AWS RDS, which is the agenda of this session.
Step 2: Create a managed database using AWS Relational Database.
2.1. Go to the AWS RDS console.
2.2. Choose Create Database.
2.3. For choose a database creation method: Select
.
Standard Create
2.4. For Engine Type: Select MySQL
2.5. For Edition: Select MySQL Community
2.6. For Version: Select Latest Version
2.7. For Templates: Select Free Tier
2.8. Under setting give DB instance identifier name-TargetDB
2.9. Give Master Username - admin
2.10. Give Master Password - shubhamkcloud
2.11. Confirm Password
2.12. Under instance Configuration - For DB instance class select Brustable classes
and then select db.t3.micro
2.13. Leave the storage parameter as it is.
2.14. Under Connectivity: Select VPC and Subnet Group.
2.15. For Public Access: Select No
2.16. Select Security Group. Make sure to allow port 3306.
2.17. For Database Authentication: Select password
.
Authentication
2.18. Finally click on Create Database
It will take sometime but finally DB will be created.
Step 3: Create Replication Instance
Replication Instance initiates the connection between source and target database and it will transfer data.
3.1. Go to the Database Migration Service
console.
3.2. Click on the Replication instance
on the left side panel.
3.3. Click on Create Replication instance
3.4. Enter instance name - replication-instance
3.5. For instance class: select dms.t3.medium
3.6. For Engine version: select latest version. Currently it is 3.5.1
3.7. For High Availability: Select Dev or test workload
3.8. For Allocation storage: enter 50
3.9. For network type - select IPV4
3.10. Select VPC and Subnet
3.11. Select the checkbox for public accessible
3.12. Expand Advance setting and select Availability zone and Security group.
3.13. Choose Create replication instance
.
This will again take some time but after waiting for 5-7 mins replication instance will be created.
Step 4: Configure Source Database
Use continuous replication of changes (also known as Change Data Capture(CDC))to ensure minimum downtime.
4.1. Get the Source DB endpoint, username and password.
4.2. You need to login to the DB server and grant the following permission to the DB USER. You can use the following command.
mysql -u root -p <password>
GRANT REPLICATION CLIENT ON *.* to '<DB_USER>;
GRANT REPLICATION SLAVE ON *.* to '<DB_USER>;
GRANT SUPER ON *.* to '<DB_USER>;
exit
4.3. Restart MYSQL service with the following command
sudo service mysql restart
STEP 5: Create Source and Target end points
5.1. Go to the AWS DMS console.
5.2. Click on Create endpoint
from the left panel.
5.3. Give Endpoint identifier name as source-endpoint
5.4. Select Source engine as MySQL
5.5. For Access to endpoint database - Select Provide access information manually
5.6. For Server name - Enter Source DB server name(from step 1).
5.7. For port enter: 3306
5.8. Enter Username set on the first step.
5.9. Enter password set on the first step.
5.10. For Secure Socket Layer mode - select None
5.11. Click on Test endpoint connection
for testing the endpoint.
5.12. Select VPC
5.13. For Replication instance - Select replication-instance
from the dropdown list.
5.14. Choose Create endpoint
5.15 Follow the same step from 5.1 to 5.14 and create Target endpoint in the same way as you created for source endpoint. Remember we have to give here RDS endpoint, username and password.
Step 6: Create and Run Replication Task
As I mentioned above we will perform this migration by continuous data replication migration approach. Although this can be perform in multiple ways.
6.1. Go to the AWS DMS console.
6.2. Navigate to Database Migration Tasks
on the left side.
6.3. Click Create Task
6.4. Provide a task identifier name, e.g., replication-task
6.5. For "Replication instance," select replication-instance
from the dropdown list.
6.6. For Source database endpoint - Select source-endpoint
from the dropdown list.
6.7. For Target database endpoint - Select target-endpoint
from the dropdown list.
6.8. For Migration Type - Select Migrate existing data and replicate ongoing changes
6.9. On the Task setting section, For Editing mode - Select Wizard
6.10. For Target table preparation mode - Select Do nothing
6.11. For Stop task after full load complete: Select Don't stop
6.12. For Include LOB columns in replication: Select Limited LOB mode
6.13. For Maximum LOB size(KB) - Enter 32
6.14. Select the checkbox for - Turn on validation
6.15. Select the checkbox for - Turn on Cloudwatch logs
6.16. Leave the other values as default
6.17. For the Table mapping section, select Editing mode as Wizard
6.18. choose Selection rules
and then choose Add new selection rule
6.19. For Schema - SelectEnter a schema
from the dropdown list
6.20. For Source name - enter DB name.
6.21. Under the Migration task startup configuration, for Start migration task - Select Automatically on create
6.22. Choose Create task
. This will take few minutes to complete. Wait for the status to change to Load complete, replication ongoing
6.23. We can check the table statistics on the Table statistics
tab inside your replication-task
Step 7: Validate
Since you completed all these steps, now you can verify the data in your RDS.
Conclusion: Congratulations on successfully migrating your database using AWS Data Migration Service (DMS). You've harnessed the power of seamless data movement to AWS RDS.
Posted on August 24, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.