DOYENSYS Knowledge Portal




We Welcome you to visit our DOYENSYS KNOWLEDGE PORTAL : Doyensys Knowledge Portal




Monday, June 25, 2018

Cloning a PDB in Same CDB in 12c

The Hot cloning is ability to clone a active database, and create a copy of that database in multi tenant database environment.
      In Oracle 12c cloing allows the capability and flexibiltiy of rapid provisioning of database.
     The Hot Cloning of a existing PDB in same CDB using create
pluggable database statement.
     Existing PDB         - PSDBT
     New Clone PDB    - PCLONE

step 1. Connect to the CDB
    CON_NAME
    ------------
    CDB$ROOT
step 2. Check the available PDB
    SQL> show pdbs
    CON_ID CON_NAME  OPEN MODE     RESTRICTED
    ----------- ------------------ ---------------------- -------------------
               2 PDB$SEED    READ ONLY       NO
               3 PSDBT           READ WRITE     NO
               4 APPS             READ WRITE     NO
step 3. Check the datafile path 
        A PDB named as PSDBT is going to be cloned. So before going to cloing that PDB we must check there physical path of the datafile.
  
    SQL> select name from v$datafile where con_id=3;
  
    NAME
    --------------------------------------------------------------------------------
    /u02/app/oracle/oradata/acs/psdbt/system01.dbf
    /u02/app/oracle/oradata/acs/psdbt/sysaux01.dbf
    /u02/app/oracle/oradata/acs/psdbt/undotbs01.dbf
    /u02/app/oracle/oradata/acs/psdbt/user01.dbf
    /u02/app/oracle/oradata/acs/psdbt/user02.dbf
step 4. create a directory 
        Create a Physical directory in Operating System responisble
    for the clonig PDB.
    SQL> !
    [oracle@ramkumar ~]$ mkdir /u02/app/oracle/oradata/acs/pclone
    [oracle@ramkumar pclone]$ exit
    exit
step 5. Clone the PDB 
        The PSDBT Pluggable Database is cloned to PCLONE  Pluggable database using below statement.
  
    SQL> create pluggable database pclone from psdbt
      2 file_name_convert=('psdbt','pclone');
    Pluggable database created.
step 6. Check the PDB status
        The cloned Pluggable database is always in mounted stage.
    SQL> show pdbs
     CON_ID CON_NAME       OPEN MODE  RESTRICTED
    ------- --------------------------- ------------------- ----------
          2 PDB$SEED               READ ONLY    NO
          3 PSDBT                      READ WRITE  NO
          4 APPS                        READ WRITE  NO
          5 PCLONE                   MOUNTED
step 7. Open the PDB and Check the Status
    SQL> alter pluggable database pclone open;
    Pluggable database altered.

    SQL> show pdbs
     CON_ID CON_NAME        OPEN MODE  RESTRICTED
    -------- --------------------------- ------------------- ----------
          2 PDB$SEED                   READ ONLY    NO
          3 PSDBT                          READ WRITE  NO
          4 APPS                            READ WRITE  NO
          5 PCLONE                       READ WRITE  NO

No comments: