Note:

Clone a Pluggable Database online remotely between DB Systems in Oracle Base Database Service using database link

Introduction

You can create clones of your Pluggable Databases (PDB) within the same database (Container Database) in a DB System. This operation is known as local cloning. This can be achieved easily using the Console. You can also clone a PDB to a different database (Container Database) of a different DB system. This operation is known as remote cloning.

Remote cloning requires two DB Systems, as each DB System supports only one database (Container Database). Remote cloning of PDB is not yet available on the Console. You can create a remote clone using the RemoteclonePluggabledatabase API, using a database link and with API-based tools including the OCI CLI, SDKs, and Terraform.

This tutorial guides you with the steps to remote clone a PDB using a database link on a Oracle Base Database Service.

Objectives

Remote online cloning of a PDB to a different DB system in Oracle Base Database Service using a database link.

Prerequisites

  1. An understanding of Oracle Base Database Service.
  2. Two Oracle Base Database Services either within the same VCN or different VCNs.
  3. VCN Peering if these DB systems are on different VCN VCN Peering.
  4. Below are the environment names used in this tutorial for easy understanding.
    • Source DB system name : SOURCE
    • Destination DB system name: TARGET
    • Source PDB name : SOURCE_PDB1
    • Clone PDB name : CLONE_PDB1

Task 1: Prepare the Source Environment

  1. Create a user for clone purpose on Source CDB using following command.

    CREATE USER c##clone IDENTIFIED BY <PASSWORD> CONTAINER=ALL;
    GRANT CREATE SESSION, CREATE PLUGGABLE DATABASE TO c##clone CONTAINER=ALL;
    
  2. Check the object contents on source PDB: In this example we are considering TEST.PERSONS table for reference.

    • Schema name : TEST

    • Table name : PERSONS

      Source PDB object details

Task 2: Prepare the Destination Environment

  1. Make sure local_undo_enabled is set to true on destination CDB.

  2. Make sure destination CDB is in archivelog mode.

    Note: When the destination CDB is in ARCHIVELOG mode and LOCAL UNDO MODE, the source PDB can be open in read/write mode, and operational during the cloning process. This technique is known as hot cloning.

    Check target CDB local undo & archivelog details

  3. Update the address of the source CDB service name in the tnsnames.ora file located in the $ORACLE_HOME/network/admin/ directory on destination DB system node.

    <addressname> =
    (DESCRIPTION =
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = TCP)(Host = <hostname>)(Port = <port>))
      )
    (CONNECT_DATA =
      (SERVICE_NAME = <service_name>)
    )
    )
    

    Here is a completed example:

    SOURCE_CDB =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = source.**************.*****.oraclevcn.com)(PORT = 1521))
        (CONNECT_DATA =
          (SERVER = DEDICATED)
          (SERVICE_NAME = SOURCE_iad1zr.**************.*****.oraclevcn.com)
        )
      )
    
  4. Create a database link on the destination CDB pointing to the source CDB.

    CREATE PUBLIC DATABASE LINK clone_pdb_dblink CONNECT TO c##clone identified by <PASSWORD> using '<ADDRESSNAME>';
    
    CREATE PUBLIC DATABASE LINK clone_pdb_dblink CONNECT TO c##clone identified by ************** using 'SOURCE_CDB';
    
  5. 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;
    

    Query through dblink

Task 3: Clone a Remote PDB

  1. It’s time to clone the source PDB into the destination CDB by logging into the destination CDB. Provide the TDE_WALLET_PASSWORD of the destination environment.

    alter session set global_names=false;
    
    create pluggable database <CLONE_PDB_NAME> from <SOURCE_PDB_NAME>@<DB_LINK_NAME> keystore identified by <TDE_WALLET_PASSWORD>;
    
    create pluggable database CLONE_PDB1 from SOURCE_PDB1@clone_pdb_dblink keystore identified by <TDE_WALLET_PASSWORD>;
    

    Create a PDB clone on target CDB

  2. Open the cloned PDB in read/write mode. After you create the PDB, it is in mounted mode. You must open the new cloned PDB in read/write mode for Oracle Database to complete the integration of the new PDB into the destination CDB.

    alter pluggable database CLONE_PDB1 open read write;
    
  3. Verify if all the object data is cloned on clone PDB:

    Verify cloned PDB

We can see that the data has been successfully copied over from the source PDB to the clone PDB on destination DB system.

Acknowledgments

More Learning Resources

Explore other labs on docs.oracle.com/learn or access more free learning content on the Oracle Learning YouTube channel. Additionally, visit education.oracle.com/learning-explorer to become an Oracle Learning Explorer.

For product documentation, visit Oracle Help Center.