Migrating An Oracle Database To AWS
Migrating An Oracle Database To AWS
PostgreSQL
Oracle database to a PostgreSQL database using AWS Database Migration Service
(AWS DMS) and the AWS Schema Conversion Tool (AWS SCT).
AWS DMS migrates your data from your Oracle source into your PostgreSQL target.
AWS DMS also captures data manipulation language (DML) and supported data
definition language (DDL)changes that happen on your source database and applies
these changes to your target database. This way, AWS DMS keeps your source and
target databases in sync with each other. To facilitate the data migration, AWS SCT
creates the migrated schemas on the target database, including the tables and
primary key indexes on the target if necessary.
AWS DMS doesn't migrate your secondary indexes, sequences, default values,
stored procedures, triggers, synonyms, views, and other schema objects not
specifically related to data migration. To migrate these objects to your PostgreSQL
target, use AWS SCT.
AWS DMS takes a table-by-table approach when migrating data from source to
target in the Full Load phase. Table order during the full load phase cannot be
guaranteed. Tables are out of sync during the full load phase and while cached
transactions for individual tables are being applied. As a result, active referential
integrity constraints can result in task failure during the full load phase.
Temporarily disable all triggers from the instance, and finish the full load .
Use the session_replication_role parameter in PostgreSQL.
Step-by-Step Migration
Step 1: Install the SQL Drivers and AWS Schema Conversion Tool on Your Local
Computer
https://docs.aws.amazon.com/dms/latest/sbs/CHAP_RDSOracle2PostgreSQL.Steps.InstallSCT.
html
o If the schemas you are migrating do not exist on the PostgreSQL database,
then create the schemas.
o Create the AWS DMS user to connect to your target database, and grant
Superuser or the necessary individual privileges (or use the master username
for RDS).
Step 4: Use the AWS Schema Conversion Tool (AWS SCT) to Convert the Oracle
Schema to PostgreSQL
https://docs.aws.amazon.com/dms/latest/sbs/CHAP_RDSOracle2PostgreSQL.Steps.ConvertSc
hema.html
Before you migrate data to PostgreSQL, you convert the Oracle schema to a
PostgreSQL schema.
To convert an Oracle schema to a PostgreSQL schema using AWS SCT
Launch AWS SCT. In AWS SCT, choose File, then choose New Project. Create a new
project called AWS Schema Conversion Tool Oracle to PostgreSQL. Enter the
following information in the New Project window and then choose OK.
An AWS DMS replication instance performs the actual data migration between
source and target. The replication instance also caches the transaction logs during
the migration. How much CPU and memory capacity a replication instance has
influences the overall time required for the migration.
Using an AWS DMS task, you can specify which schema to migrate and the type of
migration. You can migrate existing data, migrate existing data and replicate
ongoing changes, or replicate data changes only. This walkthrough migrates
existing data and replicates ongoing changes.
You can optionally set up a rollback task, in case you run into a show
stopping issue, by creating a task going in the opposite direction. Because all
tables should be in sync between both databases, you only need to set up a
CDC task. Therefore, you do not have to disable any foreign key constraints.
Now that the source and target databases are reversed, you must follow the
instructions in the following sections:
You do not have to disable the foreign key constraints. During the CDC
process, foreign key constraints are updated in the same order as they
are updated by application users.
Create a new CDC-only AWS DMS task with the endpoints reversed (source
PostgreSQL endpoint and target Oracle endpoint database). See Step 7:
Create and Run Your AWS DMS Migration Task.
Start the AWS DMS task to enable you to push changes back to the original
source Oracle database from the new PostgreSQL database if rollback is
necessary.
Prerequisites:
The following prerequisites are required to complete this walkthrough:
Understand Amazon Relational Database Service (Amazon RDS), the
applicable database technologies, and SQL.
Create an AWS account with AWS Identity and Access Management (IAM)
credentials that allows you to launch Amazon RDS and AWS Database
Migration Service (AWS DMS) instances in your AWS Region. For information
about IAM credentials, see Create an IAM User.
Understand the Amazon Virtual Private Cloud (Amazon VPC) service and
security groups. For information about using Amazon VPC with Amazon RDS,
see Amazon Virtual Private Cloud (VPCs) and Amazon RDS. For information
about Amazon RDS security groups, see Amazon RDS Security Groups.
Understand the supported features and limitations of AWS DMS. For
information about AWS DMS, see What Is AWS Database Migration Service?
Understand the supported data type conversion options for Oracle and
PostgreSQL. For information about data types for Oracle as a source,
see Using an Oracle Database as a Source for AWS Database Migration
Service. For information about data types for PostgreSQL as a target,
see Using a PostgreSQL Database as a Target for AWS Database Migration
Service.
Size your target PostgreSQL database host. DBAs should be aware of the load
profile of the current source Oracle database host. Consider CPU, memory,
and IOPS. With RDS, you can size up the target database host, or reduce it,
after the migration. If this is the first time you are migrating to PostgreSQL,
then we recommend that you have extra capacity to account for performance
issues and tuning opportunities.
Audit your source Oracle database. For each schema and all the objects
under each schema, determine if any of the objects are no longer being used.
Deprecate these objects on the source Oracle database, because there's no
need to migrate them if they are not being used.
If load capacity permits, then get the max size (kb) for each LOB type on the
source database, and keep this information for later.
If possible, move columns with BLOB, CLOB, NCLOB, LONG, LONG RAW, and
XMLTYPE to Amazon S3, Dynamo DB, or another data store. Doing so
simplifies your source Oracle database for an easier migration. It will also
lower the capacity requirements for the target PostgreSQL database.
To use AWS DMS to migrate data from an Oracle source database requires some
preparation and we also recommend a few additional steps as best practices.
AWS DMS account – It’s a good practice to create a separate account for the
specific purpose of migrating your data. This account should have the
minimal set of privileges required to migrate your data. Specific details
regarding those privileges are outlined below. If you are simply interested in
testing AWS DMS on a non-production database, any DBA account will be
sufficient.
Supplemental logging – To capture changes, you must enable supplemental
logging in order to use DMS. To enable supplemental logging at the database
level issue the following command.
ALTER DATABASE ADD SUPPLEMENTAL LOG DATA
Additionally, AWS DMS requires for each table being migrated, you set at
least key-level supplemental logging. AWS DMS automatically adds this
supplemental logging for you if you include the following extra connection
parameter for your source connection.
addSupplementalLogging=Y
Step 2: Launch and Prepare Your Aurora MySQL Target
Database
Following are some things to consider when launching your Aurora MySQL instance:
For best results, we recommend that you locate your Aurora MySQL instance
and your replication instance in the same VPC and, if possible, the same
Availability Zone.
We recommend that you create a separate account with minimal privileges
for migrating your data. The AWS DMS account needs the following privileges
on all databases to which data is being migrated.
ALTER, CREATE, DROP, INDEX, INSERT, UPDATE, DELETE, SELECT
Additionally, AWS DMS needs complete access to the awsdms control
database. This database holds information required by AWS DMS specific to
the migration. To provide access, run the following command.
ALL PRIVILEGES ON awsdms_control.* TO 'dms_user'
The AWS DMS service connects to your source and target databases from a
replication instance. Here are some things to consider when launching your
replication instance:
For best results, we recommend that you locate your replication instance in
the same VPC and Availability Zone as your target database, in this case
Aurora MySQL.
If either your source or target database is outside of the VPC where you
launch your replication server, the replication server must be publicly
accessible.
AWS DMS can consume a fair bit of memory and CPU. However, it’s easy
enough to scale up if necessary. If you anticipate running several tasks on a
single replication server or
The default storage is usually enough for most migrations.
Step 4: Create a Source Endpoint
For AWS DMS to access your Oracle source database you’ll need to create a source
endpoint. The source endpoint defines all the information required for AWS DMS to
connect to your source database from the replication server. Following are some
requirements for the source endpoint.
Your source endpoint needs to be accessible from the replication server. To
allow this, you will likely need to modify your firewall rules to whitelist the
replication server. You can find the IP address of your replication server in the
AWS DMS Management Console.
For AWS DMS to capture changes, Oracle requires supplemental logging be
enabled. If you want AWS DMS to enable supplemental logging for you, add
the following to the extra connection attributes for your Oracle source
endpoint.
addSupplementalLogging=Y
Step 5: Create a Target Endpoint
For AWS DMS to access your Aurora MySQL target database you’ll need to create a
target endpoint. The target endpoint defines all the information required for DMS to
connect to your Aurora MySQL database.
Your target endpoint needs to be accessible from the replication server. You
might need to modify your security groups to make the target endpoint
accessible.
If you’ve pre-created the database on your target, it’s a good idea to disable
foreign key checks during the full load. To do so, add the following to your
extra connection attributes.
initstmt=SET FOREIGN_KEY_CHECKS=0
There are a number of simple ways to import data into Amazon RDS, such as with
the mysqldump or mysqlimport utilities for MySQL; Data Pump, import/export or
SQL Loader for Oracle; Import/Export wizard, full backup files (.bak files) or Bulk
Copy Program (BCP) for SQL Server; or pg_dump for PostgreSQL. For more
information on data import and export, please refer to the Data Import Guide for
MySQL or the Data Import Guide for Oracle or the Data Import Guide for SQL
Server or the Data Import Guide for PostgreSQL.