Saturday 14 September 2024

Clone PDB from Remote PDB In Oracle 19C database:

Dear All,

In this post i am going to share how to preform PDB clone from Remote PDB .


Create clones of your PDB within the same DB (Container Database) in a 

DB System. This operation is known as local cloning. 

>>> OCI console level we can do this .

Create clones of your PDB to a different database (Container Database)

of a different DB system. This operation is known as remote cloning.

>>> OCI console level we cannot perform the remote clone .

------------------------------------------------


Source DB : PRODDB ( remote ) ( ex: pdb , pdb1 ) 

TARGET DB : TESTDB  ( local ) ( ex: pdb )


Source DB system name : PRODDB01

Destination DB system name: TESTDB01

Source PDB name : PDB1  ( PRODDB ) 

Clone PDB name : CLONE_PDB2 ( TESTDB )

Destination db should be archive log mode enabled and local undo enabled should be true.


Step1 :  Source Database preparation ( PRODDB)


      >  create user in CDB$ROOT and grant the create session and create pluggable database role. 
     > create some test data on pdb1.
/u01/app/oracle/product/19.0.0/db_home/rdbms/admin/utlsampl.sql


CREATE USER c##clone IDENTIFIED BY Welcome_123 CONTAINER=ALL;
GRANT CREATE SESSION, CREATE PLUGGABLE DATABASE TO c##clone CONTAINER=ALL;





Step 2 :: Prepare the destination database ( TESTDB )
   
    > local_undo_enabled should be true 
   > archive log mode  should be enabled 
   > update the source db tnsnames.ora entry in this db. 
   > create the db_link on this server ( TESTDB)  using source db user ( PRODDB).
   > test the db link
   


select property_name,property_value from database_properties where property_name='LOCAL_UNDO_ENABLED';

archive log list;


> Update the remote DB ( PRODDB) tnsnames.ora on Local db tnsnames.ora ( TESTDB)






bounce the listener to update the changes ..


test the connection for Remote db from Local db ..



> create a db link on your destination db ( TESTDB ) to pointing to the source db ( PRODDB)


CREATE PUBLIC DATABASE LINK clone_pdb_dblink CONNECT TO c##clone identified by Welcome_123 using 'PRODDB';



note : Check if the connectivity through database link works fine on destination CDB. As we are not using the database link with the same name as the database it connects to, we need to additionally set the global_names parameter to false. Else, you’ll encounter ORA-02085 error.

alter session set global_names=false;

select * from dual@clone_pdb_dblink;



Step3 : Report PDB clone activity 

  > create remote pdb ( PRODDB) to local pdb( testdb) 
 > start the newly cloned pdb.
 > do the sanity check which we have created some dummy data check that was there or not.





Create a New PDB in the Local DB by cloning the Remote PDB.

Here we need to check with FILE_NAME_CONVERT parameter for 
file name conversions because we are not using OMF (Oracle Managed Files).


create pluggable database CLONE_PDB1 from pdb1@clone_pdb_dblink file_name_convert=('/u01/app/oracle/oradata/PRODDB/pdb1','/u01/app/oracle/oradata/TESTDB/clone_pdb1');


alter pluggable database CLONE_PDB1 open







remote pdb clone successfully completed.


Thanks,
Srini



No comments:

Post a Comment


No one has ever become poor by giving