LAB 01

Database Migration with AWS DMS

Migrate a MySQL database from on-premises to Amazon RDS with zero downtime using Change Data Capture (CDC)

🗄️ MySQL → RDS 🔄 CDC ⏱ ~65 min 🏗️ Hands-On

Lab Architecture Overview

This lab involves two environments: the existing on-premises data center running a WordPress/WooCommerce application with MySQL, and the target AWS environment where the database will be migrated to Amazon RDS.

Source Environment — On-Premises Data Center

CURRENT DATA CENTER Users Webserver Linux, Apache, PHP WordPress + WooCommerce MySQL Server Linux, MySQL 8.0 wordpress-db (46 tables)

Target Environment — AWS Cloud

AWS CLOUD — AVAILABILITY ZONE VPC (TargetVPC) Public Subnet Bastion Host EC2 Instance SSH AWS DMS Replication Instance dms.t3.medium NAT Gateway Internet Access for Private Subnet Private Subnet Amazon RDS for MySQL Target Database (db.t3.micro) DATA FLOW
💡 Architecture Note

The DMS replication instance sits in the public subnet with public accessibility enabled so it can reach the on-premises source database over the internet. The target RDS instance remains in the private subnet for security — DMS communicates with it through the VPC's internal network.

Migration Flow — Step by Step

Follow the six-task pipeline to migrate your MySQL database from on-premises to Amazon RDS. Click any node to see details, or hit Play to watch the full sequence.

🔍
Review Source
🗄️
Create RDS
⚙️
DMS Instance
🔧
Configure CDC
🔌
Endpoints
▶️
Replicate

🔍 Task 1: Review Source Database

Connect to the source MySQL server via Session Manager and verify the wordpress-db database exists with all 46 tables (WordPress core + WooCommerce).

Console: EC2 → Session Manager → mysql -u root -p

Task Guide — Quick Reference

Expand each task for the goal, key configuration, and important notes. Use this as a condensed reference while working through the lab.

01 Connect to Source Database

Goal

Verify the source MySQL database is running and contains the expected wordpress-db with 46 tables.

Key Configuration

SettingValue
Connection methodSession Manager (SSM)
MySQL userroot
Databasewordpress-db
Expected tables46 (WordPress + WooCommerce)
📝 Note

Use the SourceDBServerSessionURL from your lab resources to connect. The password is provided in the DatabasePassword output.

02 Create Target Amazon RDS

Goal

Provision a managed MySQL database in a private subnet that will serve as the migration target.

Key Configuration

SettingValue
EngineMySQL 8.4.7 (Community)
TemplateDev/Test
Instance classdb.t3.micro (Burstable)
DB identifiertargetrdsdatabase
Master usernameadmin
VPCTargetVPC
Subnet groupdatabase-subnet-group
Public accessNo
Security groupDB-SG
DeploymentSingle-AZ
⚠️ Important

Remove the default security group and select only DB-SG. Disable enhanced monitoring, automated backups, encryption, and auto minor version upgrades for this lab environment.

03 Create DMS Replication Instance

Goal

Deploy the DMS replication instance that orchestrates data movement between source and target databases.

Key Configuration

SettingValue
Namereplication-instance
Instance classdms.t3.medium
Storage50 GiB
Engine version3.5.x (latest)
High AvailabilitySingle-AZ (Dev/Test)
VPCTargetVPC
Subnet groupdms-subnet-group
Public accessibleYes
Security groupRI-SG
📝 Note

Public accessibility is required so the replication instance can reach the on-premises source database over the internet. Remove the default security group and use only RI-SG.

04 Configure CDC (Binary Logging)

Goal

Grant replication privileges and verify binary logging is active so DMS can perform continuous change capture.

Key Configuration

SettingRequired Value
REPLICATION CLIENTGranted to wordpress-user
REPLICATION SLAVEGranted to wordpress-user
SUPER privilegeGranted to wordpress-user
log_binON
binlog_formatROW
⚠️ Important

Binary logging must be in ROW format (not STATEMENT or MIXED) for DMS CDC to work correctly. After granting privileges, restart MySQL with sudo service mysql restart.

05 Create Source & Target Endpoints

Goal

Define connection configurations for both databases and verify connectivity through the replication instance.

Source Endpoint

SettingValue
Identifiersource-endpoint
EngineMySQL
ServerDBServerDNSName (from outputs)
Port3306
Usernamewordpress-user

Target Endpoint

SettingValue
Identifiertarget-endpoint
EngineMySQL (auto-filled from RDS)
RDS instancetargetrdsdatabase
Usernameadmin
📝 Note

Always run the endpoint connectivity test before creating. Select the replication instance and wait for "Successful" status. This confirms network paths and credentials are correct.

06 Run Replication Task

Goal

Create and start a migration task that performs full load followed by continuous replication, then validate the migrated data.

Key Configuration

SettingValue
Task identifierreplication-cdc
Task typeMigrate and replicate
DurationIndefinitely
Target table prepDo nothing
LOB modeLimited LOB (32 KB max)
Data validationEnabled
Table mapping schemawordpress-db
Start taskAutomatically on create
✅ Validation

After the task reaches "Load complete, replication ongoing" status, connect to the target RDS via the Bastion Host and confirm all 46 tables are present in wordpress-db.

Key Concepts

Essential concepts to understand before and during the database migration lab.

🔄 Homogeneous Migration

Source and target use the same database engine (MySQL → MySQL). No schema conversion is needed — DMS handles the data transfer directly without transformation overhead.

📡 Change Data Capture (CDC)

After the initial full load completes, DMS continuously reads the source database's binary log to capture inserts, updates, and deletes — replicating them to the target in near real-time.

🖥️ Replication Instance

An EC2-based server managed by DMS that runs your migration tasks. It connects to both source and target endpoints, pulling data from one and pushing to the other.

📦 Full Load + CDC

The recommended migration strategy: first, bulk-copy all existing data (full load), then switch to continuous replication (CDC) to keep source and target synchronized until cutover.

📋 Binary Logging

A MySQL feature that records every data modification in a binary log file. DMS reads this log to identify changes made after the full load started — essential for CDC to function.

🔌 Endpoint Testing

Before running any migration task, always test endpoint connectivity. This validates network paths, security group rules, credentials, and database accessibility through the replication instance.

🏦 Banking Context

In production banking environments, CDC is essential for migrating transaction databases. The source system continues processing payments while DMS replicates changes in near real-time — enabling cutover windows measured in seconds rather than hours of downtime. For AnyCompany Bank, this means payment processing, account updates, and customer transactions never stop during the migration.

Migration Type Comparison

AspectThis Lab (Homogeneous)Heterogeneous Alternative
Engine changeMySQL → MySQL (same)Oracle → PostgreSQL (different)
Schema conversionNot requiredAWS SCT required
ComplexityLower — direct replicationHigher — type mapping, stored proc conversion
CDC supportBinary log (ROW format)Varies by source engine
Typical use caseLift-and-shift to managed serviceEngine modernization (cost, licensing)