News
Perth, Australia
+ (61) 417713124
prosolutions@gavinsoorma.com

19c New Feature DBCA Pluggable Database remote clone and relocate

  • Posted by Gavin Soorma
  • On August 13, 2019
  • 0 Comments
  • 18c, 19c, 19c new feature, CDB, clone, dbca silent, PDB, relocate, remote clone

A new feature in Oracle 19c is the ability to use DBCA to not only perform a remote clone of a PDB, but also to relocate a PDB from one Container Database to another.

Let us have a look an example where we will first clone a PDB and then relocate the PDB to another CDB.

 
This is our initial environment

  • Container database CDB1 (host02): PDB$SEED, PDB1
  • Container database CDB2 (host03): PDB$SEED

This is the intended final environment

  • Container database CDB1 (host02): PDB$SEED
  • Container database CDB2 (host03): PDB$SEED, PDB1, PDB2

 

SQL> select name from v$database;

NAME
---------
CDB1

SQL> show pdbs

    CON_ID CON_NAME			  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
	 2 PDB$SEED			  READ ONLY  NO
	 3 PDB1 			  READ WRITE NO

SQL> select name from v$database;

NAME
---------
CDB2

SQL> show pdbs

    CON_ID CON_NAME			  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
	 2 PDB$SEED			  READ ONLY  NO

 
Remote Clone CDB1/PDB1 to CDB2/PDB2
 
Create the Common User which will be used for the database link
 

SQL> create user c##link_user identified by Oracle4U;

User created.

SQL> GRANT CREATE SESSION, RESOURCE, CREATE ANY TABLE, UNLIMITED TABLESPACE TO c##link_user CONTAINER=ALL;

Grant succeeded.

SQL> GRANT CREATE PLUGGABLE DATABASE TO c##link_user CONTAINER=ALL;

Grant succeeded.

SQL> GRANT SYSOPER TO c##link_user CONTAINER=ALL;

Grant succeeded.

 
Create the database link in CDB2 connecting to CDB1
 

SQL> create database link cdb1_link 
  2  connect to c##link_user identified by Oracle4U
  3  using 'CDB1';

Database link created.


SQL> select * from dual@cdb1_link;

D
-
X

 

Run DBCA in silent mode performing the remote clone (run this from CDB2)
 

[oracle@host03 admin]$ dbca 
-silent 
-createPluggableDatabase 
-createFromRemotePDB 
-sourceDB cdb2  
-remotePDBName pdb1 
-remoteDBConnString host02:1521/cdb1.localdomain 
-remoteDBSYSDBAUserName SYS 
-remoteDBSYSDBAUserPassword G#vin1 
-dbLinkUsername c##link_user 
-dbLinkUserPassword Oracle4U 
-sysDBAUserName SYS 
-sysDBAPassword G#vin1
-pdbName pdb2 
-pdbDatafileDestination '/u01/app/oracle/oradata/CDB2/pdb2/'


Prepare for db operation
50% complete
Create pluggable database using remote clone operation
100% complete
Pluggable database "pdb2" plugged successfully.
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/cdb2/pdb2/cdb2.log" for further details.

 

In CDB2 verify that the pluggable database PDB2 is created and also note the location of the data files for PDB2
 

SQL> show pdbs

    CON_ID CON_NAME			  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
	 2 PDB$SEED			  READ ONLY  NO
	 3 PDB2 			  READ WRITE NO

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/CDB2/system01.dbf
/u01/app/oracle/oradata/CDB2/sysaux01.dbf
/u01/app/oracle/oradata/CDB2/undotbs01.dbf
/u01/app/oracle/oradata/CDB2/pdbseed/system01.dbf
/u01/app/oracle/oradata/CDB2/pdbseed/sysaux01.dbf
/u01/app/oracle/oradata/CDB2/users01.dbf
/u01/app/oracle/oradata/CDB2/pdbseed/undotbs01.dbf
/u01/app/oracle/oradata/CDB2/pdb2/system01.dbf
/u01/app/oracle/oradata/CDB2/pdb2/sysaux01.dbf
/u01/app/oracle/oradata/CDB2/pdb2/undotbs01.dbf
/u01/app/oracle/oradata/CDB2/pdb2/users01.dbf

 
Relocate PDB1 from CDB1 to CDB2
 
Run DBCA in silent mode to perform the relocation (run this from CDB2)
 

[oracle@host03 admin]$ dbca 
-silent 
-relocatePDB 
-sourceDB cdb2  
-remotePDBName pdb1 
-remoteDBConnString host02:1521/cdb1.localdomain 
-remoteDBSYSDBAUserName SYS 
-remoteDBSYSDBAUserPassword G#vin1
-dbLinkUsername c##link_user 
-dbLinkUserPassword Oracle4U 
-sysDBAUserName SYS 
-sysDBAPassword G#vin1
-pdbName pdb1 
-pdbDatafileDestination '/u01/app/oracle/oradata/CDB2/pdb1/'

Prepare for db operation
50% complete
Create pluggable database using relocate PDB operation
100% complete
Pluggable database "pdb1" plugged successfully.
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/cdb2/pdb1/cdb20.log" for further details.

 

Verify the environment after the clone and relocation
 

SQL> select name from v$database;

NAME
---------
CDB2

SQL> show pdbs

    CON_ID CON_NAME			  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
	 2 PDB$SEED			  READ ONLY  NO
	 3 PDB2 			  READ WRITE NO
	 4 PDB1 			  READ WRITE NO


SQL> select name from v$database;

NAME
---------
CDB1

SQL> show pdbs

    CON_ID CON_NAME			  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
	 2 PDB$SEED			  READ ONLY  NO

 

0 Comments

Leave Reply

Your email address will not be published. Required fields are marked *