Tuesday, December 16, 2014

How to Clone Pluggable Database in Oracle 12c

How to Clone Pluggable Database in Oracle 12c

Scenario:

We will perform PDB cloning operation within the same CDB. 
Note: To clone a PDB from a CDB into another CDB, you identify the source CDB by creating a database link to it from the CDB in which you want to create the clone.

Prerequisites

·         Availability of enough disk space to hold a new clone of the PDB.
·         Install Oracle Database 12c Database.
·         Create one CDB with one PDB in it.

STEPS:

Set the source PDB to READ ONLY mode

1.       Use SQL*Plus to close the PDB that you want to clone.
. oraenv
[enter cdb1 at the prompt]
sqlplus / as sysdba
alter pluggable database pdb1 close immediate;
2.       Open the PDB that you want to clone in READ ONLY mode.
alter pluggable database pdb1 open read only;
exit

Create a new directory for the clone PDB

1.       Navigate to /u02 (in my case) or any other directory where you can find enough available space to store the data files for pdb1_clone. 
cd /u02
2.       Create a subdirectory called pdb1_clone under /u02. 
Note: You may need to log in as root to create the subdirectory, and then change the owner to oracle (oracle software owner) and the group to oinstall.
mkdir pdb1_clone

Configure OMF to the Directory of the Clone PDB

1.       Connect as SYSDBA and set the following parameter: 
sqlplus / as sysdba
alter system set db_create_file_dest='/u02/pdb1_clone';


Cloning the PDB Within the CDB

Commands to clone the PDB within the same CDB
1.       Execute the following statement:
create pluggable database pdb1_clone from pdb1;
2.       Open the new pdb.
alter pluggable database pdb1_clone open;
3.       Connect to the new pdb.
connect system/oracle@localhost:1521/pdb1_clone;
4.       Verify that you are connected to the new PDB:
show con_name

Set the Source PDB Back to open mode

1.       Connect to the root in the CDB.
connect / as sysdba
alter session set container=cdb$root;
2.       Execute the following statement:
alter pluggable database pdb1 close immediate;
3.       Open the source pdb.
alter pluggable database pdb1 open;

Resetting Your Environment to Original State

Perform the following steps to reset your environment prior to repeating the activities covered in this document.
1.       Close the clone PDB.
alter pluggable database pdb1_clone close immediate;
2.       Delete the clone PDB and its data files.

drop pluggable database pdb1_clone including datafiles;

No comments:

Post a Comment