Unplug and Plug PDB

宋元良 1月前 123

Attention: to unplug a PDB, you need to close it first and then generate an XML manifest file.

0.Overview

This document is the instruction of how to unplug a PDB and plug it into the same or another CDB.

You can disassociate or unplug a PDB from a CDB and re-associate or plug the PDB into the same CDB or into another CDB. This capability is suitable for the following situations:

  • You have to upgrade a PDB to the latest Oracle version, but you do not want to apply it on all PDBs. Instead of upgrading a CDB from one release to another, you can unplug a PDB from one Oracle Database release, and then plug it into a newly created CDB from a later release.
  • You want to test the performance of the CDB without a particular PDB. You unplug the PDB, test the performance without the PDB and, if necessary, re-plug the PDB into the CDB.
  • You want to maintain a collection of PDB “gold images” as unplugged PDBs.
  • The XML manifest contains names and path of tablespaces and data files. This information will be used by the plugging operation.

The overall steps of doing unplugging and plugging are:

  • Unplug the PDB
  • Plug the PDB Into the Same or Another CDB
  • Open the Plugged PDB
  • Reset the Environment

1. Unplug the PDB To unplug a PDB, you should first close it and then generate an XML manifest.

Close the PDB before plugging

ps -ef | grep pmon
. oraenv
sqlplus / as sysdba
show pdbs 
ALTER PLUGGABLE DATABASE CDSSPD CLOSE IMMEDIATE;

Unplug the closed PDBs in to a XML file

sqlplus / as sysdba
show pdbs
ALTER PLUGGABLE DATABASE CDSSPD UNPLUG INTO '/u01/app/oracle/CDSSPD.xml'

2. Plug the PDB Into the Same or Another CDB

After unplugged the PDB and generated a XML file, you can plug it into the same or another CDB.

Checking the Compatibility of The Unplugged PDB with the Target CDB. Before starting plug the PDB into CDB, make sure that the PDB is compatible with the CDB.

. oraenv
[enter target CDB at the prompt]
sqlplus / as sysdba
[if CDB is not started up, start it up now.]
set serveroutput on
DECLARE
   compatible BOOLEAN := FALSE;
BEGIN 
   compatible := DBMS_PDB.CHECK_PLUG_COMPATIBILITY(
        pdb_descr_file => '/u01/app/oracle/oradata/CDSSPD.xml');
   if compatible then
      DBMS_OUTPUT.PUT_LINE('Is pluggable PDB1 compatible? YES');
   else DBMS_OUTPUT.PUT_LINE('Is pluggable PDB1 compatible? NO');
   end if;
END;
/

If you see YES in the output, feel free to go to next step

3. Plugging the Unplugged PDB in NOCOPY Method Use the data files of the unplugged PDB to plug the PDB into another CDB without any copy.

create pluggable database CDSSPD using '/u01/app/oracle/oradata/CDSSPD.xml'
NOCOPY
TEMPFILE REUSE;

Verify the status of the plugged PDB.

select pdb_name, status from cdb_pdbs where pdb_name='CDSSPD';
select open_mode from v$pdbs where name='CDSSPD';

Verify the data files of the plugged PDB.

select name from v$datafile where con_id=9;

4. Plugging the Unplugged PDB in COPY Method Use the data files of the unplugged PDB to plug the PDB into another CDB and copy the data files to a new location.

create pluggable database CDSSPD using '/u01/app/oracle/oradata/CDSSPD.xml'
COPY
FILE_NAME_CONVERT=('path of old datafiles','path of where you want to copy the datafiles');

Verify the status of the plugged PDB.

select pdb_name, status from cdb_pdbs where pdb_name='CDSSPD';
select open_mode from v$pdbs where name='CDSSPD';

Verify the data files of the plugged PDB.

select name from v$datafile where con_id=9;

5. Plugging the Unplugged PDB in AS CLONE MOVE Method Use the data files of the unplugged PDB to plug the PDB into another CDB and move the data files to a new location.

create pluggable database CDSSPD using '/u01/app/oracle/oradata/CDSSPD.xml'
MOVE
FILE_NAME_CONVERT=('path of old datafiles','path of where you want to move the datafiles');

Verify the status of the plugged PDB.

select pdb_name, status from cdb_pdbs where pdb_name='CDSSPD';
select open_mode from v$pdbs where name='CDSSPD';

Verify the data files of the plugged PDB.

select name from v$datafile where con_id=9;

You can use all three method above to plug the PDB to the same or another CDB based on whether you want the datafiles to be copied, moved or remained to the same place as before.

6. Open the Plugged PDB

Open the plugged PDB.

ALTER PLUGGABLE DATABASE CDSSPD OPEN;

7. Check the Availability of the Plugged PDB

Try to connect to plugged PDB to make sure it works on target CDB.

最新回复 (3)
返回
发新帖