<<Back to DB Administration Main Page
Unplugging and Plugging Oracle PDB from One Container to Another
Note: The procedure is valid if even if the root container and others are using TDE but the container (PDB) you are unplugging is not having TDE and wallet keysSetup Overview
Source Container: CDB01
No of PDB's in Source Container 2 (PDB01 and PDB02)
PDB01 using TDE
PDB02 don't
Target Container: CDB02
No of PDB's 0
TDE not used
Task: In this post I will unplug the PDB02 from CDB01 and Plug it in CDB002 on the same host without copying the datafile (using NOCOPY Method).
Precheck
2) Create PDB description XML file for PDB(PDB02)
SQL> exec dbms_pdb.describe (PDB_DESCR_FILE=>'/u01/app/oracle/PDB02.xml', PDB_NAME=>'PDB02');
3) Verify the status of the PDB.
SQL> select pdb_name, status from cdb_pdbs where pdb_name in ('PDB02');
4) Checking the Compatibility of the PDB with the Target CDB
SQL> BEGIN
IF dbms_pdb.check_plug_compatibility('/u01/app/oracle/PDB02.xml') THEN
dbms_output.put_line('no violations found');
ELSE
dbms_output.put_line('violations found');
END IF;
END;
/
SQL> SELECT type, message, action FROM pdb_plug_in_violations WHERE name = 'PDB02';
At this point resolve if there is any violation found. If not proceed with unplug
How to Unplug the PDB from Container
Step1> Close the PDBSQL> alter pluggable database PDB02 close immediate ;
Step2> Unplug the closed PDB
SQL>alter pluggable database PDB02 unplug into '/u01/app/oracle/PDB02.xml';
Step3> Drop the closed PDB and keep the data files.
SQL> drop pluggable database PDB02 keep datafiles;
Step4> Verify the status of the unplugged PDB.
SQL>select pdb_name, status from cdb_pdbs where pdb_name in ('PDB02');
How to Plug an Unplugged PDB in Same or Different Container
Lets plug the unplugged database ie PDB02 in different container CDB02. The steps is same in case you want to plug it back in the same container.
Note:- If Target is not started up, start it up now.
Step1> Check Compatibility of the Unplugged PDB with the Target CDB
SQL> set serveroutput on
DECLARE
compatible BOOLEAN := FALSE;
BEGIN
IF dbms_pdb.check_plug_compatibility('/u01/app/oracle/PDB02.xml') THEN
dbms_output.put_line('no violations found');
ELSE
dbms_output.put_line('violations found');
END IF;
END;
/
DECLARE
compatible BOOLEAN := FALSE;
BEGIN
IF dbms_pdb.check_plug_compatibility('/u01/app/oracle/PDB02.xml') THEN
dbms_output.put_line('no violations found');
ELSE
dbms_output.put_line('violations found');
END IF;
END;
/
Step2> Plug into CDB02
SQL> create pluggable database PDB02 using '/u01/app/oracle/PDB02.xml' NOCOPY TEMPFILE REUSE;
Step3> Verify the status
SQL>select pdb_name, status from cdb_pdbs where pdb_name='PDB02';
SQL>select open_mode,con_id from v$pdbs where name='PDB02';
SQL>select name from v$datafile where con_id=3;
SQL>alter pluggable database PDB02 open;
Note:- As you might have noticed the datafiles are still pointing to CDB01 path that's no problem at all, but if you want you can relocate them online to different location just to look neat and clean
How to Move Datafile Online
SQL>alter database move datafile '+DATAC4/CDB01/6F74C085CC46D90DE05325F3840AB896/DATAFILE/system.543.979729827' to '+DATAC4';SQL> alter database move datafile '+DATAC4/CDB01/6F74C085CC46D90DE05325F3840AB896/DATAFILE/sysaux.542.979729825' to '+DATAC4';
Comments
Post a Comment