In Oracle database release 12.1, in order to clone a PDB, The source PDB must be quiescent(read only mode) for the duration of the clone operation. So it was called a “cold clone” operation because it involved an outage (from a transactional perspective) in the source database.
This applies for both the same CDB clone or Remote CDB clone.
Related Article
Oracle database 12c:How to create Pluggable database in 12c database
It is possible to clone without putting the PDB in read-only mode but somes time we get ORA-600 errors. Also it is not the supported method as suggested by Oracle. So it is not recommended to clone PDB while it is open read-write
With Oracle Database Release 12.2, Oracle has given the support for hot clone. This on-line cloning capability is available on all storage supported by Oracle Database.
A hot clone can be taken while the source PDB is still open read-write. What that means is that a hot clone can be taken without interrupting operations in the source PDB. No application outage is required for a hot clone.
How Oracle is doing in the background
(1) It is doing in a hot clone is known as a “fuzzy read” of all the blocks in the datafiles of the source PDB. What this means is that, if the clone operation begins at time t0, by the time the last of the blocks in the source PDB have been read and copied to the target (time t1), some changes may have been made to some of the blocks already copied. At this stage, then, the clone may be physically inconsistent with the source.
(2) The next step is to copy all the redo that has accumulated for that source PDB between times t0 and t1, and transport this to the target. This redo is then applied to the target PDB. At this stage, the target PDB will be an exact physical copy of the source PDB as of time t1. However, this includes both committed transactions and uncommitted transactions, and therefore should be considered to be potentially transactionally inconsistent.
(3) What is required now is to rollback the uncommitted transactions. This is achieved by applying the undo for all these uncommitted transactions. This is the final stage of the clone operation. The resultant clone will be a transactionally consistent copy of the source PDB as of time t1. That is, all committed transactions in the source PDB as of time t1 will be present in the clone, and all uncommitted transactions will have been rolled back.
The key technology which is making this possible is local undo. Oracle has introduced local Undo in 12.2. So each PDB has seperate UNDO and uncommitted transaction can be rolled back from it .
Related Articles
Local Undo in Oracle Database 12c R2(12.2)
If you are in 12.2 and If the CDB is not in local undo mode, then the source PDB still must be in open read-only mode.
If the CDB is not in ARCHIVELOG mode, then the source PDB must be in open read-only mode. This requirement does not apply if the CDB is in ARCHIVELOG mode
How to clone the Local PDB in Oracle Database 12.2
Suppose we want to create PDB(test2_tech) from existing db test1_tech,
(a) First we need to check for Archive log mode and undo mode
CONN / AS SYSDBA
COLUMN property_name FORMAT A30
COLUMN property_value FORMAT A30
SELECT property_name, property_value
FROM database_properties
WHERE property_name = 'LOCAL_UNDO_ENABLED';
PROPERTY_NAME PROPERTY_VALUE
--------------------- -----------------------------
LOCAL_UNDO_ENABLED TRUE
SQL>SELECT log_mode
FROM v$database;
LOG_MODE
----------------
ARCHIVELOG
SQL>
We can use below method to put the database in Archivelog mode ,incase not present
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
ALTER DATABASE ARCHIVELOG;
ALTER DATABASE OPEN;
(b) Since the Local Undo and Archive log is enabled, we need not put the source PDB is read only mode
c) If OMF is set i.e DB_CREATE_FILE_DEST or CREATE_FILE_DEST,
CREATE PLUGGABLE DATABASE
test2_tech FROM test1_tech;
if OMF not set
CREATE PLUGGABLE DATABASE
test2_tech FROM test1_tech
FILE_NAME_CONVERT= (‘/u01/oracle/CDB1/datafile/techdata’,
‘/u01/oracle/CDB1/datafile/tech2data’);
;
(d) We can see the new PDB has been created, but it is in the MOUNTED state.
COLUMN name FORMAT A30
SELECT name, open_mode FROM v$pdbs WHERE name = 'TEST2_TECH';
NAME OPEN_MODE
-------- ------------------
TEST2_TECH MOUNTED
SQL>
The PDB is opened in read-write mode to complete the process.
ALTER PLUGGABLE DATABASE TEST2_TECH OPEN;
SELECT name, open_mode FROM v$pdbs WHERE name = 'TEST2_TECH';
NAME OPEN_MODE
-------- ---------------
TEST2_TECH READ WRITE
Hope you like this article on Hot PDB cloning in Oracle database 12.2. Oracle database 12.2 has come up with lot of new features to help with Administration ,performance tuning.
Related Articles
approx_count_distinct : Oracle Database 12c : The approx_count_distinct is a 12c new feature to reduces the time required to get the number of distinct values (NDV) for a table column
Oracle Flex Cluster 12c : Oracle Flex cluster 12c is a new Oracle Clusterware based High Availability clustering topology.it has hub nodes and leaf nodes.
Online move of active datafile in 12c :This articles gives the detailed steps for Online move of active datafile in 12c. it can be used for movement from ASM to non-ASM
Oracle Database Interactive Quick Reference Guide | 11g & 12c
New Optimizer Feature with 11g and 12c