Cloning a PDB from Oracle 12.1 to Oracle 12.2

Is cloning a PDB from Oracle 12.1 to Oracle 12.2 possible?

A colleague raised this question recently. And a customer did ask me the same question a few days before at a user group conference. There are several ways to move a PDB from Oracle 12.1. to 12.2. But the documentation does not say explicitly if you can do a cloning operation between Oracle 12.1 and 12.2.

Please see also: Upgrade Testing – Online Clone a PDB to Oracle 19c

Cloning a PDB from Oracle 12.1 to Oracle 12.2

You can clone a non-CDB and make it a PDB but you need to run noncdb_to_pdb.sql afterwards. When I wrote this blog post, Oracle 12.2 was not available yet. Now, as it is available, I will clone a PDB between different Oracle versions.

You can redo the same steps by yourself with our Hands-On Lab environment if you have no Multitenant environment to play with.

Cloning a PDB from Oracle 12.1 to Oracle 12.2

Clone a PDB from Oracle (CDB1) to Oracle (CDB2)

Requirements and Prerequisites

Please see the description in the documentation:

The important topic to mention is whether the source CDB has local undo on or not. When cloning from an Oracle database there’s no local undo – and therefore the source PDB has to remain in read-only mode during the entire operations.

Step by Step

At first, you must prepare the source PDB for the cloning.

Oracle – CDB1
  1. Login as SYS as SYSDBA to the CDB$ROOT container
    sqlplus / as sysdba
  2. Create a test PDB first, then open it:
    create pluggable database pdb1
    admin user adm identified by adm
    file_name_convert=('/u02/oradata/CDB1/pdbseed', '/u02/oradata/CDB1/pdb1');
    alter pluggable database PDB1 open;
  3. Switch into the new PDB and prepare a cloning user.
    Afterwards the PDB has to be set into read-only mode due to the non-existence of local undo in Oracle

    alter session set container=PDB1;
    create user hugo identified by hugo;
    grant create session, create pluggable database to hugo;
    alter pluggable database PDB1 close;
    alter pluggable database pdb1 open read only;
Oracle – CDB2
  1. Make sure you’ll have TNS setup correctly so PDB1 is visible and reachable. Then create a database link from the destination CDB into the source PDB1 and initiate the cloning operation.
    create database link sourcedblink
    connect to hugo identified by hugo using 'PDB1';
    create pluggable database CDB2_PDB1 from pdb1@sourcedblink
    file_name_convert=('/u02/oradata/CDB1/pdb1', '/u02/oradata/CDB2/pdb1');
    alter pluggable database CDB2_PDB1 open;
  2. At this point you’ll see that the PDB1 will open but signal the following error:
    Warning: PDB altered with errors.
    Query PDB_PLUG_IN_VIOLATIONS to learn more about the error:

    column name format a9
    column cause format a20
    column message format a50
    column action format a36
    set line 200
    set pages 1000
    select name, cause, message, action from PDB_PLUG_IN_VIOLATIONS
     where status<>'RESOLVED' and CON_ID=3
     order by time;

    This will result in the following output:

    NAME       CAUSE               MESSAGE                                            ACTION
    ---------- ------------------- -------------------------------------------------- ------------------------------------
    CDB2_PDB1  VSN not match       PDB's version does not match CDB's version: PDB's  Either upgrade the PDB or reload the
                                   version CDB's version      components in the PDB.
  3. You need to upgrade the CDB2_PDB1 now. In case you haven’t run preupgrade.jar before cloning the PDB you should now switch PDB1 in CDB1 into read-write mode again and execute preupgrade.jar within the source environment against it:
    java -jar $OH12/rdbms/admin/preupgrade.jar -c "PDB1" TEXT TERMINAL

    Fix potential issues and execute the preupgrade_fixups.sql in the destination environment.
    Afterwards you can initiate the upgrade of the pluggable database.

    cd $ORACLE_HOME/rdbms/admin
    $ORACLE_HOME/perl/bin/perl -c "CDB2_PDB1" -l /home/oracle catupgrd.sql

    Run the postupgrade_fixups.sql once the upgrade is completed.
    For further details on how to upgrade a PDB please see Upgrade PDBs – One at a time.
    And finally, I don’t know what the ACTION “… or reload the components in the PDB” means.

OMF – ORA-1276

In case you try out any of the examples in ASM, please be aware that you can’t use FILE_NAME_CONVERT but instead need to control the destination via the init.ora parameter DB_CREATE_FILE_DEST.

See MOS Note: 1912436.1 – ORA-01276 Errors Reported in PDB for additional advice.

Further Information and Links


Share this: