AWS Database Blog

Data migration strategies to Amazon RDS for Db2

Amazon announced Amazon Relational Database (Amazon RDS) for Db2 at re:Invent 2023. RDS for Db2 is the latest addition to the Amazon RDS family of database engines. You can deploy a Db2 database on scalable hardware in minutes designed for optimal performance with an optional highly available database using a Multi-AZ deployment, which synchronously replicates data to a standby database instance in a different Availability Zone.

In this post, we explain the steps to migrate self-managed Db2 databases using the built-in capabilities of Amazon RDS for Db2 and with AWS Database Migration Service (AWS DMS) or Db2 Migration Tooling (Db2MT). We start by providing an overview of various migration strategies you may employ, then discuss the migration methods, and conclude with best practices for planning the migration.

Migration strategy

The migration strategy depends on the operating system of the self-managed Db2 database. When the operating system of the source and destination databases is the same (for example, Linux to Linux), we describe the migration as rehosting. If the source database’s operating system is different from the destination database’s (for example, z/OS to Linux), we describe the migration as replatforming. The following table summarizes the details of rehosting and replatforming based on the underlying operating system of the source database.

Migration Strategy Rehost Replatform Remark
Operating System Linux Other than Linux such as z/OS, AIX, Windows You may use native IBM Db2 migrations tools, DMS, or third party
Speed of migration Faster Slower Rehosting is faster because it requires no conversion; Replatforming requires conversion and takes longer
Db2 Offline restore Yes No Use Db2 backup and restore; requires downtime till the restore completes
Db2 Online restore Yes No Use Db2 backup and restore with roll forward; requires minimal downtime, may take longer to complete
Db2 Export or Import Yes Yes Use Db2 export and import for logical migrations; takes longer with re-platforming due to conversion
Load from Client Yes Yes Use Db2
Load from Amazon S3 Yes Yes Fast speed for replatforming
AWS DMS Yes Yes Replication
IBM CDC Replication Yes Yes Replication
IBM Q Replication Yes Yes Replication
Fidelity of Metadata+ High Medium Extra care required for fidelity for replatform
Quality of Data High Medium Extra care required for quality for replatform
Ease of Use Simple Complex Rehosting is easier
Implementation Effort Low High Significant effort for replatform

+The metadata from source to target may not get the exact depiction based on the method of reconstructing the database schema. The example includes a missing starting point for identity, sequence, hidden columns, check constraints, and foreign key constraints enforcements.

Rehost with Amazon RDS

You can rehost with Amazon RDS for Db2 if the self-managed Db2 database runs on a supported Linux platform using little endian. For example, you can rehost self-managed Db2 from Linux on Intel, AMD, and Linux POWER LE (little endian) but not from AIX, zLinux, or Windows.

Replatform with Amazon RDS

When the self-managed Db2 operating system is different than Linux (LE), you’ll be replatforming the source Db2 database to Amazon RDS for Db2. You can replatform with Amazon RDS for Db2 if the self-managed Db2 database runs on operating systems such as AIX, Windows, or zLinux. Replatforming with Amazon RDS is often seen as a first step in a broader migration journey, allowing organizations to quickly move their databases to Amazon RDS for Db2 and then consider gradual optimizations or re-architecting in the future.

Migration methods for rehosting and replatforming with Amazon RDS for Db2

Your choice of a migration method would depend on the type of source Db2 operating system and acceptable downtime. We recommend that you determine the migration speed from your self-managed Db2 database to Amazon RDS for Db2 by doing a test migration of a reasonable size of your database to know the end-to-end time of migration. You can choose from either a one-time migration or a migration with a log replication approach depending on the downtime you can tolerate. You may refer the following decision tree to select the appropriate replication method based on your business needs.

Rehost with Amazon RDS

You can rehost with Amazon RDS for Db2 if the self-managed Db2 database runs on a supported Linux distribution. Migrating from Linux is simpler and quicker than re-platforming as it involves no data conversion. We rely on Db2’s native tooling and avoid complex data structure changes and optimization.

One-time migration

If the overall time for backing up the database, restoring it, and cutting over is within your acceptable downtime, you can use a one-time migration. Use Db2 Migration Tooling (Db2MT) for copying the self-managed Db2 Linux database backup directly on Amazon Simple Storage Service (Amazon S3), and then restore it on Amazon RDS for Db2. Db2MT creates the scripts you’d need to complete the migration and parallelizes both the backup and restore to speed up the migration. The following diagram illustrates the solution architecture.

If you are manually performing the migration, you can invoke the RDS for Db2 stored procedure restore_database to restore the offline backup from Amazon S3.

Migration with log replication

If the measured migration time through an initial test migration takes longer than the acceptable downtime, then you can use migration with log replication from self-managed Db2 on Linux to Amazon RDS for Db2 by using the A/B deployment approach. In this approach, you can use the new RDS for Db2 database (A) alongside the old database (B) and switch over when ready.

Db2MT provides steps for taking an online database backup of self-managed Db2 on Linux direct to Amazon S3 and then restoring it on Amazon RDS for Db2, as described in the previous section. Db2MT also provides steps to periodically archive logs direct to Amazon S3 and then apply the logs to the RDS for Db2 database by keeping the database in roll-forward pending mode. You can do a final cutover by completing the roll-forward operation. The following diagram illustrates the solution architecture.

You can use the RDS for Db2 stored procedure restore_database to restore the online backup image by setting the backup_type to ONLINE. You can use the RDS for Db2 stored procedure rollforward_database to apply the archive logs. When you’re ready to cut over, you can run the stored procedure complete_rollforward to complete database recovery and make the RDS for Db2 database available for connections.

Replatform with Amazon RDS

The other key challenge is to migrate data from AIX, Windows, and Mainframe Db2 on Linux (Big Endian) with speed and near-zero downtime. Replatforming with Amazon RDS will take more time compared to rehosting because you can’t restore the Db2 backup image from AIX, Windows, and Mainframe Db2 on Linux due to little and big-endian differences.

You need to extract the metadata from the source Db2 database and then apply it to Amazon RDS for Db2. The best method is to use the native tool db2look, which provides the best fidelity of the metadata compared to other reverse engineering methods used by third-party tools.

You can use Db2 native tools such as export to unload the data and use native tools such as import or load to migrate from the source to the RDS for Db2 database. Refer to the following diagram for the relative speed of migration.

AWS DMS is a managed service that simplifies the process of migrating self-managed Db2 databases to Amazon RDS for Db2. AWS DMS announced support for Db2 as a target endpoint and it supports both full load and change data capture (CDC) migration modes for Amazon RDS for Db2.

Alternatively, Db2MT allows you to extract the metadata and unload the data. You can create database objects using the metadata and then use Db2MT to load data to Amazon RDS for Db2 directly from Amazon S3. These tasks are automated, and you can use simple Db2MT commands to initiate each task without getting into the complexities of extract and parallelization processes.

We recommend that you determine the migration speed by doing a sample migration of a reasonable size of your database. This can help you determine if you should use a one-time migration or migration with log replication.

One-time migration

If the combined time including cutover is within your acceptable downtime, you can opt for a one-time migration. We recommend using Db2MT for migrating from AIX or Windows and loading the data to Amazon RDS for Db2. The following diagram illustrates the solution architecture.

Amazon RDS for Db2 provides native support for loading data directly from Amazon S3. Db2MT uses DB2REMOTE identifiers through the use of storage access for Amazon S3 for loading data directly from Amazon S3 using a Db2 client connected to Amazon RDS for Db2.

Migration with log replication

If the measured migration time through an initial test migration is outside the outage window, you can use migration with log replication from self-managed Db2 on AIX or Windows to Amazon RDS for Db2.

Follow the previous step of using Db2MT to complete the one-time migration. You can use one of the following methods to accomplish a near-zero downtime migration:

  • AWS DMS – AWS supports Db2 as a source and a target. With an AWS DMS replication instance, you can synchronize changes from the source Db2 database to Amazon RDS for Db2.
  • IBM Q Replication – You can use IBM Q Replication for near-zero downtime migrations from AIX, Windows, and Mainframe Db2 running on Linux BE.

The following diagram illustrates the solution architecture.

Migration project planning

The data migration process requires careful planning to ensure fidelity of the metadata; ensure integrity and quality of the data; address performance concerns, cost management, and integration using existing Amazon RDS services such as AWS DMS; address legacy application support, network bandwidth, business continuity, and disaster recovery; and secure access. Each migration task is worthy of a proper project plan including the following phases:

  • Preparation and planning:
    • Analyze the database size and complexity – Understand the size of the database and the complexity of the data. This helps in estimating the time required and the resources needed for the migration.
    • Identify peak and off-peak hours – Schedule the migration during off-peak hours to minimize the impact on users.
  • Testing:
    • Test the migration process – Conduct thorough testing in a staging environment to identify potential issues and refine the migration process.
    • Performance testing – Test the migration process under load to ensure it can handle the actual data transfer efficiently.
  • Incremental migration:
    • Migrate data in phases – Instead of migrating all data at once, consider breaking it into smaller chunks. This approach reduces the risk and can improve speed.
    • Replication – Use database replication to keep the new database in sync with the old one until the final switchover.
  • Monitoring and backup:
    • Continuous monitoring – Closely monitor the migration process for any issues or performance bottlenecks.
    • Backup – Always have a backup of the original database to fall back on in case something goes wrong.
  • Final cutover and validation:
    • Switchover – After you ensure that all data is accurately transferred and the new system is ready, make the final cutover.
    • Post-migration validation – Perform thorough checks to ensure the data integrity and performance of the new system.

Each database migration is unique, and the preceding strategies should be tailored to your specific circumstances and requirements. Additionally, involving a team of experienced database administrators and engineers is crucial for a smooth and efficient migration process.

Conclusion

In this post, we showed you rehosting and replatforming strategies to migrate from Db2 to Amazon RDS for Db2. The rehosting represents a straightforward, time-efficient approach for organizations aiming to transition to Amazon RDS for Db2 with minimal modifications to their existing systems by using Db2MT. The replatforming strategy uses either AWS DMS with full load and CDC or Db2MT with IBM Q Replication.

Both strategies offer the immediate benefits of fully managed Amazon RDS for Db2, such as enhanced scalability and potential cost savings, without the complexities of altering the core architecture or functionality of the applications. Rehosting or replatforming with Amazon RDS provides a stepping stone in your journey to AWS and sets the stage for future modernization and optimization initiatives.

We invite you to comment on this post and leave suggestions for future posts about Amazon RDS for Db2. Review the Amazon RDS for Db2 User Guide to learn more about the service.


About the author

Vikram S Khatri is a Sr. Product Manager for Amazon RDS for Db2. Vikram has over 20 years of experience in Db2. He enjoys developing new products from the ground up. In his spare time, he practices meditation and enjoys listening to podcasts.