Oracle Database 12.1.0.2c: Hot Cloning Of Pluggable Databases

Cloning of a Pluggable Database (PDB) in Oracle Multitenant is a great feature and is very useful. Oracle Database 12c Release 1 has introduced various enhancements to the cloning of Pluggable Databases to overcome the limitations imposed by the initial release of Oracle Database 12c (12.1.0.1). In Oracle 12.1.0.2c: PDBs can be hot cloned, i.e. you don’t need to put the source PDB

Cloning of a Pluggable Database (PDB) in Oracle Multitenant is a great feature and is very useful. Oracle Database 12c Release 1 has introduced various enhancements to the cloning of Pluggable Databases to overcome the limitations imposed by the initial release of Oracle Database 12c (12.1.0.1). In Oracle 12.1.0.2c:

  • PDBs can be hot cloned, i.e. you don’t need to put the source PDB in read-only for cloning so that it can be cloned to a CDB online. In Oracle 12.1.0.1c, a pluggable database can be cloned only if it is read-only.
  • PDBs can be remote cloned, i.e. the source PDB may be located in a remote container. This feature was listed in Oracle Database 12c Release 1 (12.1.0.1), but didn’t work.
  • There is no need to create the directories where the database files of clone PDB will be placed. If the directory is not already present, it will be automatically created as part of the cloning operation.

In this article, I will demonstrate hot cloning of a PDB locally as well as remotely. For the purpose of this demonstration, I have two virtual machines, each with a container database.

Current scenario:

Host: host01
Container Database 12.1.0.2c: cdb1 with pluggable database pdb1

Host: host02
Container Database 12.1.0.2c: destcdb with pluggable database pdb1

Demonstration 1: Hot cloning of PDB locally

We will clone the pluggable database pdb1 to pdb1clone in the same CDB, i.e. cdb1 on host host01

Source host: host01
Source PDB: pdb1 in container database cdb1

Destination host: host01
Destination PDB: pdb1clone in container database cdb1

Currently, there is only one PDB called pdb1 currently open in READ WRITE mode in the container database cdb1.

CDB1>select name, cdb from v$database;

Verify that directory corresponding to data files of target PDB, i.e. pdb1clone is not present:

Using the CREATE PLUGGABLE DATABASE ... FROM command we will clone the existing PDB (pdb1) to create a new PDB (pdb1clone) in the same container database (cdb1). This statement copies the files associated with the source PDB to a new location and associates the files with the target PDB.

We can see that the new PDB called pdb1clone is in MOUNTED state when created and is opened successfully thereafter.

CDB1>sho pdbs

Note that the directory for the data files of the clone PDB pdb1clone has been created automatically in the location specified using FILE_NAME_CONVERT.

[oracle@host01 cdb1]$ ls -l /u01/app/oracle/oradata/cdb1/pdb1clone

Hence, we have been able to hot clone a PDB locally without:

  • Placing the source PDB in READ ONLY mode
  • Creating the directory for the destination PDB

Demonstration 2: Hot cloning of PDB remotely

We will clone the pluggable database pdb1 in CDB cdb1 on host host01 to pdb1new in another CDB, i.e. destcdb on host host02:

Source host: host01
Source PDB: pdb1 in container database cdb1

Destination host: host02
Destination PDB: pdb1new in container database destcdb

Currently, there is only one PDB called pdb1 open in READ WRITE mode in destination container database destcdb:

On the target container database destcdb, we need to create the database link to connect to source container database cdb1 which will be used in the CREATE PLUGGABLE DATABASE.

Verify that the source pluggable database (pdb1@cdb1) that we want to clone is in READ WRITE mode.

Let’s execute the CREATE PLUGGABLE DATABASE statement using the database link (cdb1_link) as previously defined.

Let’s find out location of datafiles for pdb1@cdb1 on host01:

Verify that directory corresponding to data files of target PDB, i.e. pdb1new, is not present on the target host host02:

Let’s specify FILE_NAME_CONVERT and re-execute the CREATE PLUGGABLE DATABASE statement using the database link (cdb1_link) we previously defined:

By default the new pluggable database is created in MOUNTED state and can be opened.

Verify that the directory for data files of pbdnew has been created automatically on host02 in the location specified using FILE_NAME_CONVERT:

Hence, we have been able to hot clone a PDB remotely without:

  • Placing the source PDB in READ ONLY mode
  • Creating the directory for the destination PDB

Summary:

In Oracle 12.1.0.2c, various enhancements been made to cloning of PDB:

  • PDBs can be hot cloned, i.e. you don’t need to put the source PDB in read-only for cloning so that it can be cloned to a CDB online.
  • PDBs can be hot cloned remotely as well, i.e. the source PDB can be located in a remote container.
  • There is no need to create the directories where the database files of clone PDB will be placed. If the directory is not already present, it will be automatically created as part of the cloning operation.