Note:
- This tutorial requires access to Oracle Cloud. To sign up for a free account, see Get started with Oracle Cloud Infrastructure Free Tier.
- It uses example values for Oracle Cloud Infrastructure credentials, tenancy, and compartments. When completing your lab, substitute these values with ones specific to your cloud environment.
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
- An understanding of Oracle Base Database Service.
- Two Oracle Base Database Services either within the same VCN or different VCNs.
- VCN Peering if these DB systems are on different VCN VCN Peering.
- 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
-
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;
-
Check the object contents on source PDB: In this example we are considering
TEST.PERSONS
table for reference.-
Schema name : TEST
-
Table name : PERSONS
-
Task 2: Prepare the Destination Environment
-
Make sure
local_undo_enabled
is set to true on destination CDB. -
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.
-
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) ) )
-
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';
-
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;
Task 3: Clone a Remote PDB
-
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>;
-
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;
-
Verify if all the object data is cloned on clone PDB:
We can see that the data has been successfully copied over from the source PDB to the clone PDB on destination DB system.
Related Links
Acknowledgments
- Author - Leona Dsouza, Senior Cloud Engineer
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.
Clone a Pluggable Database online remotely between DB Systems in Oracle Base Database Service using database link
F87175-01
September 2023
Copyright © 2023, Oracle and/or its affiliates.