Skip to main content
BLOG

Migrating Oracle to AlloyDB for PostgreSQL on Google Cloud Platform (GCP) – A Walkthrough of Heterogeneous Migrations

By February 27, 2025No Comments
oracle to AlloyDB for AlloyDB for PostgreSQL
Migrating Oracle to AlloyDB

O’Reilly’s recent Cloud Adoption Report stated that 48% of organizations plan on migrating at least half of their applications to the cloud and 20% want to move all their applications to the cloud. By leveraging a heterogeneous migration, businesses can gain significant cost savings, scalability, and flexibility. As companies look to migrate, the right solutions and services are key to unlocking real benefits. This blog outlines the best practices for migrating Oracle to AlloyDB for PostgreSQL on the Google Cloud Platform (GCP) including assessment, schema conversion, data migration, and performance optimization, as well as frameworks and solutions.

Ensure data integrity with efficient database migration.

A heterogeneous migration, such as migrating from Oracle to AlloyDB for PostgreSQL on the Google Cloud Platform (GCP), involves moving between two different kinds of database engines with distinct architecture and types. AlloyDB for PostgreSQL, an open-source RDBMS, offers enterprise-grade features comparable to Oracle without the licensing costs.  Migrating to AlloyDB for PostgreSQL on GCP allows businesses to integrate Google Cloud services seamlessly, improving automation, security, and analytics. 

Migration Challenges

There are various obstacles for businesses to overcome while switching from Oracle to AlloyDB for PostgreSQL, which call for thorough preparation and migration management. These include:

  • Schema Differences: Oracle’s proprietary features (PL/SQL, sequences, packages) need transformation.
  • Data Type Mapping: Some Oracle types have no direct AlloyDB for PostgreSQL equivalent.
  • Stored Procedures & Triggers: Oracle’s PL/SQL must be converted to PL/pgSQL.
  • Performance Tuning: Query execution plans differ between Oracle and AlloyDB for PostgreSQL.
  • Application & ETL Impact: Application dependencies may need code modifications.

A successful migration can be ensured with thorough testing, automation tools, and a systematic approach. 

Migration Approach

Simplifying the migration of Oracle to AlloyDB for PostgreSQL is done by using structured evaluation, data migration, schema conversion, and optimization. 

 Oracle to AlloyDB for Postgres

Image 1: Oracle to AlloyDB For Postgres Migration Architecture on Google Cloud

Assessment & Planning

To determine the optimal migration plan, businesses need to evaluate factors that can build or break the migration strategy. These include:

Comprehensive Infrastructure Analysis: 

  • Analyze Oracle Schema: Begin by thoroughly examining the Oracle database schema, including tables, data types, constraints, and relationships. Understand how indexes are defined and their impact on query performance.
  • Stored Procedures & Functions: Identify all stored procedures, triggers, and PL/SQL scripts to check compatibility with AlloyDB for PostgreSQL’s PL/pgSQL. Make note of any proprietary Oracle features or functions that might require modifications or replacements.
  • Dependencies and External Connections: Map out all dependencies, such as foreign keys, references, and external integrations. Also, review network connections, data pipelines, or ETL jobs that may need adjustment in the target AlloyDB setup.

Compatibility: 

Tools for Compatibility Check: Use tools like Ora2Pg or AWS Schema Conversion Tool (SCT) to automate parts of the migration. These tools help in:

  • Schema Conversion: Automatically convert Oracle-specific data types to their AlloyDB for PostgreSQL equivalents (e.g., NUMBER to INTEGER or NUMERIC).
  • Functionality Mapping: They also assist in converting PL/SQL code to PL/pgSQL, identifying and handling Oracle-specific functions, and suggesting the best alternatives in AlloyDB for PostgreSQL.
  • Issue Detection: Highlight any compatibility issues or performance optimizations that may need re-engineering.

Drawing up the Right Strategy:  This strategy involves migrating the Oracle database to AlloyDB with minimal modification to the schema, queries, and stored procedures.

  • Re-Engineering (Optimization for AlloyDB for PostgreSQL): This involves more extensive changes to the Oracle schema, queries, stored procedures, and overall architecture to optimize them for AlloyDB for PostgreSQL features.
  • Network and Access: Ensure that all network rules, IP access lists, and firewall settings are configured properly for the Oracle and AlloyDB instances to communicate seamlessly.
  • Database Sizing: Calculate resources like vCPU, RAM, and storage needed for the target database.

Schema Conversion

Transform Oracle objects into AlloyDB for PostgreSQL equivalents while compatibility and performance are ensured.

  • Convert tables, indexes, constraints, and sequences.
  • Translate Oracle NUMBER to AlloyDB for PostgreSQL NUMERIC/INTEGER.
  • Replace Oracle CLOB/BLOB with TEXT/BYTEA.
  • Convert PL/SQL to PL/pgSQL using tools like Ora2Pg.
  • Convert Oracle Synonyms & Packages to AlloyDB for PostgreSQL Schemas & Functions.

Data Migration

Businesses can reduce downtime and facilitate seamless data transfer with the right cloud-native migration services.

Google Cloud’s Data Migration Service, for example, simplifies database migrations by streamlining networking workflows, managing initial snapshots, and data replication. It provides the status of the migration operations, allowing users to track progress.  In addition, continuous data replication results in minimal downtime, allowing Database Migration Service to migrate your data without disruptions.

Application & Query Optimization

  • Stored procedures can now be converted 
  • Performance can now be improved with SQL Query optimization 

Post-Migration Validation & Optimization

Post-migration validations are to be conducted to ensure the accuracy and integrity of data after migration. These checks include: 

  • Data Validation: Verifying the accuracy and completeness of migrated data.
  • Row Count: Ensuring the number of rows in the source and destination are identical.
  • Column Count: Comparing the number of columns between source and destination.
  • Column Name Validation: Confirm that column names match between the source and destination tables.
  • Datatype Comparison: Ensuring data types are consistent across the source and destination.
  • Column Not-null Check: Verifying that non-null constraints are properly maintained.
  • Column Not-null Count: Ensuring the count of non-null columns is consistent across source and destination tables.
  • Index Count: Confirming the number of indexes is the same on both source and destination.
  • Index Name Validation: Ensuring index names are preserved post-migration.
  • Foreign Key Count and Name Validation: Ensuring that foreign key constraints and their names are consistent.

Niveus Utilities 

Our framework for migration: Google Cloud Database Migration Service is used to migrate your data from Oracle to Postgres. This service helps you lift and shift your Oracle workloads into AlloyDB for PostgreSQL. Alternatively, we can utilize ora2pg to migrate the schema from Oracle to AlloyDB for PostgreSQL.

Other frameworks you can consider include- 

  • Oracle GoldenGate: A real-time data application that enables seamless migration from Oracle to AlloyDB for PostgreSQL while ensuring data consistency. 
  • Debezium: An open-source platform that captures data changes and tracks and streams real-time changes from Oracle to AlloyDB for PostgreSQL with the least disruption.
  • Striim: A platform that integrates and streams data in real-time. It facilitates continuous data migration from Oracle to AlloyDB for PostgreSQL with its built-in transformative capabilities. 

Our QA utility: We use our in-house Data validation utility to validate the post-migration data. This utility performs the following validations: row count, Data Validation, Column Count, Column Name Validation, Datatype Comparison, Column Not-null Check, Column Not-null Count, Index Count, Index Name Validation, Foreign Key Count, and Name Validation.

This data validation utility generates a summary report outlining whether each check (e.g., row count, column count, data type comparison) has passed or failed. This provides an overview of the migration status at a glance. The report captures any errors or mismatches, such as data type differences, column name mismatches, or missing indexes. This allows the team to understand the exact nature of migration issues and focus on resolving them quickly.

Heterogenous Migration from Oracle to AlloyDB

Pre-Cutover Preparation

Oracle (Source Database)

  • Backup: Take a full backup of the Oracle database before starting the migration.
  • Identify Changes: Ensure that the change data capture (CDC) mechanism is set up correctly on Oracle (using Oracle’s redo logs, for example).
  • Data Consistency: Make sure that there are no ongoing transactions or uncommitted data that might impact consistency during migration.

AlloyDB for PostgreSQL (Target Database)

  • Provision AlloyDB: Set up your AlloyDB instance in Google Cloud and make sure it’s fully configured.
  • Schema Creation: Create the required schema and tables in AlloyDB for the target data. Use tools like pg_dump or AlloyDB’s native tools to help set up the schema or migrate existing data.
  • Network and Access: Ensure that all network rules, IP access lists, and firewall settings are configured properly for the Oracle and AlloyDB instances to communicate seamlessly.
  • Bandwidth & Connectivity: Use Cloud Interconnect or VPN to on-premise for secure connection. Ensure you have sufficient bandwidth for seamless migration. 
  • Performance Tuning: Optimize performance on AlloyDB by setting up indexes, storage, and maintenance plans.

Google Cloud Database Migration Service (DMS) Setup

  • Source and Target Database Connectivity: Test and validate the connection between Oracle and AlloyDB through DMS.
  • CDC Configuration: Set up the Change Data Capture (CDC) replication on DMS. Choose “Continuous Data Replication” for capturing changes from Oracle in near real-time.
  • Data Validation: Perform an initial data validation to ensure DMS can properly capture and replicate the changes from Oracle to AlloyDB for Postgres.

Test Migration (Dry Run)

  • Test Runs: Run multiple test migrations to ensure that data is replicated correctly from Oracle to AlloyDB for Postgres.
  • Check Latency: Monitor the CDC replication latency during these tests to ensure that changes are being captured and applied promptly.
  • End-to-End Validation: Check for data consistency, missing data, or replication failures. Ensure that the migration setup is fully functional before proceeding with the production cutover.

Cutover Planning

  • Business Coordination: Ensure the cutover is scheduled during a low-traffic period (e.g., off-hours or a weekend) to minimize business disruption.
  • Inform Stakeholders: Communicate with all stakeholders (DBA, development, operations, etc.) about the cutover schedule, impact, and expected downtime.
  • Data Sync: Initiate the final sync between Oracle and AlloyDB for Postgres to ensure all recent changes from Oracle are captured by DMS.
  • Freeze Changes: If required, freeze writes to the Oracle database to prevent any changes after this sync, minimizing the risk of data inconsistency.
  • Last Check: Verify that all tables, data, and indexes have been replicated to AlloyDB for Postgres.

Production Cutover Execution

Switching to AlloyDB

  • Database Redirection: Change application connections to point to the new AlloyDB instance. Ensure all application queries are redirected to AlloyDB for Postgres instead of Oracle.
  • Test Critical Application Flows: Ensure that the application runs as expected with the new AlloyDB database and monitor for any errors or slow queries.
  • Monitor DMS Status: Use Google Cloud DMS monitoring tools to ensure that CDC replication is functioning correctly and new changes from Oracle are still being captured if there’s any need for post-cutover syncing.

Post-Cutover Validation

  • Data Integrity Check: Compare data between Oracle and AlloyDB for Postgres for any discrepancies.
  • Application Testing: Perform smoke tests to validate that key application functionalities are working as expected.
  • Performance Tuning: Monitor performance on AlloyDB and optimize it if needed (e.g., adjusting queries, indexing, or resource allocation).

Decommission Oracle Database

  • Stop Replication: Disable any ongoing replication from Oracle to AlloyDB.
  • Oracle Shutdown: Once confident that all data has been replicated successfully and is accessible in AlloyDB, shut down the Oracle database or archive it for backup purposes.
  • Data Backup: Ensure that a backup of the Oracle database is taken before decommissioning it permanently.

Support and Monitoring

  • Monitor Logs: Continuously monitor the migration and replication logs for errors or performance issues.
  • CDC Latency: Track CDC latency to ensure changes from Oracle are properly applied in real-time.
  • Resource Utilization: Keep an eye on AlloyDB’s resource usage (e.g., CPU, memory, disk I/O) to ensure it’s not under excessive load.
  • End-User Feedback: Gather feedback from end-users to identify any issues or performance bottlenecks.
  • Fine-Tune Queries: If certain queries are slow, consider optimizing them on AlloyDB (e.g., through indexing, query rewriting, or partitioning).

Rollback Plan

  • Backup: Ensure that you have a backup of the Oracle database and the AlloyDB state before the cutover.
  • Failback to Oracle: If critical issues arise post-cutover, prepare to failback to the Oracle system. This can involve:
    • Repointing applications back to Oracle.
    • Rolling back recent changes on AlloyDB.
    • Re-establishing the replication process in reverse.

Advantage/Benefits

  • Reduced Infrastructure & Licensing Costs: Moving from on-premise Oracle to AlloyDB eliminates the need for expensive on-prem hardware, storage, and maintenance. AlloyDB operates on Google Cloud, which means pay-as-you-go pricing for compute and storage resources, potentially leading to cost savings. Oracle licenses can be costly, and by migrating to AlloyDB, you can eliminate or reduce the ongoing Oracle license fees.
  • Elastic Scaling & High Availability: AlloyDB on Google Cloud allows you to scale compute, storage, and memory resources based on your application’s requirements. As your data grows, AlloyDB can scale easily without manual intervention. AlloyDB supports built-in high availability with automatic failover, replication, and backup capabilities, ensuring your applications remain highly available.
  • Fully Managed Service & Operational Efficiency: AlloyDB is a fully managed database service, so you don’t need to worry about database patching, backups, or replication. Google Cloud DMS helps automate the migration and ongoing data replication, simplifying database management. Automating operational tasks like database backups, scaling, and monitoring through Google Cloud’s native tools can lead to reduced operational overhead.
  • Built-in Security Features: AlloyDB provides robust security features, including encryption at rest and in transit, identity, and access management (IAM), and integration with Google Cloud’s security offerings like Cloud Identity and Cloud Key Management.
  • Seamless Migration with DMS & Zero Downtime: Google Cloud Database Migration Service makes it easier to migrate from Oracle to AlloyDB with minimal downtime. The service supports continuous data replication, allowing you to migrate data in near real-time while keeping both systems in sync until cutover. By leveraging Change Data Capture, you can minimize downtime during the migration. This allows you to maintain business continuity as data is replicated incrementally until you switch over to AlloyDB.

What Niveus Brings to the Table?

  • Oracle & AlloyDB for AlloyDB for PostgreSQL Database Expertise: In-depth knowledge of Oracle database structures, performance tuning, and optimization. Prepare the database for migration, including understanding PL/SQL procedures, triggers, and data types. Understanding AlloyDB data types, schema design, queries, and indexing strategies, as Oracle and AlloyDB for AlloyDB for PostgreSQL have different architectures and syntax.
  • Google Cloud Platform (GCP) Expertise: Proficiency with Google Cloud services, Google Cloud Database Migration Service (DMS), Compute Engine, Cloud Storage, IAM, and Cloud Monitoring to configure and manage the migration infrastructure.
  • Schema Conversion Skills: Schema conversion is needed to migrate Oracle’s data types, tables, constraints, and stored procedures to AlloyDB-compatible AlloyDB for PostgreSQL schemas.
  • Data Validation and Testing: Expertise in data validation techniques to compare and verify data integrity between Oracle and AlloyDB.
  • Performance Tuning and Optimization: Ability to optimize the performance of AlloyDB after migration, including query optimization, indexing strategies, and resource allocation for optimal database performance.
  • Database Backup and Disaster Recovery Plans: Knowledge of setting up backup and disaster recovery mechanisms for AlloyDB in Google Cloud to ensure data integrity and business continuity during migration and beyond.

Conclusion

Migrating from Oracle to cloud AlloyDB Postgres offers scalability, cost-efficiency, and improved performance. The migration process can be streamlined with proper planning, data migration service tools, and post-migration checks. By ensuring data integrity, minimizing downtime, and leveraging cloud benefits, businesses can enhance their operations and take advantage of flexible, secure, and easily manageable cloud environments.

Migrate with ease with Niveus

Deepak Kumar

Author Deepak Kumar

Deepak Kumar is a Cloud Expert specializing in data migration. With a strong focus on Database Migration Services (DMS), he helps businesses seamlessly transition their databases to the cloud, ensuring efficiency, security, and minimal downtime.

More posts by Deepak Kumar
We use cookies to make our website a better place. Cookies help to provide a more personalized experience and web analytics for us. For new detail on our privacy policy click on View more
Accept
Decline