Playbook Migrate from Oracle to Amazon Aurora Postgresql
Total Page:16
File Type:pdf, Size:1020Kb
Oracle Database 11g/12c To Amazon Aurora with PostgreSQL Compatibility (9.6.x) Migration Playbook Version: 1.1, January 2018 Written by: David Yahalom, Nimrod Keinan 1 © 2017, Amazon Web Services, Inc. or its affiliates. All rights reserved. Document written by David Yahalom and Nimrod Keinan. Notices This document is provided for informational purposes only. It represents AWS’s current product offerings and practices as of the date of issue of this document, which are subject to change without notice. Customers are responsible for making their own independent assessment of the information in this document and any use of AWS’s products or services, each of which is provided “as is” without warranty of any kind, whether express or implied. This document does not create any warranties, representations, contractual commitments, conditions or assurances from AWS, its affiliates, suppliers or licensors. The responsibilities and liabilities of AWS to its customers are controlled by AWS agreements, and this document is not part of, nor does it modify, any agreement between AWS and its customers. 2 Introduction To migrate an Oracle database to Amazon Aurora with PostgreSQL Compatibility, you usually need to perform both automated and manual tasks. The automated tasks involve data migration and schema conversion using the AWS Database Migration Service (AWS DMS) and AWS Schema Conversion Tool (AWS SCT). The manual tasks involve post-migration “touch-ups” for certain database objects that can’t be migrated automatically. This whitepaper primarily focuses on the manual aspects of database migration and includes step-by-step instructions that you can adapt for your own requirements. In this document, we focus on how to manually migrate specific Oracle database objects and features to Amazon Aurora with PostgreSQL Compatibility equivalents. We also include a brief overview that explains how to use the AWS Schema Conversion Tool (AWS SCT) for automatic migrations of schema objects. You can use this document as a supplementary guide for your database migrations – both as a guide to expand your PostgreSQL competency if you come from an Oracle database background and as a reference to help build Oracle-comparable functionality in Amazon Aurora with PostgreSQL compatibility This document does not yet cover all Oracle Database features and capabilities from a migration perspective. For the first release, we focus on some of the most important features and will continue to expand the Playbook document over time. Not all Oracle features have direct and fully compatible equivalents in PostgreSQL. In these cases, we present our recommendations for the best-possible equivalent features in Amazon Aurora with PostgreSQL compatibility. We also plan to expand this document in the future and add new chapters specifically dedicated to advanced topics such as Oracle security, High Availability and Disaster Recovery, Performance Tuning, and more. Disclaimer The various code snippets, commands, guides, best practices, and scripts included in this document should be used for reference only and are provided as-is without warranty. Please be sure to test all of the code, commands, best practices, and scripts outlined in this document in a non-production environment first. Amazon and its affiliates are not responsible for any direct or indirect damage that can occur from the information contained in this document. 3 Automatic Schema Migration Help Section Link Using the AWS Schema Conversion Tool for automatic schema conversion SQL & PL/SQL (Manual) Oracle Feature Aurora PostgreSQL Compatibility Feature Link Anonymous Block Do Yes Link Execute Immediate Execute & Prepare Yes Link DBMS_RANDOM random() Yes* Link DBMS_OUTPUT RAISE Yes Link Procedures & Functions Functions Yes* Link User Defined Functions Functions Yes* (UDFs) Link UTL_FILE N/A None Link JSON Document Support JSON Document Support Yes* Link OLAP Functions Window Functions Yes Link PL/SQL Cursors Cursors Yes Link Single Row & Aggregate Single Row & Aggregate Yes Functions Functions Link Merge SQL Merge Yes Link Create Table As Select (CTAS) Create Table As Select (CTAS) Yes Link Common Table Expression Common Table Expression Yes (CTE) (CTE) Link Insert From Select Insert From Select Yes Link Inline Views Inline Views Yes Link DB Hints Query Planning Yes* 4 Tables & Indexes (Manual) Oracle Feature Aurora PostgreSQL Compatibility Feature Link Index Organized Tables (IOTs) PostgreSQL “Cluster” Tables Yes* Link Common Data Types Common Data Types Yes Link Table Constraints Table Constraints Yes Link Table Partitioning including: Table Partitioning including: Yes* RANGE, LIST, HASH, RANGE, LIST COMPOSITE, Automatic LIST Link Exchange and Split Partitions N/A None Link Temporary Tables Temporary Tables Yes* Link Unused Columns ALTER TABLE DROP COLUMN Yes Link Virtual Columns Views and/or Function as a Yes* Column Link User Defined Types (UDTs) User Defined Types (UDTs) Yes Link Read Only Tables and Table Read Only Roles and/or Yes* Partitions Triggers Link Index Types Index Types Yes* Link B-Tree Indexes B-Tree Indexes Yes Link Composite Indexes Multi-Column Indexes Yes Link BITMAP Indexes BRIN Indexes Minimal Link Function-Based Indexes Expression Indexes Yes Link Local and Global Partitioned Partitioned Indexes Yes* Indexes Link Identity Columns Serial Data Type Yes* Link MVCC MVCC Yes* (Table and Row Locks) (Table and Row Locks) Link Character Sets Encoding Yes* Link Transaction Model Transactional Model Yes* Link LOBs and SecureFile LOBs LOBs Yes* Database Objects (Manual) Oracle Feature Aurora PostgreSQL Compatibility Feature Link Materialized Views Materialized Views Yes* Link Common Data Types Common Data Types Yes Link Oracle Triggers PostgreSQL Trigger Procedure Yes* Link Views Views Yes Link Sequences Sequences Yes 5 Link Database Links PostgreSQL DBLink and Yes* FDWrapper 6 Database Administration (Manual) Oracle Feature Aurora PostgreSQL Compatibility Feature Link Recovery Manager (RMAN) Amazon Aurora Snapshots Yes Link Flashback Database Amazon Aurora Snapshots Yes Link 12c Multi-Tenant Databases Yes* Architecture: PDBs and CDB Link Tablespaces and DataFiles Tablespaces Yes* Link Data Pump pg_dump and pg_restore Yes Link Resource Manager Separate Amazon Aurora Yes Clusters Link Database Users Database Roles Yes Link Database Roles Database Roles Yes Link SGA & PGA Memory Memory Buffers Yes Link V$ Views & the Data System Catalog Tables, Yes* Dictionary Statistics Collector, Amazon Aurora Performance Insights Link Log Miner Logging Options Yes Link Instance & Database Amazon Aurora Parameter Yes Parameters (SPFILE) Groups Link Session Parameters Session Parameters Yes Link Alert.log (error log) Error Log via AWS Yes Management Console Link Automatic and Manual Automatic and Manual Yes Statistics Collection Statistics Collection Link Viewing Execution Plans Viewing Execution Plans Yes 7 Automatic Migration of Oracle Schema Objects Using the AWS Schema Conversion Tool 8 Automatic Schema Migration [Back to TOC] This section provides a step-by-step process for using the AWS Schema Conversion Tool (AWS SCT) to migrate an Oracle database to an Aurora with PostgreSQL compatibility database cluster. Amazon SCT can automatically migrate most of the database objects. While this document primarily covers the best practices, feature-parity aspects of manual database migrations, and Oracle to Amazon Aurora with PostgreSQL compatibility migration best practices, we recommend using AWS SCT as the first step of the process. AWS SCT is a downloadable Java utility that runs locally on your computer. It connects to the source and target databases, scans the source database schema objects (tables, views, indexes, procedures, etc.), and converts them to the target database objects. For more information, see http://docs.aws.amazon.com/SchemaConversionTool/latest/userguide/Welcome.html 9 Download AWS SCT and Install JDBC Drivers JDBC drivers are required for database connectivity to both the source and target databases. 1. Download SCT: http://docs.aws.amazon.com/SchemaConversionTool/latest/userguide/CHAP_SchemaConversionTool.Installing.h tml 2. Download the Oracle JDBC Driver (ojdbc7.jar): http://www.oracle.com/technetwork/database/features/jdbc/jdbc-drivers-12c-download-1958347.html 3. Download the PostgreSQL JDBC Driver (postgresql-9.4-1204.jdbc42.jar): https://jdbc.postgresql.org/download.html Configure SCT for Database Migration 1. Launch SCT. 2. Choose the JAR files path under SCTs Global Settings 3. Click Global Settings > Drivers 4. Add the file path to the Oracle and the PostgreSQL JDBC drivers 5. Use the following filenames: Oracle JDBC JAR - ojdbc7.jar PostgreSQL JDBC JAR - postgresql-9.4-1204.jdbc42.jar 6. Click OK. 10 AWS SCT – Database Migration Project Configuration Create a new SCT project which will guide you, step-by-step, through the schema conversion process. 1. Click SCT > File > New Project Wizard 2. Select a source database for migration (the Oracle Database to migrate to Aurora with PostgreSQL Compatibility). 3. Enter a project name, specify the location of the SCT project files, choose the source database workload characteristics (OLTP or OLAP), and select the source database engine (Oracle). 11 4. Configure the source database connection properties: • Server hostname • Oracle Net Listener port number • Oracle Database SID • Privileged username and password. For example, the Oracle system user. 5. Click Next. 6. Select the source Oracle schema for migration. 12 7. SCT analyzes the source