Plugging an Unplugged Pluggable Database with copy method

FacebooktwitterredditpinterestlinkedinmailFacebooktwitterredditpinterestlinkedinmail

Plugging an Unplugged Pluggable Database

Unplugging the PDB

To unplug a PDB, you first close it and then generate an XML manifest file. The XML file contains information about the names and the full paths of the tablespaces, datafiles of the unplugged PDB. The information will be used by the plugging operation.

We are going to unplug the PDB to plug them with Copy methods.

[oracle@localhost pdb3]$ . oraenv
ORACLE_SID = [cdb1] ? cdb1
The Oracle base remains unchanged with value /u01/app/oracle

[oracle@localhost pdb3]$ sqlplus / as sysdba

SQL> show con_name

CON_NAME
------------------------------
CDB$ROOT

SQL> alter pluggable database pdb1 close immediate;

SQL> alter pluggable database pdb1 unplug into '/u01/app/oracle/oradata/cdb1/pdb1/pdb1.xml';
Pluggable database altered

SQL> drop pluggable database pdb1 keep datafiles;
Pluggable database dropped.

SQL> select pdb_name, status from cdb_pdbs where pdb_name in ('PDB1');
no rows selected

SQL> Shutdown immediate;
SQL> exit

Plugging the PDB into the Same or Another CDB

[oracle@localhost pdb3]$ ps -ef | grep pmon
oracle 6950 2581 0 11:26 pts/1 00:00:00 grep pmon
[oracle@localhost ~]$ . oraenv
ORACLE_SID = [cdb1] ? cdb2
The Oracle base remains unchanged with value /u01/app/oracle

[oracle@localhost ~]$ sqlplus / as sysdba
SQL> startup;

SQL> set serveroutput on
SQL> DECLARE
compatible BOOLEAN := FALSE;
BEGIN
compatible := DBMS_PDB.CHECK_PLUG_COMPATIBILITY(
pdb_descr_file => '/u01/app/oracle/oradata/cdb1/pdb1/pdb1.xml',
pdb_name => 'pdb1');
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;
/

Note: The unplugging operation actually makes some changes in the PDB’s datafiles to record that the PDB was properly and successfully unplugged. Because it is still part of the CDB, you can do an ad hoc RMAN backup of it. This provides a convenient way to archive the unplugged PDB. Once you have backed it up, you then remove it from the CDB’s catalog. But, of course, you must preserve the datafiles for the subsequent plugging operation.

Method-2: Plug the unplugged PDB: COPY Method

Plug the unplugged PDB into the CDB copying the datafiles of the unplugged PDB. This operation requires that a destination for the new datafiles is created and defined first.

[oracle@localhost ~]$ cd /u01/app/oracle/oradata/cdb2/
[oracle@localhost cdb2]$ mkdir pdb_plug_copy
[oracle@localhost cdb2]$ cd pdb_plug_copy/
[oracle@localhost pdb_plug_copy]$ pwd
/u01/app/oracle/oradata/cdb2/pdb_plug_copy
[oracle@localhost pdb_plug_copy]$ sqlplus / as sysdba

Use the datafiles of the unplugged PDB to plug the PDB into the CDB copying the datafiles to a new location.

SQL> create pluggable database pdb_plug_copy using '/u01/app/oracle/oradata/cdb1/pdb2/pdb2.xml'
COPY
FILE_NAME_CONVERT= ('/u01/app/oracle/oradata/cdb1/pdb2','/u01/app/oracle/oradata/cdb2/pdb_plug_copy');

Pluggable database created.

SQL> select pdb_name, status from cdb_pdbs where pdb_name='PDB_PLUG_COPY';
SQL> select open_mode from v$pdbs where name='PDB_PLUG_COPY';
SQL> select name from v$datafile where con_id=4;
SQL> exit

Opening the plugged PDB

SQL> show con_name

CON_NAME
------------------------------
CDB$ROOT

SQL> alter pluggable database pdb_plug_copy open;
Pluggable database altered.

Connect to the plugged-in PDBs and verify the container name you are connected to:
SQL> show con_name
CON_NAME
------------------------------
PDB_PLUG_COPY

SQL> connect sys/oracle@localhost:1521/pdb_plug_copy AS SYSDBA
Connected.

Close all of the pluggable databases:

SQL> connect sys/oracle@192.168.56.101:1521/cdb2 as sysdba
Connected.

SQL> alter pluggable database all close immediate;
Pluggable database altered

Unplug the PDB_PLUG_COPY database so that it can be used to re-create the pdb2 database:

SQL> alter pluggable database pdb_plug_copy unplug into '/u01/app/oracle/oradata/pdb_plug_copy.xml';

Pluggable database altered.

Drop the PDB_PLUG_COPY database:

SQL> drop pluggable database pdb_plug_copy;
Pluggable database dropped.

Plug the pdb2 database back into the cdb1 container database:

[oracle@localhost ~]$ . oraenv
ORACLE_SID = [cdb2] ? cdb1
The Oracle base remains unchanged with value /u01/app/oracle
[oracle@localhost ~]$ ps -ef | grep pmon
oracle 8025 2581 0 13:15 pts/1 00:00:00 grep pmon
[oracle@localhost ~]$ sqlplus / as sysdba

SQL> startup;
SQL> connect sys/oracle@localhost:1521/cdb1 as sysdba
SQL> create pluggable database pdb2 AS CLONE using '/u01/app/oracle/oradata/pdb_plug_copy.xml'
MOVE
FILE_NAME_CONVERT=
('/u01/app/oracle/oradata/cdb2/pdb_plug_copy','/u01/app/oracle/oradata/cdb1/pdb2');

Pluggable database created.

3 thoughts on “Plugging an Unplugged Pluggable Database with copy method”

  1. Des individus qui apportent leur assistance pour un déménagement ?
    C’est illico faisable grâce au site mydemenageur.com dans le lequel leur profil est détaillé également leur paiement soit financier soit par un échange de service ou le don d’un meuble.

Leave a Reply

Your email address will not be published.