By using AWS re:Post, you agree to the AWS re:Post Terms of Use

How do I migrate to an Amazon RDS or Amazon Aurora DB instance using AWS DMS?

5 minute read
0

I want to migrate my database to Amazon Relational Database Service (Amazon RDS) or Amazon Aurora. How can I do this with minimal downtime?

Short description

Note: If you're performing a homogeneous migration, use your engine’s native tools (like MySQL dump or MySQL replication) whenever possible.

To migrate to an Amazon RDS DB instance using AWS DMS:

  • Create a replication instance
  • Create target and source endpoints
  • Refresh the source endpoint schemas
  • Create a migration task
  • Monitor your migration task

You can use these steps for all Amazon RDS and Amazon Aurora engine types, including Amazon RDS for Oracle and Amazon Aurora for MySQL DB instances.

Resolution

Note: AWS DMS creates a table with a primary key on the target only when necessary before migrating table data. To generate a complete target schema, use the AWS Schema Conversion Tool (AWS SCT). For more information, see Converting schema.

(Optional) Turn on logging with Amazon CloudWatch

Amazon CloudWatch logs can alert you to potential issues when migrating. For more information, see Monitoring replication tasks using Amazon CloudWatch.

Create a replication instance

  1. Open the AWS DMS console, and choose Replication Instances from the navigation pane.
  2. Choose Create replication instance.
  3. Enter your replication instance name, description, instance class, Amazon Virtual Private Cloud (Amazon VPC), and Multi-AZ preference.
    Note: -Choose an instance class that's sufficient for your migration workload. If the instance isn't sufficient for your workload, you can modify the replication instance later.
  4. From the Advanced section, choose your VPC security groups, or choose the default option.
  5. Choose Create replication instance.

Create target and source endpoints

  1. Open the AWS DMS console, and choose Endpoints from the navigation pane.
  2. Choose Create endpoint to create the source and target database.
  3. For Endpoint type, choose Source.
  4. Enter the endpoint's engine-specific information.
  5. Choose Run Test.
  6. After the test is complete, choose Save.
  7. Repeat steps 3-6, but for Endpoint type, choose Target.
    Note: Complete this step for both the target and the source.

Refresh the source endpoint schemas<b></b>

  1. Open the AWS DMS console, and choose Endpoints from the navigation pane.
  2. Select the source endpoint, and choose Refresh schemas.
  3. Choose Refresh schemas.
    Note: You must refresh the source so that the source schemas appear in the table mappings when you create an AWS DMS task.

Create a migration task

  1. Open the AWS DMS console, and choose Database migration tasks from the navigation pane.
  2. Choose Create task.
  3. Specify the Task identifier, Replication instance, Source database endpoint, Target database endpoint, and Migration type. Choose one of the following migration types:
    Migrate existing data only—Use this migration type for one-time migrations.
    Migrate existing data and replicate ongoing changes—Use this migration type to migrate large databases to the AWS Cloud with minimal downtime.
    Migrate ongoing replication changes—Use this migration type when you already have migrated the existing data and want to synchronize the source database with the target MySQL database hosted on the AWS Cloud.
  4. From the Task Settings section, modify the task as needed.
  5. From the Table mappings section, choose Guided UI.
  6. Choose Add new selection rule, and specify your Schema and Table name.
    Note: You can change or transform the source schema, table, or column name of some or all of the selected objects. To do this, expand the Transformation rules section. Choose Add new transformation rule. Then select the Target, Schema name, and Action.
  7. Choose Create task.

Note: If you have large object (LOBs) columns, then use Limited LOB Mode. For more information, see Setting LOB support for source databases in an AWS DMS task.

Monitor your migration task

  1. Use the Task Monitoring view to monitor the migration tasks. You can see which tables have been migrated successfully and which tables are in the process of migration. Pay attention to the following message types:
    I - indicates an informational message
    W - indicates warnings
    E - indicates errors that occurred when migrating the database
  2. Verify that the databases have been migrated successfully by connecting to the source and target instances through the terminal.

Migrating Oracle

When you use Oracle as the source database, then AWS DMS migrates table to the specified target endpoint user. You can change the schema for an Oracle target by using transformation rules. For more information, see Changing the user and schema for an Oracle target.

Migrating to MySQL/PostgreSQL/SQL Server

During migration, schemas and tables are migrated to the same name on the target. If you want to migrate tables to a different schema/table on the target, then create a mapping rule to specify the new schema/table on the target database.

{
  "rules": [{
      "rule-type": "selection",
      "rule-id": "1",
      "rule-name": "1",
      "object-locator": {
        "schema-name": "test",
        "table-name": "%"
      },
      "rule-action": "include"
    }, {
      "rule-type": "transformation",
      "rule-id": "2",
      "rule-name": "2",
      "rule-action": "rename",
      "rule-target": "schema",
      "object-locator": {
        "schema-name": "test"
      },
      "value": "newtest"
    }
  ]
}

Check the logs to confirm that there are no errors.

Monitor latency and compare data counts on the source and the target databases before switching to the new target database. For more information, see Troubleshooting migration tasks in AWS Database Migration Service.


Related information

How AWS Database Migration Service works

Database Migration step-by-step walkthroughs

Sources for data migration

Targets for data migration

AWS OFFICIAL
AWS OFFICIALUpdated 2 years ago