Migrating from Linux to Linux for Amazon RDS for Db2
Migrating from on-premises Linux to Amazon RDS for Db2 (deployed on Linux only) requires you to back up your self-managed Db2 database to an Amazon S3 bucket. Then, you use Amazon RDS stored procedures to restore your Db2 database to an RDS for Db2 DB instance. For more information about using Amazon S3, see Integrating an Amazon RDS for Db2 DB instance with Amazon S3.
Backup and restore for RDS for Db2 follows the IBM Db2 Db2 supported upgrade paths and
restrictions. For more information, see Supported upgrade paths for Db2 servers
Topics
Limitations and recommendations
The following limitations and recommendations apply to the three restore paths: same-version restore, version-upgrade restore, and near-zero downtime restore. The matrix below shows which apply to each approach. A value of Applies indicates that the item applies to that approach. Not applicable indicates that the item doesn't apply to that approach.
| No. | Limitation or recommendation | Restore (same version) | Restore (version upgrade) | Restore (near-zero downtime) |
|---|---|---|---|---|
| 1 | Supports offline and online backups. No incremental or Delta backups. The on-premises and RDS for Db2 versions must match. | Applies | Not applicable | Not applicable |
| 2 | Supports offline only backups. No incremental or Delta backups. | Not applicable | Applies | Not applicable |
| 3 | Supports an online only backup (database kept in rollforward-pending while archive logs upload). The on-premises and RDS for Db2 versions must match. | Not applicable | Not applicable | Applies |
| 4 | No cross-Region restore (the Amazon S3 bucket must be in the same Region as the DB instance). | Applies | Applies | Applies |
| 5 | Amazon S3 limits the size of uploaded files to 5 TB. Split larger backup files. | Applies | Applies | Applies |
| 6 | No non-fenced external routines, incremental restores, or Delta restores. | Applies | Applies | Applies |
| 7 | No restore from an encrypted source (you can restore to an encrypted Amazon RDS instance). | Applies | Applies | Applies |
| 8 | USE_STREAMING_RESTORE affects storage sizing.
TRUE streams the backup. FALSE downloads and
extracts the backup. |
Applies | Applies | Applies |
| 9 | The maximum restored database size equals the maximum supported size minus temporary restore space. | Applies | Applies | Applies |
Post-restore hardening applies to all restore paths:
-
RDS for Db2 revokes authorities higher than
DBADMand caps the master user atDBADM. -
The restore process sets the database configuration parameter
connect_procto null. -
The restore process applies archive logging or circular logging based on the native backup image setting.
-
The restore process removes audit policies and cataloged storage-access aliases that are carried in the backup image.
Backing up your database to Amazon S3
To back up your database on Amazon S3, you need the following AWS components:
-
An Amazon S3 bucket to store your backup files: Upload any backup files that you want to migrate to Amazon RDS. If you already have an Amazon S3 bucket, you can use that bucket. If you don't have an Amazon S3 bucket, see Creating a bucket in the Amazon S3 User Guide.
-
An IAM role to access the Amazon S3 bucket: If you already have an AWS Identity and Access Management (IAM) role, you can use that role. If you don't have a role, see Step 2: Create an IAM role and attach your IAM policy.
-
An IAM policy with trust relationships and permissions attached to your IAM role: For more information, see Step 1: Create an IAM policy.
-
The IAM role added to your RDS for Db2 DB instance: For more information, see Step 3: Add your IAM role to your RDS for Db2 DB instance.
If your database is large and would take a long time to transfer to an Amazon S3 bucket, you can order an AWS Snow Family device and ask AWS to perform the backup. After you copy your files to the device and return it to the Snow Family team, the team transfers your backed-up images to your Amazon S3 bucket. For more information, see the AWS Snow Family documentation.
Creating a default automatic storage group
Your source database must have a default automatic storage group. If your database doesn't have a default automatic storage group, you must create one.
To create a default automatic storage group
-
Connect to your source database. In the following example, replace
source_databasewith the name of your database.db2 connect tosource_database -
Create an automatic storage group and set it as the default. In the following example, replace
storage_pathwith the absolute path to where the storage group is located.db2 "create stogroup IBMSTOGROUP ONstorage_pathset as default" -
Terminate the backend process by running the following command.
db2 terminate
Restoring your Db2 database (same version or version upgrade)
After you back up your database on Amazon S3 and create an automatic storage group, you are ready to restore your Db2 database to your RDS for Db2 DB instance.
To restore your Db2 database from your Amazon S3 bucket to your RDS for Db2 DB instance
-
Back up your database on premises.
-
To prepare for backup, deactivate the database and stop all database services. In the following example, replace
source_databasewith the name of the database that you created the storage group for.db2 deactivate dbsource_database -
Back up the database. In the following example, replace
source_databasewith the name of the database that you created the storage group for. Replacefile_system_pathwith the absolute path to where you want to back up the database. After the backup is complete, copy the backup file to your Amazon S3 bucket. For more information, see BACKUP DATABASE commandin the IBM Db2 documentation. db2 backup databasesource_databasetofile_system_path
-
-
Connect to the
rdsadmindatabase with themaster_usernameandmaster_passwordfor your RDS for Db2 DB instance.db2 "connect to rdsadmin usermaster_usernameusingmaster_password" -
(Optional) To ensure that your database is configured with the optimal restore settings, check the values for the following parameters by calling rdsadmin.show_configuration:
-
RESTORE_DATABASE_NUM_BUFFERS -
RESTORE_DATABASE_PARALLELISM -
RESTORE_DATABASE_NUM_MULTI_PATHS -
USE_STREAMING_RESTORE
Use rdsadmin.set_configuration to modify these values as needed. Properly configuring these parameters can improve performance when you restore databases with large volumes of data. Set
USE_STREAMING_RESTOREtoTRUEto reduce storage requirements and improve restoration speed compared to downloading and extracting the full backup file. -
-
To restore your database, call rdsadmin.restore_database.
Restoring your Db2 database with near-zero downtime
With near-zero downtime restore, Amazon RDS keeps your database in a rollforward-pending state as you upload your archived transaction logs, which helps prevent disruptions to ongoing operations.
To back up and restore your database for near-zero downtime migration
-
Perform an online backup of your source database. For more information, see BACKUP DATABASE command
in the IBM Db2 documentation. -
Copy the backup of your database to an Amazon S3 bucket. For information about using Amazon S3, see the Amazon Simple Storage Service User Guide.
-
Connect to the
rdsadminserver with themaster_usernameandmaster_passwordfor your RDS for Db2 DB instance.db2 connect to rdsadmin usermaster_usernameusingmaster_password -
(Optional) To ensure that your database is configured with the optimal settings, check the values for the following parameters by calling rdsadmin.show_configuration:
-
RESTORE_DATABASE_NUM_BUFFERS -
RESTORE_DATABASE_PARALLELISM -
RESTORE_DATABASE_NUM_MULTI_PATHS -
USE_STREAMING_RESTORE
Use rdsadmin.set_configuration to modify these values as needed. Properly configuring these parameters can improve performance when you restore databases with large volumes of data. Set
USE_STREAMING_RESTOREtoTRUEto reduce storage requirements and improve restoration speed compared to downloading and extracting the full backup file. -
-
Restore the backup on the RDS for Db2 server by calling
rdsadmin.restore_database. Setbackup_typetoONLINE. For more information, see rdsadmin.restore_database.
After you restore the backup, apply your archive logs and switch your applications to the RDS for Db2 DB instance.
To apply logs and cut over to your RDS for Db2 DB instance
-
Copy your archive logs from your source server to your Amazon S3 bucket. Upload archive log files to a dedicated prefix that doesn't contain backup images or other non-log files. Archive log files must use the standard Db2 naming format (
S). For more information, see Archive loggingsequence.LOGin the IBM Db2 documentation. For example, if your backup files are at
backups/TESTDB/, upload your archive logs to a separate prefix such asarchiveLogs/TESTDB/. -
Apply archive logs as many times as needed by calling
rdsadmin.rollforward_database. Set thes3_prefixto the dedicated archive log prefix, for examplearchiveLogs/TESTDB/. Ensure that the prefix contains only archive log files in theSformat. Setsequence.LOGcomplete_rollforwardtoFALSEto keep the database in aROLL-FORWARD PENDINGstate. For more information, see rdsadmin.rollforward_database. -
Bring the database online by calling
rdsadmin.complete_rollforwardafter you apply all of the archive logs. For more information, see rdsadmin.complete_rollforward. -
Switch application connections to the RDS for Db2 server by either updating your application endpoints for the database or by updating the DNS endpoints to redirect traffic to the RDS for Db2 server. You can also use the Db2 automatic client reroute feature on your self-managed Db2 database with the RDS for Db2 database endpoint. For more information, see Automatic client reroute description and setup
in the IBM Db2 documentation. -
(Optional) Shut down your source database.