Lesson 1 of 6 Batch Ingestion and Integration Services

Replicating Databases with AWS DMS and Change Data Capture

This lesson explains how AWS Database Migration Service (AWS DMS) migrates databases and continuously replicates their changes into AWS data stores, the standard way to bring operational data into a data lake or warehouse.

Learning outcomes

After completing this lesson, you will be able to:

  • Distinguish full load, full load plus CDC and CDC-only tasks.
  • Identify DMS sources and targets for data engineering.
  • Choose between a replication instance and DMS Serverless.
  • Configure the source database prerequisites for CDC.

Task types

An AWS DMS task performs one of three kinds of work. A full load copies the existing data once, which suits a one-off copy. A full load plus CDC copies the existing data and then keeps applying changes made to the source while the copy runs and afterwards, so the target stays current; this is how a database is migrated with minimal downtime, or kept in sync with a data lake. A CDC only task replicates changes from a chosen point in time, for example after an initial load made by another tool. The following table summarises the task types.

TaskWhat it does
Full loadCopies existing data once
Full load plus CDCCopies existing data, then keeps applying ongoing changes
CDC onlyReplicates changes from a point in time

Change data capture (CDC) reads the source's transaction log, capturing inserts, updates and deletes with little load on the source.

The following diagram shows what each task type does over time.

The three AWS DMS task types on a timeline. A full load copies the existing data once and stops. A full load plus CDC copies the existing data and then keeps applying changes, so the target stays current. A CDC only task replicates changes from a chosen point, for example after another tool made the initial load.
A full load plus CDC also captures changes made while the copy runs.
Match the pairs

DMS task types

Exam skills 1.1.2

Match each requirement with the DMS task type.

Log in to try this activity Interactive activities are free with an account.

Sources and targets

AWS DMS reads from most commercial and open-source databases, such as Oracle, SQL Server, MySQL, PostgreSQL and MongoDB, whether on premises or in AWS. For data engineering, the most important targets are Amazon S3, where DMS writes CSV or Parquet files partitioned by date with an extra column that marks each row as an insert, update or delete, ready to be merged into a lake table; and Kinesis Data Streams or MSK, which turn database changes into a stream for real-time consumers. It can also load Redshift, Aurora, RDS, DynamoDB, OpenSearch and DocumentDB. The following table summarises the principal sources and targets.

SourcesTargets
Oracle, SQL Server, MySQL, MariaDB, PostgreSQL, MongoDB, Db2, SAP ASE (on premises or in AWS)Amazon S3 (CSV or Parquet, date-partitioned, with an operation column for inserts, updates and deletes), Redshift, Aurora, RDS, DynamoDB, Kinesis Data Streams, MSK, OpenSearch, DocumentDB
Scenario questions

Choosing a DMS target

Exam skills 1.1.2

Choose the DMS target for each requirement.

Log in to try this activity Interactive activities are free with an account.

Running and configuring tasks

AWS DMS tasks run on a replication instance that the customer sizes, or with DMS Serverless, which provisions and scales capacity automatically and suits variable or unknown workloads. A task can perform a full load, ongoing replication of changes (CDC), or both.

Table mappings select which schemas, tables and columns are migrated and can rename them, and transformation rules add or drop columns along the way. Data validation compares source and target rows to confirm that the migration is complete and correct. Large object (LOB) settings control how large text and binary values are copied, which has a significant effect on performance for tables that contain them.

Match the pairs

DMS configuration

Exam skills 1.1.3

Match each requirement with the DMS feature that meets it.

Log in to try this activity Interactive activities are free with an account.

CDC prerequisites

Change data capture reads changes from the source database's transaction log, so the database must be configured to record enough detail in that log. Each engine has its own setting. MySQL needs binary logging in row format, so each changed row is recorded. Oracle needs supplemental logging, which adds the columns DMS needs to identify rows. SQL Server needs MS-CDC or MS-Replication, and PostgreSQL needs logical replication. The following table summarises the settings.

SourceMust enable
MySQLBinary logging in row format
OracleSupplemental logging
SQL ServerMS-CDC or MS-Replication
PostgreSQLLogical replication

Missing prerequisites are a common cause of CDC failures.

The following diagram shows a DMS pipeline that replicates an on-premises PostgreSQL orders table into the data lake, and the rows it writes to S3.

Replicating the on-premises orders table into the lake. Logical replication lets DMS read PostgreSQL's write-ahead log, a full load and CDC task writes changes to S3 as Parquet with an operation column, and a Glue job or Iceberg MERGE applies them to a current-state table. Alarms watch source and target CDC latency.
The example rows are illustrative.
Match the pairs

CDC prerequisites

Exam skills 1.1.3

Match each source engine with the setting CDC needs.

Log in to try this activity Interactive activities are free with an account.

Heterogeneous migrations and zero-ETL

When the source and target use different database engines, such as Oracle and Aurora PostgreSQL, the schema and code must be converted as well as the data. DMS Schema Conversion or the AWS Schema Conversion Tool converts tables, views and procedural code, reporting what needs manual work, and DMS then moves the data.

When the purpose is analytics in Amazon Redshift rather than migration, zero-ETL integrations from Aurora, RDS or DynamoDB replicate data continuously with no DMS tasks or pipeline to build, which is usually the answer when least operational overhead is required.

Scenario questions

Conversion or zero-ETL?

Exam skills 1.1.2 · 2.4.3

Choose the approach for each requirement.

Log in to try this activity Interactive activities are free with an account.
Worked example

Replicating an operational database into the lake

Analysts need the orders table from an on-premises PostgreSQL database in the S3 data lake, at most 15 minutes behind, without slowing the production database.

StepConfiguration
PrerequisiteEnable logical replication on PostgreSQL so DMS can read the write-ahead log
Task typeFull load and CDC: copy existing rows, then stream changes
TargetS3 in Parquet, with a timestamp and an operation column (I, U, D) on each change
DownstreamA scheduled Glue job (or Iceberg MERGE) applies the changes to a current-state table
MonitoringAlarms on CDCLatencySource and CDCLatencyTarget

Reading the transaction log puts little load on the source, unlike repeated full extracts with SELECT *. If the source were Aurora and the target Redshift, a zero-ETL integration would do the same with no pipeline to manage at all.

Check yourself

How can you check that rows migrated by DMS match the source?

Show answer

With DMS data validation, which compares the source and target data.

Exam Tips

Remember for the exam

  • To replicate ongoing database changes into the S3 data lake, use DMS full load plus CDC to S3, in Parquet.
  • To stream database changes to Kinesis or Kafka, use DMS CDC with a Kinesis or MSK target.
  • To check that migrated rows match the source, use DMS data validation.
  • For Oracle to PostgreSQL, convert the schema with DMS Schema Conversion or SCT, then move the data with DMS.
  • To run DMS without sizing replication instances, use DMS Serverless.
  • If CDC fails to start, check the source's logging prerequisites, such as binlog or supplemental logging.