Quantcast
Channel: Doyensys Allappsdba Blog..
Viewing all articles
Browse latest Browse all 1640

Hot Cloning of a Remote PDB in 12c

$
0
0
 The remote CDB is in local undo mode and archivelog mode, we don't need to turn the remote database into read-only mode
CDB1 - The remote container database which used for cloing a particular PDB named PSDBT.
CDB2 - The container database where we going to clone a PDB.
Step 1. Connect to the CDB.
    cdb1> select name, log_mode, cdb from v$database;
    NAME      LOG_MODE               CDB
    ---------           ------------                  ---
    CBD1      ARCHIVELOG              YES

Step 2. check Local Undo Mode of Remote CDB.
    cdb1> select property_name, property_value
      2  from database_properties
      3  where property_name='LOCAL_UNDO_ENABLED';
    PROPERTY_NAME         PROPERTY_VALUE
    ---------------------                      -----------------
    LOCAL_UNDO_ENABLED            TRUE

Step 3. Connect to the another CDB.
    cdb2> select name, log_mode, cdb from v$database;
    NAME          LOG_MODE                CDB
    --------             ------------                      ---
    CDB2      NOARCHIVELOG             YES

Step 4. Check Local Undo Mode of source CDB.
    cdb2> select property_name, property_value
      2  from database_properties
      3  where property_name='LOCAL_UNDO_ENABLED';
    PROPERTY_NAME             PROPERTY_VALUE
    ---------------------                          -----------------
    LOCAL_UNDO_ENABLED             TRUE

Step 5. Check tnsping between network.
  
    chech net configuration between source and remote server.
     tnsping cdb1 2
     tnsping cdb2 2
     [oracle@ramkumar ~]$ tnsping psdbt 2
    TNS Ping Utility for Linux: Version 12.2.0.1.0 - Production on 25-JUN-2018 09:56:14
    Copyright (c) 1997, 2016, Oracle.  All rights reserved.
    Used parameter files:
    /u02/app/oracle/product/12.2.0.1/db_1/network/admin/sqlnet.ora

    Used TNSNAMES adapter to resolve the alias
    Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST =   
acs.localdomain)(PORT = 1521))) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME =   
psdbt.localdomain)))
    OK (0 msec)
    OK (0 msec)

Step 6. Create database link in source CDB.
        Create database link name as cdb_ln using
    a user and password of existing user in target CDB.
    
    cdb2>create database link cdb_ln
      2  connect to c##ram
      3  identified by oracle
      4  using 'psdbt';
    Database link created.
Step 7. Check the link
    cdb2> column DB_LINK format a10
    cdb2> column username format a10
    cdb2> column host format a10
    cdb2> select db_link,username,host from dba_db_links;
    DB_LINK    USERNAME   HOST
    ---------- ---------- ----------
    SYS_HUB               CDB2
    CDB_LN     C##RAM    psdbt

Step 8. Check the PDB datafile path using link.
    cdb2>select name from v$datafile@cdb_ln;
    NAME
    --------------------------------------------------------------------------------
    /u02/app/oracle/oradata/ram/system01.dbf
    /u02/app/oracle/oradata/ram/sysaux01.dbf
    /u02/app/oracle/oradata/ram/undotbs01.dbf
    /u02/app/oracle/oradata/ram/user01.dbf
    /u02/app/oracle/oradata/ram/user02.dbf
    
Step 9. Create a directory in responsible place in OS.
    cdb2>!
    [oracle@ramkumar ~]$ mkdir /u02/app/oracle/oradata/pdbnew
    [oracle@ramkumar ~]$ exit
    exit
Step 10. Clone the Remote PDB using database link.
    cdb2>create pluggable database pdbnew
      2  from psdbt@cdb_ln
      3  file_name_convert=  
('/u02/app/oracle/oradata/ram/','/u02/app/oracle/oradata/pdbnew/');
    Pluggable database created.
  
Step 11. Check the Pluggable database mode
    cdb2>show pdbs
  
        CON_ID         CON_NAME                      OPEN MODE          RESTRICTED
    ----------         ------------------------------                ----------                     ----------
             2            PDB$SEED                       READ ONLY                    NO
             3            LONEPDB                         MOUNTED
             4            LTWOPDB                         MOUNTED
             5            PDBNEW                          MOUNTED
Step 12. Open the Cloned PDB in read only mode
    cdb2>alter pluggable database pdbnew open read only;
  
    Pluggable database altered.
  
    cdb2>show pdbs
        CON_ID       CON_NAME                       OPEN MODE                RESTRICTED
    ---------------    ------------------------                   ----------                              ----------
             2          PDB$SEED                              READ ONLY                         NO
             3          LONEPDB                                MOUNTED
             4          LTWOPDB                                MOUNTED
             5          PDBNEW                                  READ ONLY                        YES
Step 13. Change the session to Newly cloned PDB.

    cdb2>alter session set container=pdbnew;
    Session altered.

Step 14. Check the Consistency of cloned records.
    cdb2>show con_name;
    CON_NAME
    ------------------------------
    PDBNEW

    cdb2>select count(*) from dba_tables;
      COUNT(*)
         ----------
          1751
    
Step 15. Connect session to CDB. 
  
    cdb2>alter session set container=cdb$root;
  
    Session altered.
  
  
Step 16. Check the consistency of records by dblinks.
    cdb2>select count(*) from dba_tables@cdb_ln;
    
      COUNT(*)

       ----------

         1751


Step 17. Close the read only mode and open it normaly.    
  
    cdb2>alter pluggable database pdbnew close immediate;
  
    Pluggable database altered.

Viewing all articles
Browse latest Browse all 1640

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>