HOL 18c Unplug – Plug

In this part of the Hands-On Lab you will now unplug an Oracle 12.1.0.2 pluggable database (PDB) from CDB1 and plug it into CDB2 including all the necessary steps.

Index

1. Preparation work in CDB1

First of all, you need to startup CDB1 and create a PDB.

. cdb1
sqlplus / as sysdba

startup
create pluggable database PDB3 admin user adm identified by adm file_name_convert=( '/u02/oradata/CDB1/pdbseed', '/u02/oradata/CDB1/pdb3');
alter pluggable database pdb3 open;
show pdbs
exit

2. Preupgrade.jar and Unplug

Run the preupgrade.jar but only on container PDB3

$ java -jar $OH18/rdbms/admin/preupgrade.jar -c 'pdb3' TERMINAL TEXT

This will execute preupgrade.jar only in container “PDB3”.

Follow the advice of preupgrade.jar‘s output. This includes removing the _fix_control parameter we used in Oracle 12.1.0.2 to enable fixes for Optimizer Adaptive features. The fixes are included in the Oracle 12.2/18c/19c code, and hence the parameter is not needed anymore.

Open a second terminal window (or a new tab in your existing one) and logon at first to CDB$ROOT. Then change to PDB3 to complete the steps recommended by preupgrade.jar.

Be aware: You remove the _fix_control setting for the entire CDB. This would affect other PDBs as well which may still remain in the 12.1.0.2 environment. We can only do this here as an exercise.

. cdb1
sqlplus / as sysdba

alter system reset "_fix_control" scope=spfile sid='*';
alter session set container=PDB3;
@/u01/app/oracle/cfgtoollogs/CDB1/preupgrade/preupgrade_fixups.sql
alter session set container=CDB$ROOT;
alter pluggable database PDB3 close;
alter pluggable database PDB3 unplug into '/home/oracle/pdb3.xml';
drop pluggable database PDB3 keep datafiles;

The last command removes the entries for PDB3 from CDB1. In Oracle 12.1.0.2 this command may hang. Do a CTRL+C after 30 seconds if the command prompt doesn’t get displayed automatically. You will have to restart the CDB1 in order to have the command succeed. Ignore this part. Just shutdown CDB1 as we won’t need it anymore:

Type: CTRL+C

shutdown immediate
exit

3. Plugin

In this step you’ll plugin PDB3 into CDB3.

. cdb2
sqlplus / as sysdba

At first, you’ll do a compatibility check and find out, why the action is classified as “not compatible”:

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

If the result is “NO“, check PDB_PLUG_IN_VIOLATIONS for the reason:

select message from pdb_plug_in_violations where type like '%ERR%' and status <> 'RESOLVED';

You receive two messages:

SQL> select message from pdb_plug_in_violations where type like '%ERR%' and status <> 'RESOLVED';

MESSAGE
--------------------------------------------------------------------------------
PDB's version does not match CDB's version: PDB's version 12.1.0.2.0. CDB's vers
ion 18.0.0.0.0.

DBBP bundle patch 180417 (DATABASE BUNDLE PATCH 12.1.0.2.180417): Not installed
in the CDB but installed in the PDB

The first one is correct and makes sense. The second one can be ignored as it doesn’t matter if PDB3 has a different patch level in 12.1.0.2 – you will upgrade it to 18c anyways. You may read a bit more about PDB_PLUG_IN_VIOLATIONS here.

Plugin the PDB3, the open it in UPGRADE mode:

create pluggable database pdb3 using '/home/oracle/pdb3.xml' file_name_convert=('/u02/oradata/CDB1/pdb3', '/u02/oradata/CDB2/pdb3');
alter pluggable database PDB3 open upgrade;
exit

4. Upgrade PDB3

As final action, as a PDB has its own data dictionary, you need to upgrade PDB3 now.

. cdb2
cd $ORACLE_HOME/rdbms/admin
$ORACLE_HOME/perl/bin/perl catctl.pl -c 'PDB3' -l /home/oracle/logs catupgrd.sql

Once the upgrade has been completed, you need to recompile and run the postupgrade_fixups.sql as usual:

. cdb2

alter session set container=PDB3
startup
@?/rdbms/admin/utlrp.sql
@/u01/app/oracle/cfgtoollogs/CDB1/preupgrade/postupgrade_fixups.sql
alter session set container=CDB$ROOT;
show pdbs
exit

Done.


Completed!