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 one of the highest-risk phases 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 safely migrates data from on-premises databases to AWS, or between databases within AWS. It supports over 20 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, offering high flexibility in migration destinations.

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. ```bash aws dms create-replication-instance \ --replication-instance-identifier my-repl-instance \ --replication-instance-class dms.r5.large \ --allocated-storage 100 \ --multi-az ``` Table 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. DMS also offers a Serverless option where capacity automatically scales based on migration workload, eliminating the need for upfront sizing.

Continuous Replication and Downtime Minimization

DMS's continuous replication (CDC: Change Data Capture) feature continues to replicate source database changes to the target in real time 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. Cutover downtime is limited to the few minutes needed to switch application connections, minimizing business impact even for large database migrations. 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 accurately determine the optimal cutover timing.

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. For typical workloads, over 80% of schemas can be automatically converted. SCT provides unified support for conversions from diverse sources including Oracle, SQL Server, SAP ASE, and Teradata in a single tool. Combining DMS and SCT enables executing schema conversion and data migration in a consistent workflow. For a systematic understanding of DMS replication, related books (Amazon) can also be helpful.

Post-Migration Data Validation and Optimization

DMS's data validation feature automatically confirms that source and target data match exactly, ensuring migration accuracy. 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. ```bash aws dms describe-table-statistics \ --replication-task-arn arn:aws:dms:ap-northeast-1:123456789012:task:TASK123 \ --filters Name=table-name,Values=orders ``` Setting up CloudWatch Alarms to monitor replication lag and error counts, with SNS notifications when thresholds are exceeded, builds an operational framework that enhances migration process reliability.

DMS Pricing

DMS pricing is based on hourly charges for replication instances. A dms.r5.large costs approximately $0.185 per hour (about $133 per month). DMS Serverless uses pay-per-use pricing based on DCU (DMS Capacity Unit) at approximately $0.018 per DCU-hour. 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 executes safe and efficient migration between homogeneous and heterogeneous databases. SCT's 80%+ automatic schema conversion, pre-assessment compatibility checks, and data validation for migration accuracy are essential features for successful database migration projects. The DMS Serverless option eliminates upfront sizing requirements, and automatic scaling based on migration workload improves cost efficiency.