Database Migration Service - Safe and Efficient Database Migration with AWS DMS
Learn how to use AWS Database Migration Service (DMS) for database migration. This guide covers homogeneous and heterogeneous database migration with RDS integration, and practical methods for minimizing downtime through continuous replication.
Database Migration Challenges and DMS Overview
Database migration is a phase that carries risk in cloud migration projects. There are many factors to consider, including ensuring data integrity, minimizing downtime, schema conversion, and application compatibility verification. AWS Database Migration Service (DMS) is a fully managed service that migrates data from on-premises databases to AWS, or between databases within AWS. It supports database engines as source or target, including Oracle, SQL Server, MySQL, PostgreSQL, MongoDB, Amazon Aurora, and DynamoDB. DMS supports AWS database services (RDS, Aurora, DynamoDB, Redshift) as well as self-managed databases on EC2 as targets.
Migration Task Configuration and Endpoint Management
DMS migration tasks consist of three components: source endpoint, target endpoint, and replication instance. The source endpoint defines the connection information for the migration source database, and the target endpoint defines the connection information for the destination. The replication instance is the compute resource that reads data from the source, transforms it as needed, and writes it to the target. You can create a replication instance with the following CLI command.
aws dms create-replication-instance \
--replication-instance-identifier my-repl-instance \
--replication-instance-class dms.r5.large \
--allocated-storage 100 \
--multi-azTable mapping rules allow you to selectively specify schemas and tables for migration, and define transformation rules for table and column names. Filtering rules enable migrating only records that match specific conditions. The pre-assessment feature automatically checks source database compatibility and identifies data types and objects that may cause issues during migration. With the DMS Serverless option, capacity scales automatically based on migration workload.
Continuous Replication and Downtime Minimization
DMS's continuous replication (CDC: Change Data Capture) feature continues to replicate source database changes to the target after the initial full load completes. This allows you to keep the source database running during the migration period while maintaining synchronization with the target database. Downtime at cutover occurs mainly while application connections are switched. CDC reads the source database's transaction logs (Oracle Redo Log, MySQL Binary Log, PostgreSQL WAL) and applies INSERT, UPDATE, and DELETE changes to the target in order. Multi-AZ replication instances ensure high availability of the migration process itself. CloudWatch metrics let you monitor replication lag and use it to decide when to cut over.
Heterogeneous Database Migration and Schema Conversion Tool
Heterogeneous database migrations (e.g., Oracle to Aurora PostgreSQL) require converting database objects such as schemas, stored procedures, triggers, and views. AWS Schema Conversion Tool (SCT) analyzes the source database schema and automatically converts it to a compatible format for the target database. For objects that cannot be converted, it provides detailed reports on items requiring manual conversion and recommended conversion methods. SCT's assessment report quantitatively evaluates migration complexity, presenting the automatic conversion rate, number of objects requiring manual conversion, and estimated effort. SCT supports conversions from sources including Oracle, SQL Server, SAP ASE, and Teradata. Combining DMS and SCT enables executing schema conversion and data migration in a consistent workflow.
Post-Migration Data Validation and Optimization
DMS's data validation feature compares source and target data to check that they match. In addition to row count comparison per table, it performs column-level data comparison and generates detailed reports when discrepancies are detected. For post-migration database optimization, use RDS Performance Insights to analyze query performance and consider adding indexes or rewriting queries. When migrating to Aurora, you can leverage read replicas for read scaling and Aurora Serverless v2 for automatic scaling based on workload. You can check migration task table statistics with the following command.
aws dms describe-table-statistics \
--replication-task-arn arn:aws:dms:ap-northeast-1:123456789012:task:TASK123 \
--filters Name=table-name,Values=ordersYou can set up CloudWatch Alarms to monitor replication lag and error counts and send SNS notifications when thresholds are exceeded.
DMS Pricing
DMS pricing is based on hourly charges for replication instances. DMS Serverless uses pay-per-use pricing based on DCU (DMS Capacity Unit) usage. Schema Conversion Tool (SCT) is free. When running continuous replication (CDC) after the initial load completes, the replication instance runs continuously, so promptly stop the instance after migration is complete.
Summary - Guidelines for Building a Database Migration Strategy
AWS DMS is a fully managed service that performs migration between homogeneous and heterogeneous databases. SCT's automatic schema conversion, pre-assessment compatibility checks, and data validation are features used in database migration. The DMS Serverless option increases and decreases capacity automatically to match the migration workload.
References (Official AWS Resources)
The primary sources for this page are the official AWS website and documentation. Check the official pages below for the latest specifications and pricing.
If this page and the official documentation disagree, treat the official documentation as authoritative.