Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Shubham Kumar
Shubham Kumar

Posted on

     

AWS DMS - Database Migration to AWS

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.

Image description

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 selectBrustable classes and then selectdb.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: Selectpassword
Authentication
.
2.18. Finally click onCreate 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 theDatabase Migration Service console.
3.2. Click on theReplication instance on the left side panel.
3.3. Click onCreate Replication instance
3.4. Enter instance name -replication-instance
3.5. For instance class: selectdms.t3.medium
3.6. For Engine version: select latest version. Currently it is 3.5.1
3.7. For High Availability: SelectDev or test workload
3.8. For Allocation storage: enter50
3.9. For network type - selectIPV4
3.10. Select VPC and Subnet
3.11. Select the checkbox forpublic accessible
3.12. Expand Advance setting and select Availability zone and Security group.
3.13. ChooseCreate 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
Enter fullscreen modeExit fullscreen mode

4.3. Restart MYSQL service with the following command

sudo service mysql restart
Enter fullscreen modeExit fullscreen mode

STEP 5: Create Source and Target end points

5.1. Go to the AWS DMS console.
5.2. Click onCreate endpoint from the left panel.
5.3. Give Endpoint identifier name assource-endpoint
5.4. Select Source engine asMySQL
5.5. For Access to endpoint database - SelectProvide 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 - selectNone
5.11. Click onTest endpoint connection for testing the endpoint.
5.12. Select VPC
5.13. For Replication instance - Selectreplication-instance from the dropdown list.
5.14. ChooseCreate 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 toDatabase Migration Tasks on the left side.
6.3. ClickCreate Task
6.4. Provide a task identifier name, e.g.,replication-task
6.5. For "Replication instance," selectreplication-instance from the dropdown list.
6.6. For Source database endpoint - Selectsource-endpoint from the dropdown list.
6.7. For Target database endpoint - Selecttarget-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 - SelectWizard
6.10. For Target table preparation mode - SelectDo nothing
6.11. For Stop task after full load complete: SelectDon't stop
6.12. For Include LOB columns in replication:Select Limited LOB mode
6.13. For Maximum LOB size(KB) - Enter32
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 asWizard
6.18. chooseSelection rules and then chooseAdd 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 - SelectAutomatically on create
6.22. ChooseCreate task. This will take few minutes to complete. Wait for the status to change toLoad complete, replication ongoing
6.23. We can check the table statistics on theTable 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.

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

AWS|Cloud Infrastructure|AWS Multi Account Architecture Setup|MicroServices|DevOps|GenAI|K8S|Data Engineer|Cloud Architecture|Infra automation|Cloud Security|Cloud Administrator|AWS Cost Optimisation|
  • Joined

More fromShubham Kumar

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp