Upgrading Oracle Database Releases Using Replay Upgrade

To upgrade from an earlier release, you can use the Replay Upgrade procedure to convert and upgrade a non-CDB to a PDB.

Upgrading PDBs Using Replay Upgrade

You can upgrade an entire container database (CDB) and its pluggable databases (PDBs) using a Replay Upgrade, or you can upgrade individual PDBs.

Note:

Replay Upgrade replaces the classic Parallel Upgrade, but you are still required to run pre-upgrade and post-upgrade tasks as specified elsewhere in the documentation.

Before you start an upgrade, the following steps must be performed:

  • Install the new release software for Oracle Database.
  • Create a new CDB on the new release, or use an existing one..
  • Perform the preupgrade activities as explained in Chapter 2 in this guide, Preparing to Upgrade Oracle Database.

Note:

When you plug in PDBs and upgrade the PDBs on PDB open using Replay Upgrade, Oracle recommends that you upgrade a number of PDBs equivalent to no more than one-fourth (¼) of the value of the Oracle Database initialization parameter CPU_COUNT, which specifies the number of CPU core (processors) available for Oracle Database to use. With classic Parallel Upgrade, the default number of PDBs upgraded at a time is no more than one-half (½) of the value of CPU_COUNT.

You can complete an upgrade using the Replay Upgrade method either by using Upgrade on PDB Open, or with the AutoUpgrade Utility.

After the upgrade, the following steps must be performed, as specified in Chapter 7, "Post-Upgrade Tasks for Oracle Database":

  • Run Datapatch to patch the new PDB.
  • Use AutoUpgrade to perform postupgrade checks.

Replay Upgrade Using Automatic Upgrade on PDB Plug-In To a New Release CDB

If you plug in an earlier release PDB to a new release CDB, then the CDB detects on opening the PDB that the PDB is an earlier release than the CDB, and automatically starts a Replay Upgrade process. Upgrade on PDB Open automatically upgrades the PDB using the Replay Upgrade synchronization feature.

How to Disable or Enable Replay Upgrade

By default, the Replay Upgrade method is enabled for upgrades on PDBs. However, you can enable or disable the use of this method.

You can use this SQL query to determine whether Replay Upgrade is active:


select property_name, property_value
from database_properties
where property_name in ('UPGRADE_PDB_ON_OPEN');

To disable Replay Upgrade, run the following command, on either CDB$ROOT or a particular PDB:

ALTER DATABASE UPGRADE SYNC OFF

If you disable Replay Upgrade, then you must upgrade the PDB using AutoUpgrade.

To re-enable the Replay Upgrade behavior, enter the following command

ALTER DATABASE UPGRADE SYNC ON

AutoUpgrade by default does not use Replay Upgrade. It uses the classic Parallel Upgrade scripts. If you want to force AutoUpgrade to use Replay Upgrade, then add the following to your AutoUpgrade configuration file, where prefix is the upgrade prefix used for the upgrade in your configuration file:

prefix.replay=yes

Note:

You can manage use of the Replay Upgrade method on individual PDBs, depending on whether you are connected to CDB$ROOT, or to a particular PDB:

  • If UPGRADE SYNC is set to OFF in CDB$ROOT, then the Replay Upgrade method is not used for any PDBs plugged into the CDB.
  • If UPGRADE SYNC is set to ON in CDB$ROOT, but set to OFF for a PDB, then the Replay Upgrade method is not used for the PDB where UPGRADE SYNC is OFF, but the Replay Upgrade method is used for all other PDBs plugged into the CDB.
  • If UPGRADE SYNC is set to ON in CDB$ROOT, and set to ON for all PDBs (the default), then the Replay Upgrade method is used for all PDBs plugged into the CDB.

About Upgrading Non-CDBs to PDBs Using Replay Upgrade

You can automate some of the steps to upgrade non-CDB Oracle Database software to the multitenant architecture by using the Replay Upgrade method.

The Replay Upgrade method is enabled by default for upgrades from earlier Oracle Database releases that are supported for direct upgrade to this Oracle Database release. The Replay Upgrade process is different from the classic method of running scripts, such as noncdb_to_pdb.sql. For non-CDBs, after you describe the non-CDB by running DBMS_PDB.DESCRIBE, you plug in the non-CDB in to the new Oracle Database CDB. The Replay Upgrade method for upgrade is completed in two steps:

  1. The non-CDB database is upgraded to the new Oracle Database release.
  2. The non-CDB data dictionary is converted to a PDB data dictionary

Both of these steps are triggered when you run ALTER PLUGGABLE DATABASE OPEN. Both steps automatically replay SQL statements stored in the dictionary and complete the task of adopting the non-CDB to a PDB, and upgrading the database to the new release.

The benefit of using the Replay Upgrade method is to greatly simplify the upgrade workflow that you need to perform for PDB upgrades and conversions. The implicit non-CDB to PDB conversion simplifies the process of adopting and upgrading both non-CDB and PDB Oracle Database releases earlier than Oracle Database 21c to PDBs in a new release CDB.

Adopting and Upgrading a Non-CDB as a PDB with Replay Upgrade

To simplify your upgrades, you can convert and upgrade a non-CDB into a PDB by using the Replay Upgrade method.

Before you start an upgrade, the following steps must be performed:

  • Install the new release software for Oracle Database
  • Prepare the new Oracle home
  • Perform the preupgrade activities as explained in Chapter 2 of this guide, "Preparing to Upgrade Oracle Database".

To adopt a non-CDB as a PDB using the DBMS_PDB package and the Replay Upgrade method, complete the following procedure.

  1. Create the CDB if it does not exist, or use an existing one.

  2. Analyze the database for upgrade readiness. Run AutoUpgrade in analyze mode and check the outcome of the analysis in the summary report. AutoUpgrade prints the location of the summary report upon completion of the check. For example:

    export ORACLE_SID=NCDB
    export ORACLE_HOME=/u01/app/oracle/product/19.0.0/dbhome_1
    export ORACLE_TARGET_HOME=/u01/app/oracle/product/23.0.0/dbhome_1
    java -jar autoupgrade.jar -config_values "target_cdb=CDB23" -mode analyze
  3. During the pre-upgrade analysis, AutoUpgrade detects whether any changes are needed to the database before starting the upgrade. Perform those changes by starting AutoUpgrade in fixups mode. For example:

    export ORACLE_SID=NCDB
    export ORACLE_HOME=/u01/app/oracle/product/19.0.0/dbhome_1
    export ORACLE_TARGET_HOME=/u01/app/oracle/product/23.0.0/dbhome_1
    java -jar autoupgrade.jar -config_values "target_cdb=CDB23" -mode fixups
  4. Place the non-CDB in read-only mode.

  5. Connect to the non-CDB, and run the DBMS_PDB.DESCRIBE procedure to construct an XML file that describes the non-CDB.

    The current user must have SYSDBA administrative privilege. The user must exercise the privilege using AS SYSDBA at connect time.

    For example, to generate an XML file named ncdb.xml in the /disk1/oracle directory, run the following procedure:

    BEGIN
      DBMS_PDB.DESCRIBE(
        pdb_descr_file => '/disk1/oracle/ncdb.xml');
    END;
    /
    

    After the procedure completes successfully, you can use the XML file and the non-CDB data files to plug the non-CDB into a CDB.

  6. Run the DBMS_PDB.CHECK_PLUG_COMPATIBILITY function to determine whether the non-CDB is compatible with the CDB.

    When you run the function, set the following parameters:

    • pdb_descr_file - Set this parameter to the full path to the database description XML file.

    • pdb_name - Specify the name of the new PDB. If this parameter is omitted, then the PDB name in the XML file is used.

    For example, to determine whether a non-CDB described by the /disk1/oracle/ncdb.xml file is compatible with the current CDB, run the following PL/SQL block:

    SET SERVEROUTPUT ON
    DECLARE
      compatible CONSTANT VARCHAR2(3) := 
        CASE DBMS_PDB.CHECK_PLUG_COMPATIBILITY(
               pdb_descr_file => '/disk1/oracle/ncdb.xml',
               pdb_name       => 'NCDB')
        WHEN TRUE THEN 'YES'
        ELSE 'NO'
    END;
    BEGIN
      DBMS_OUTPUT.PUT_LINE(compatible);
    END;
    /
    

    If the output is YES, then the non-CDB is compatible, and you can continue with the next step. If the output is NO, then the non-CDB is not compatible. To see why it is not compatible, check the view PDB_PLUG_IN_VIOLATIONS. Before you continue, you must correct all violations. For example, any version or patch mismatches should be resolved by running an upgrade, or running the datapatch utility. After correcting the violations, run DBMS_PDB.CHECK_PLUG_COMPATIBILITY again to ensure that the non-CDB is compatible with the CDB.

  7. Shut down the non-CDB.

  8. Plug in the non-CDB to the higher-release CDB.

    For example, the following SQL statement plugs in a non-CDB, copies its files to a new location, and includes only the tbs3 user tablespace from the non-CDB:

    CREATE PLUGGABLE DATABASE ncdb USING '/disk1/oracle/ncdb.xml'
      COPY
      FILE_NAME_CONVERT = ('/disk1/oracle/dbs/', '/disk2/oracle/ncdb/')
      USER_TABLESPACES=('tbs3');
    

    If there are no violations, then do not open the new PDB. You will open it in a later step.

    The USER_TABLESPACES clause enables you to separate data that was used for multiple tenants in a non-CDB into different PDBs. You can use multiple CREATE PLUGGABLE DATABASE statements with this clause to create other PDBs that include the data from other tablespaces that existed in the non-CDB.

  9. To confirm replay upgrade is turned on, enter the following:

    select property_name, property_value
    from database_properties
    where property_name in('UPGRADE_PDB_ON_OPEN', 'CONVERT_NONCDB_ON_OPEN');
  10. Connect to the new PDB, and open it. At the time that the PDB is opened, the database is upgraded, and the non-CDB database data dictionary is converted to a PDB. For example:

    ALTER PLUGGABLE DATABASE OPEN

    You must open the new PDB for Oracle Database to complete upgrading the database. An error is returned if you attempt to open the PDB in read-only mode. When the PDB is opened, the non-CDB is adopted to a PDB, the data dictionary is converted, and the new PDB is integrated into the CDB. Messages from the Replay Upgrade are placed in the trace directory. After the PDB is opened, and the Replay Upgrade is completed, its status is NORMAL.

    To check the status of the upgrade, you can query the following views:
    • To check for Replay Upgrade errors, use the view DBA_REPLAY_UPGRADE_ERRORS
    • To check completeness, use DBA_APPLICATIONS. Check the app_version value for app_name 'APP$CDB$CATALOG' value. This value should be the new version of the PDB.
    • Check the view DBA_APP_ERRORS for statement errors. This view lists the error message and statement text (app_statement) for any errors. In a successful upgrade, this view should not contain any rows for app_name='APP$CDB$CATALOG'.
  11. Run Datapatch to patch the new PDB:

    datapatch -pdbs ncdb
  12. Run postupgrade fixups using AutoUpgrade, and specifying the following:

    • ORACLE_SID specifies the system identifier of the target container database
    • ORACLE_HOME is the Oracle home of the database specified by ORACLE_SID.
    • The inclusion_list contains the name of the PDB (the former non-CDB). You can specify more PDBs if needed.
    • The dir option specifies the directory where AutoUpgrade can store the logs files.

    In the following example, ORACLE_SID is specified as CDB23, ORACLE_HOME is specified as /u01/app/oracle/product/23.0.0/dbhome_1, the log file directory is specified as /u01/app/oracle/cfgtoollogs/autoupgrade, and the inclusion_list is specified as NCDB:

    export ORACLE_SID=CDB23
    export ORACLE_HOME=/u01/app/oracle/product/23.0.0/dbhome_1
    java -jar autoupgrade.jar -preupgrade "dir=/u01/app/oracle/cfgtoollogs/autoupgrade,inclusion_list=NCDB" -mode postfixups
    
  13. Back up the PDB.

    Oracle strongly recommends that you back up the PDB. A PDB that is not backed up can be recovered using a combination of preplugin backups from the non-CDB and the backups from the CDB. However, recovery is much more cumbersome and complex than a regular restore operation.

  14. Perform the post-upgrade tasks as specified in Chapter 7, "Post-Upgrade Tasks for Oracle Database".

Note:

If an error is returned during PDB creation, then the PDB being created might be in an UNUSABLE state. You can check the state of a PDB by querying the views CDB_PDBS or DBA_PDBS. You can learn more about PDB creation errors by checking the alert log. An unusable PDB can only be dropped. If the PDB is unusable, then it must be dropped before a PDB with the same name as the unusable PDB can be created.

Upgrading an Earlier Release With an Unplug-Plug Upgrade

You can upgrade an earlier release PDB by plugging it into a later release CDB using an automatic Replay Upgrade.

General Prerequisites

  • Complete the prerequisites described in "General Prerequisites for PDB Creation" in Oracle Multitenant Administrator's Guide

  • Either the XML file that describes the PDB or the .pdb archive file must exist in a location that is accessible to the CDB.

    The USING clause must specify the XML file or the .pdb archive file. If the PDB's XML file is unusable or cannot be located, then use the DBMS_PDB.RECOVER procedure to generate an XML file using the PDB's data files.

  • If an XML file (not a .pdb file) is specified in the USING clause, then the files associated with the PDB (such as the data files and wallet file) must exist in a location that is accessible to the CDB.

  • If the target database for the plugin operation is the primary database in an Oracle Data Guard configuration, then ensure that the standby database can locate the files for the plugged-in PDB.

    On the standby database, set the STANDBY_PDB_SOURCE_FILE_DIRECTORY initialization parameter to a location that contains the source data files for instantiating the PDB. If the files are not found, then the standby database tries to locate the files in the OMF location. If not found in the OMF location, then you must copy the data files to the OMF location on the standby database, and restart redo apply on the standby database.

  • The source and target CDB platforms must meet the following requirements:

    • They must have the same endianness.

    • The database options installed on the source platform must be the same as, or a subset of, the database options installed on the target platform.

  • If you are creating an application PDB, then the application name and version of the unplugged PDB must match the application name and version of the application container into which the application PDB is being plugged.

Note:

If you are plugging in a PDB that includes data that was encrypted with Transparent Data Encryption, then follow the instructions in Oracle Database Advanced Security Guide for united mode and Oracle Database Advanced Security Guide for isolated mode.

Character Set Prerequisites

You must meet the following prerequisites for matching the character sets:

  • If the character set of the CDB into which the PDB is being plugged is not AL32UTF8, then the CDB that contained the unplugged PDB and the target CDB must have compatible character sets and national character sets. To be compatible, the character sets and national character sets must meet the requirements specified in Oracle Database Globalization Support Guide.

    If the character set of the CDB into which the PDB is being plugged is AL32UTF8, then this requirement does not apply.

    Note:

    Oracle Multitenant does not support a LOB in one container from being accessed by a container with a different character set using data links, extended data links, or the CONTAINERS() clause. For example, if the CDB root and salespdb have different character sets, then a CONTAINERS() query run in the CDB root should not access LOBs stored in salespdb.

  • If you are creating an application PDB, then the application PDB must have the same character set and national character set as the application container.

    If the database character set of the CDB is AL32UTF8, then the character set and national character set of the application container can be different from the CDB. However, all application PDBs in an application container must have same character set and national character set, matching that of the application container.

To determine whether the preceding requirements are met, use the DBMS_PDB.CHECK_PLUG_COMPATIBILITY function. Step 2 in the following procedure describes using this function.

  1. In SQL*Plus, ensure that the current container is the CDB root or application root of the target CDB.

    When the current container is the CDB root, the PDB is created in the CDB. When the current container is an application root, the application PDB is created in the application container.

  2. (Optional) Run the DBMS_PDB.CHECK_PLUG_COMPATIBILITY function to determine whether the unplugged PDB is compatible with the CDB.

    1. If the PDB is not yet unplugged, then run the DBMS_PDB.DESCRIBE procedure to produce an XML file that describes the PDB.

      If the PDB is already unplugged, then proceed to Step 2b.

      For example, to generate an XML file named salespdb.xml in the /disk1/oracle directory, run the following procedure:

      BEGIN
        DBMS_PDB.DESCRIBE(
          pdb_descr_file => '/disk1/oracle/salespdb.xml',
          pdb_name       => 'SALESPDB');
      END;
      /
      

      If the PDB is in a remote CDB, then you can include @database_link_name in the pdb_name parameter, where database_link_name is the name of a valid database link to the remote CDB or to the PDB. For example, if the database link name to the remote CDB is rcdb, then set the pdb_name value to SALESPDB@rcdb.

    2. Run the DBMS_PDB.CHECK_PLUG_COMPATIBILITY function.

      When you run the function, set the following parameters:

      • pdb_descr_file - Set this parameter to the full path to the XML file.

      • pdb_name - Specify the name of the new PDB. If this parameter is omitted, then the PDB name in the XML file is used.

      For example, to determine whether a PDB described by the /disk1/usr/salespdb.xml file is compatible with the current CDB, run the following PL/SQL block:

      SET SERVEROUTPUT ON
      DECLARE
        compatible CONSTANT VARCHAR2(3) := 
          CASE DBMS_PDB.CHECK_PLUG_COMPATIBILITY(
                 pdb_descr_file => '/disk1/usr/salespdb.xml',
                 pdb_name       => 'SALESPDB')
          WHEN TRUE THEN 'YES'
          ELSE 'NO'
      END;
      BEGIN
        DBMS_OUTPUT.PUT_LINE(compatible);
      END;
      /
      

      If the output is YES, then the PDB is compatible, and you can continue with the next step. If the output is NO, then the PDB is not compatible: check the PDB_PLUG_IN_VIOLATIONS view to see why it is not compatible.

    Note:

    You can specify a .pdb archive file in the pdb_descr_file parameter.
  3. If the PDB is not unplugged, then unplug it.

  4. Run the CREATE PLUGGABLE DATABASE ... USING statement, specifying the XML file or the .pdb archive file in the USING clause. Specify other clauses when they are required.

    After you create the PDB, it is in mounted mode, and its status is NEW. You can view the open mode of a PDB by querying the OPEN_MODE column in the V$PDBS view. You can view the status of a PDB by querying the STATUS column of the CDB_PDBS or DBA_PDBS view.

    A new default service is created for the PDB. The service has the same name as the PDB and can be used to access the PDB. Oracle Net Services must be configured properly for clients to access this service.

  5. Open the new PDB in read/write mode.

    You must open the new PDB in read/write mode for Oracle Database to complete the integration of the new PDB into the CDB. An error is returned if you attempt to open the PDB in read-only mode. After the PDB is opened in read/write mode, its status is NORMAL.

    Opening a PDB upgrades it automatically when a version mismatch occurs between the PDB and the CDB root. The Replay Upgrade on PDB Open optimization, which is the default, avoids manual error correction by re-executing statements stored in capture tables. The mechanism is the same used in application synchronization.

    When the PDB is opened, the database automatically performs a Replay Upgrade.

  6. After the replay upgrade is complete, back up the PDB.

    Caution:

    A PDB cannot be recovered unless it is backed up. For more information about PDB and application containers, see Oracle Multitenant Administrator's Guide

Failure and Recovery Scenarios for Replay Upgrade Processes

Learn how to check for errors and issues in log files and trace files for an Replay Upgrade (Replay Upgrade).

If a Replay Upgrade fails, then the PDB_UPGRADE_SYNC property is decremented by 1 for the PDB. If the Replay Upgrade fails twice, then catctl.pl falls back to using the classic script-based Parallel Upgrade Procedure method for completing the upgrade.

To check the value, you can use the following SQL query:

select property_value
from database_properties
where property_name='PDB_UPGRADE_SYNC';

To determine the cause of Replay Upgrade errors, review the upgrade logs for statements that encounter errors. After a Replay Upgrade procedure runs, whether it is successful or unsuccessful, the query DBA_APP_ERRORS is run. Review the results of that query to see statement text and error messages for any statements that encounter errors. To see specific errors in the logs, you can also query the upgrade logs by using a grep command to locate any text strings of '^ORA-'.

Another diagnostic option is to review the trace files (.trc) . The trace files contain output for each statement run during the Replay Upgrade procedure. The files show statement text, whether statements succeeded or failed, error messages (if applicable), and the amount of time elapsed during the process. Look for lines that contain the prefix string Replay Upgrade, PDB ID where the variable ID is the PDB ID. For example: Replay Upgrade, PDB 15.