Friday 25 May 2018

Hot Cloning of PDB - 12c2 / 18c



12C has brought the container & Pluggable database feature. To clone a PDB from another clone, we need to keep the source PDB in read only mode.


SQL> SELECT PROPERTY_NAME, PROPERTY_VALUE FROM DATABASE_PROPERTIES WHERE  PROPERTY_NAME = 'LOCAL_UNDO_ENABLED'
  2  ;
no rows selected




SQL> create pluggable database DEVPDB4 from DEVPDB3;
create pluggable database DEVPDB4 from DEVPDB3
*
ERROR at line 1:
ORA-65035: unable to create pluggable database from DEVPDB3






From 12cr2 onwards we can perform this operation while source PDB is in read write mode
In-order to achieve this, we should have the following conditions met.


    1. Enabled local Undo
    2. cloneddb=true ( init.ora parameter)










Enable Local Undo
   This need to be done in upgrade mode






# stop DB
srvctl stop database -d db1


# set cluster_database = false ( it you are doing on RAC)
sqlplus /nolog
conn /as  sysdba
alter system set cluster_database=false scope=spfile;
shutdown immediate;




# enable local undo
sqlplus /nolog
conn / as sysdba
startup upgrade
ALTER DATABASE LOCAL UNDO ON;
shutdown immediate;
exit


# enable cluster_database=true ( if you are peforming this activity in RAC)
sqlplus /nolog
conn /as  sysdba
alter system set cluster_database=true scope=spfile;
shutdown immediate;


# start db
srvctl start database -d db1


set clonedb=true


  alter system set cloned=true scope=spfile sid='*' ;
 
# bounce the db to effect the above parameter


# Verify if local undo is enabled




SQL> SELECT PROPERTY_NAME, PROPERTY_VALUE FROM DATABASE_PROPERTIES WHERE  PROPERTY_NAME = 'LOCAL_UNDO_ENABLED';
PROPERTY_NAME
--------------------------------------------------------------------------------
PROPERTY_VALUE
--------------------------------------------------------------------------------
LOCAL_UNDO_ENABLED
TRUE




Hot Clone PDB


# Source PDB in read write mode


 1* select name,open_mode from v$pdbs where name='DEVPDB3'
SQL> /
NAME                           OPEN_MODE
------------------------------ ----------------------------------------
DEVPDB3                        READ WRITE


SQL> create pluggable database DEVPDB4 from DEVPDB3;
Pluggable database created.
SQL>











No comments:

Post a Comment

ZFS

Public Cloud tools comparison