Database 12c: Clone PDBs (offline and online)


In 12c it is possible to clone PDB’s. Here an example:

1. Bring source PDB in correct state:

SQL> select con_id,name,open_mode,restricted from v$pdbs;

    CON_ID NAME                           OPEN_MODE  RES GUID
---------- ------------------------------ ---------- --- --------------------------------
         2 PDB$SEED                       READ ONLY  NO  E1E189D14D2C2049E0430100007FAB5B
         3 PDB1                           READ WRITE NO  E1F01A2ED12F718AE0430100007F25BA

SQL> alter pluggable database pdb1 close;

Pluggable database altered.

SQL> alter pluggable database pdb1 open read only;

Pluggable database altered.

SQL>

2. Clone PDB

SQL> create pluggable database pdb2 from pdb1;

Pluggable database created.

    CON_ID NAME                 OPEN_MODE  RES GUID
---------- -------------------- ---------- --- --------------------------------
         2 PDB$SEED             READ ONLY  NO  E1E189D14D2C2049E0430100007FAB5B
         3 PDB1                 READ ONLY  NO  E1EE338E12A16C3EE0430100007F1A4F
         4 PDB2                 MOUNTED        E1F01A2ED12F718AE0430100007F25BA

SQL> select con_id,name from v$datafile order by 1;
    CON_ID NAME
---------- ----------------------------------------------------------------------------------------------------
         1 /opt/oracle/app/oradata/CDB12C1/system01.dbf
         1 /opt/oracle/app/oradata/CDB12C1/sysaux01.dbf
         1 /opt/oracle/app/oradata/CDB12C1/undotbs01.dbf
         1 /opt/oracle/app/oradata/CDB12C1/users01.dbf
         2 /opt/oracle/app/oradata/CDB12C1/pdbseed/sysaux01.dbf
         2 /opt/oracle/app/oradata/CDB12C1/pdbseed/system01.dbf
         3 /opt/oracle/app/oradata/CDB12C1/E1EE338E12A16C3EE0430100007F1A4F/datafile/o1_mf_system_8ynlfvd5_.dbf
         3 /opt/oracle/app/oradata/CDB12C1/E1EE338E12A16C3EE0430100007F1A4F/datafile/o1_mf_sysaux_8ynlfx2p_.dbf
         4 /opt/oracle/app/oradata/CDB12C1/E1F01A2ED12F718AE0430100007F25BA/datafile/o1_mf_sysaux_8yntf0xb_.dbf
         4 /opt/oracle/app/oradata/CDB12C1/E1F01A2ED12F718AE0430100007F25BA/datafile/o1_mf_system_8yntdzmf_.dbf

3. Bring both PDB’s in correct state

SQL> alter pluggable database pdb1 close;

Pluggable database altered.

SQL> alter pluggable database pdb1 open;

Pluggable database altered.

SQL> alter pluggable database pdb2 open;

Pluggable database altered.

SQL>

As you can see you have to bring a PDB in READ ONLY mode to clone it. I think this is not really suitable for production environments.

After some bainstorming I found a way to clone PDB’s online. All you need is some storage. Here the plan to clone PDBs online:

  1. Duplicate target PDB to a auxiliary PDB
    –> Bring the PDB to an non production environment
  2. Create a clone PDB from the auxiliary PDB
    –> The GUID of the PDB must change to replug in old CDB. I don’t found another way to change the GUID right now.
  3. Unplug an plug the clone PDB in the target CDB
    –> Transport metadata back to target
  4. Cleanup the shadow CDB
    –> Cleanup all

I’vh read that the real online cloning functionality will come in the next release.

2 thoughts on “Database 12c: Clone PDBs (offline and online)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s