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.
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.
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 188.8.131.52 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 184.108.40.206 – CDB1
- Login as SYS as SYSDBA to the CDB$ROOT container
sqlplus / as sysdba
- 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;
- 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 220.127.116.11.:
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 18.104.22.168 – CDB2
- 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;
- At this point you’ll see that the PDB1 will open but signal the following error:
Warning: PDB altered with errors.
PDB_PLUG_IN_VIOLATIONSto 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 22.214.171.124.0. CDB's version 126.96.36.199.0. components in the PDB.
- You need to upgrade the CDB2_PDB1 now. In case you haven’t run
preupgrade.jarbefore cloning the PDB you should now switch PDB1 in CDB1 into read-write mode again and execute
preupgrade.jarwithin the source environment against it:
java -jar $OH12/rdbms/admin/preupgrade.jar -c "PDB1" TEXT TERMINAL
Fix potential issues and execute the
preupgrade_fixups.sqlin the destination environment.
Afterwards you can initiate the upgrade of the pluggable database.
cd $ORACLE_HOME/rdbms/admin $ORACLE_HOME/perl/bin/perl catctl.pl -c "CDB2_PDB1" -l /home/oracle catupgrd.sql
postupgrade_fixups.sqlonce 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
or reload the components in the PDB” means.