Quick Links

Database migration can be lengthy and tiresome. AWS provides an easy-to-use service to make the process of modernizing your on-premises or legacy database and moving to AWS's RDS managed hosting platform easy.

Use AWS's Database Migration Service

If you have a small database, you might be able to simply take a backup of the database schema and contents using

        mysqldump
    

, create a new RDS instance, then restore from backup by importing the dumped file. This will effectively clone your database, and you'll be able to switch over to the RDS instance with relative ease.

However, if you have a large database,

        mysqldump
    

 is not practical to use, and will simply take far too much time. You could just leave it to run for a few days, but the issue there is that any writes made to the source database may not be reflected in the dump file, and you'll have inconsistencies in the two databases by the end of the process. If you're transferring over an enterprise production database, this is a massive problem.

The solution is AWS's Database Migration Service. Once started, DMS will connect to your source and begin syncing all the data to the target database in RDS. Any changes to the source database made during the transfer will be synchronized and reflected in the target database. Even if your data takes many months to transfer to the cloud, you'll be able to transition to your new database with relative ease.

Database migration uses EC2 Instances to handle the transfer. You have to pay the On-Demand price for running these instances as well as any associated storage costs. However, if you're migrating to an Amazon Aurora, Redshift,  DynamoDB, or DocumentDB database, usage of this instance is free for up to six months. Of course, you still incur standard AWS data charges for importing and exporting data.

Setting Up a Replication Instance

Head over to the Database Migration Service Management Console, and click "Create Replication Instance."

Give it a name, and choose the underlying instance type you wish to use. Faster instances will speed up the replication process.

replication instance settings

Select a VPC, and allocate some storage for the instance, mostly used for logs and cache. If you'd like, you can also deploy two replication instances in different AZs, which will be more fault tolerant.

replication instance settings

If you're planning on having this run for a while, you'll need to allocate a specific time for maintenance, so AWS can perform upgrades and patches to the DMS software.

replication instance settings

Click create, then wait a few minutes for the replication instance to start up.

Setting Up the Endpoints and Beginning the Transfer

Under "Endpoints" in the sidebar, create a new endpoint. Select "Source" as the type, and under "Endpoint configuration, select the type of database. You'll need to configure DMS with your database address, port, username, and password.

Setting up and configuring endpoints

Repeat this process for the target endpoint, but this time simply select an RDS instance from the list:

Setting up and configuring the target endpoint

Everything is set up, and all that is left is to begin the transfer. Under "Database Migration Tasks" in the sidebar, create a new task. Select the replication instance to use, and select the source and target endpoints. If you want everything to continue syncing, make sure to change the migration type to "Migrate existing data and replicate ongoing changes."

Create the new task in Task Configuration

Once you create the task, the migration should start. You can view the progress from the tasks tab in the console.