OCI: Cloning a remote-PDB as a PDB

This note describes how to clone a remote PDB as a new located on a OCI dbsystem.

 

#1 From the source CDB

CONNECT / AS SYSDBA
ALTER SESSION SET CONTAINER=<source pdb>;
CREATE USER dbclone IDENTIFIED BY 'password';
GRANT CREATE SESSION TO dbclone;
GRANT CREATE PLUGGABLE DATABASE TO dbclone;
CONNECT / AS SYSDBA
ALTER PLUGGABLE DATABASE <source pdb> CLOSE;
ALTER PLUGGABLE DATABASE <source pdb> OPEN READ ONLY;

 

#2 From the target CDB:

DROP DATABASE LINK dblink;
CREATE DATABASE LINK dblink
CONNECT TO dbclone IDENTIFIED BY <password> 
USING '(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = <private ip of the dbsystem>)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = <source pdb>.<domain>)))';
ALTER SESSION SET global_name=FALSE;    <= Optional if getting ORA-02085 error
SELECT COUNT(1) FROM dual@dblink;

 

#3 Submit the clone (started from the target CDB)

ALTER PLUGGABLE DATABASE <target pdb> CLOSE;
DROP PLUGGABLE DATABASE <target pdb> INCLUDING DATAFILES;
CREATE PLUGGABLE DATABASE <target pdb> FROM <source pdb>@dblink
KEYSTORE IDENTIFIED BY "<target cdb wallet password>";

Note: the last command above may return the error ORA-28382: Global wallet operation in RAC failed. This error means that the ORACLE_UNQNAME variable has probably not been properly set.

 

#4 In case of plugging violation of that kind, run database to rollback patches not available in the target db

$ORACLE_HOME/OPatch/datapatch


#5 Then reopen the PDB
ALTER PLUGGABLE DATABASE <target pdb> CLOSE;
ALTER PLUGGABLE DATABASE <target pdb> OPEN;
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s