REPEAT 1 Lessons From Migrating Oracle Databases To Amazon Aurora DAT342-R1 PDF
REPEAT 1 Lessons From Migrating Oracle Databases To Amazon Aurora DAT342-R1 PDF
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Agenda
Introduction to AWS Database Migration Service (AWS DMS) and AWS
Schema Conversion Tool
Q&A
What to expect from this session
• AWS resources with regards to migration & replication
AWS SCT
Source DB or DW Destination DB or DW
Native tool
AWS DMS
Source DB or DW Destination DB or DW
AWS SCT
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS Schema Conversion Tool
The AWS Schema Conversion Tool helps automate many
database schema and code conversion tasks when
migrating from source to target database engines
Features
Create assessment reports for homogeneous/heterogeneous migrations
Optimize Migrate
data warehouses
Database migration assessment
Sources
Amazon Aurora Amazon S3 AWS Snowball
AWS
DMS
On-premises
data center VPN
Internet
70%
Reduction in infrastructure costs
Eliminated capex infrastructure costs
Transformed organization with cost model where each team now manages its
own compute and storage infrastructure based on predicted usage and growth
Other considerations:
• Stringent timeline
• Ensure no performance degradation of service
• Ensure BAU tasks are not impacted
Amazon
Aurora
Amazon database freedom journey
1. Current application and database assessment
3. In case the above steps don’t help, deep dive into database features
• ACID compliance with multi-version concurrency control
• OLTP use-case
• OLAP use-case
• Support for advanced data types such as JSON and XML
• Partitioning
• Built in scheduler
Migration architecture
2 Oracle RDS
AWS DMS
Legacy Oracle
DB RDS
AWS DMS
PostgreSQL
1 Legacy to PostgreSQL
App1 App2
2 Amazon RDS
PostgreSQL to Amazon
RDS Oracle
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Top AWS DMS challenges/learnings
• Oracle’s default read consistency mechanism (using undo segments) which ensures
that all rows from a select are intact from the time it was executed
• AWS DMS runs a “select” on the source for a table when the full load phase starts
ORA-01555: snapshot too old: rollback segment number %n with name "%segname"
too small
What to do in Oracle?
1. Reschedule long-running queries when the system has less DML load
2. Increasing the size of your rollback segment (undo) size
Example – One of the internal AWS teams Timber migrated >=30 TB data store and had
more than 2 tables of >=4 TB each
How do we handle ORA-01555 on the source for
large table migrations in AWS DMS?
Use parallel-load AWS DMS Read from a fully synced active
feature: data guard standby or
1. This feature basically chunks snapshot standby without
the table based on partitions impacting source:
or column ranges and loads 1. Sync standby from source
each chunk in parallel 2. Stop the MRP process and
2. Documentation note the SCN at which the
3. Start a single CDC task for sync is stopped
the entire table from a 3. Run full load from standby
custom CDC start time 4. Run CDC from primary/ADG
instance using the SCN
Truncation and performance issues with
Large Object (LOBs)
• MANDATORY: For AWS DMS to replicate LOBs, the table must have a primary key or a
unique index because LOB replication is a two-step process
PS: If you choose FULL LOB MODE in AWS DMS, then even the migration (full load) phase will
be done in the above manner and not in bulk mode
Truncation and performance issues with Large Object
(LOBs)
Error handling Performance
1. For Oracle and PostgreSQL sources, use: 1. Use parallel-load feature in AWS DMS
failTasksOnLobTruncation
2. For Oracle targets with LOBs greater than
2. Have custom Amazon CloudWatch 10 MB, disable directpathfullload in AWS
alarms on AWS DMS task logs to trap DMS
for LOB truncation messages
3. Use limited lob mode, if the LOB size is
3. Use validation within AWS DMS deterministic from the database and
application side
Outgoing stream
Incoming stream
Sorter
Source Target
Transactional apply vs. Batch apply
Transactional apply Batch apply
• AWS DMS does this by default • Read changes from the source engine and build
a batch
• Based on timeout
• All transactions are applied in the same order
as it happened on the source • Based on batch size
• Designed to work with foreign key • Create an intermediate net changes table in the
constraints and triggers being active on the target with all changes from a batch
target after applying cached changes
• Apply a net changes algorithm to condense
changes and apply separate DMLs in one
transaction
EXAMPLE – Clicks team used batch apply for the higher TPS workload described earlier
Data type conversion issues
Two-step process:
• Number in Oracle becomes a double in PostgreSQL despite it having 0 precision because of the way Oracle
stores it. E.g., an ID column with entry 2045 becomes 2045.00 on the target
• Number to Boolean migration
Recommended workarounds:
1. For small tables, use a trigger on the target to convert this into an INT or BIGINT
2. For larger tables, stop full load, change column definition, resume task into CDC to get rid of extra
unwanted precision
Solution:
• During migration/replication phase, AWS DMS will encode supplementary characters to UTF-16 which causes issues
as encoding strings in surrogate range are invalid UTF8 chars and fails when written to the target
Workarounds:
• Run CSSCAN on Oracle or use the following query to find the problematic characters:
• Replace invalid characters on the source manually and run the migration
• Identify invalid characters and replace them during the migration through an extra connection attribute
Transaction isolation
• Isolation level in Oracle is read-committed for every transaction
➢ This was something that was not an issue with regards to migration to PostgreSQL, but an issue with
MySQL
• MySQL InnoDB engine default isolation level set to repeatable read. This change also requires autocommit to be
disabled
When using AWS DMS, in the initial migration (full load) phase with parallelLoadThreads parameter, rollbacks were
happening, causing data mismatch between source and target
Workarounds:
• AWS DMS allows configuration of session-level parameters using extra connection attribute:
initstmt=SET AUTOCOMMIT=1
Solution
• This was permanently fixed with AWS DMS version 3.x
Before you begin
• Identify key “technical blockers within your organization” and
unblock them
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Learn databases with AWS Training and Certification
Resources created by the experts at AWS to help you build and validate database skills
Validate expertise with the new AWS Certified Database - Specialty beta
exam
Visit aws.training
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Thank you!
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.