Practice 24 - PDB Cloning and Relocation Using DBCA
Practice 24 - PDB Cloning and Relocation Using DBCA
Practice 24 - PDB Cloning and Relocation Using DBCA
Practice Overview
In this practice, you will practice the PDB cloning and relocation methods in DBCA.
Specifically, you will use the dbca utility to perform the following:
Practice Assumptions
You have the ORADB (in srv1) and ORADB2 (in srv2) databases up and running.
In the following steps, you prepare oradb and oradb2 for the practice.
Caution: Do not proceed with the practice before taking a snapshot for the srv1 and srv2 first.
In the following steps, you will create a new PDB (named as PDB2 in oradb ) from the seed container.
8. Open a new Putty session to srv1 as oracle. Issue the following command in it to monitor the
changes in the alertlog file of oradb.
In the rest of the practice, this session is referred to as the srv1 monitoring session. This session
helps us to understand what the dbca executes in the background.
tail -f $ORACLE_BASE/diag/rdbms/oradb/oradb/trace/alert_oradb.log
9. In the other srv1 session, issue the following dbca command to create a PDB named as PDB2 from
the seed container.
While the dbca is executing the command, you can look at the monitoring session to check out the
commands executed by the utility.
The dbca creates the PDB from the seed container because the parameter createpdbfrom is set to
DEFAUTL.
dbca -silent -createpluggabledatabase -createpdbfrom DEFAULT -sourcedb oradb -
pdbName pdb2 -pdbAdminUserName pdb2admin -pdbAdminPassword ABcd##1234
10. Display the available PDBs in oradb and make sure PDB2 is open in read/write mode.
sqlplus / as sysdba
show pdbs
Let’s test if setting the dbca parameter pdbDatafileDestination changes the clone PDB datafiles
destination directory.
14. Issue the following dbca command to create a PDB named as PDB2 from the seed container and set
the PDB2 datafiles in the created directory using the pdbDatafileDestination parameter.
In the monitoring session observe the following statement was run by the dbca:
CREATE PLUGGABLE DATABASE pdb2 ADMIN USER PDBADMIN IDENTIFIED BY *
ROLES=(CONNECT) file_name_convert=
The parameter file_name_convert was used to set the location of the each PDB datafile.
19. Issue the following dbca command to create PDB2 from the seed container and set the
pdbDatafileDestination parameter.
In the monitoring session observe the following statement was run by the dbca:
CREATE PLUGGABLE DATABASE pdb2 ADMIN USER PDBADMIN IDENTIFIED BY *
ROLES=(CONNECT) file_name_convert=NONE
Clean up
In the following steps, you will clone PDB1 in oradb and name the cloned PDB as PDB2.
23. In the other srv1 session, issue the following dbca command to clone PDB1 into a new PDB named
as PDB2.
The dbca understands that we want to clone a local PDB because the parameter createpdbfrom is
set to PDB
dbca -silent -createpluggabledatabase -sourcedb oradb -createpdbfrom PDB -pdbName
pdb2 -sourcepdb pdb1
The impact of pdbDatafileDestination parameter and enabling OMF on this scenario is the same
as their impact on the previous scenario. If you want to, you can test it yourself.
27. Issue the following dbca command to clone PDB1 into a new PDB named as PDB2. Use
fileNameConvert parameter to set PDB2 datafiles location to /home/oracle/oradata
Note: If you try creating the pluggable database PDB2 from SQL using the following command, it
works fine:
CREATE PLUGGABLE DATABASE pdb3 FROM pdb1
FILE_NAME_CONVERT=('/u01/app/oracle/oradata/ORADB/pdb1','/home/oracle/orad
ata');
dbca -silent -createpluggabledatabase -sourcedb oradb -createpdbfrom PDB -pdbName
pdb2 -sourcepdb pdb1 -fileNameConvert
'/u01/app/oracle/oradata/ORADB/pdb1','/home/oracle/oradata'
Clean up
In the following steps, you will clone PDB1 in oradb (which is hosted in srv1) into oradb2 (which is
hosted in srv2). You will name the new PDB as PDB2.
31. In srv1 session, create a common user and grant it the privileges needed to clone a PDB.
CREATE USER c##ruser IDENTIFIED BY abc##1234;
GRANT CREATE SESSION, RESOURCE, CREATE PLUGGABLE DATABASE TO c##ruser
CONTAINER=ALL;
GRANT SYSOPER TO c##ruser CONTAINER=ALL;
32. In srv2 session, invoke dbca to clone PDB1 into oradb2 and name the new PDB as PDB2.
Observe the common user is not enough for the dbca to execute the command. It requires a sysdba
user as well.
Clean up
Because we do not want to change PDB1 in srv1, you will first locally clone PDB1 in oradb into a new
PDB named as PDB2. You will then unplug PDB2 and plug it into oradb2 as PDB3.
36. In srv1 session, locally clone PDB1 as a new PDB named PDB2.
dbca -silent -createpluggabledatabase -sourcedb oradb -createpdbfrom PDB -pdbName
pdb2 -sourcepdb pdb1
37. Use dbca to unplug PDB2. Save the unplugged PDB files into an archive file in the sharing folder.
dbca -silent -unplugDatabase -sourceDB oradb -pdbName pdb2 -archiveType TAR -
pdbArchiveFile '/media/sf_staging/pdb2.arc'
39. In srv2, start the dbca in silent mode to plug in the unplugged PDB. Name the new PDB as PDB3.
dbca -silent -createPluggableDatabase -sourceDB oradb2 -pdbName pdb3 -
createPDBFrom FILEARCHIVE -pdbArchiveFile '/media/sf_staging/pdb2.arc' -workArea
'/media/sf_staging/'
In this section of the practice, you will use dbca to create a PDB from an RMAN backupset file.
41. In srv1 session, invoke RMAN and take a backup of PDB1 as backupset. Save the backupset file
into the staging folder.
$ORACLE_HOME/bin/rman target /
44. In srv2 session, invoke dbca in silent mode to create a PDB named as PDB4.
dbca -silent -createPluggableDatabase -createPDBFrom RMANBACKUP -pdbBackUpfile
'/media/sf_staging/pdb1.back' -pdbMetadataFile '/media/sf_staging/pdb1.xml' -
pdbName pdb4 -sourceDB oradb2
Clean up
47. In Oracle VirtualBox, restore srv1 and srv2 from their snapshots that were taken in the first section
of the practice
49. Delete the backupset file, xml file, and archive file created in the staging folder.
Summary
dbca can be used to create a PDB clone in the following scenarios:
o Creating a PDB clone locally
o Creating a PDB clone remotely
o Plugging in an unplugged PDB
o Creating a PDB from an RMAN backup
The datafiles location of the PDB cloned by dbca is set based on the following algorithm:
o If OMF is enabled, the datafiles will be saved on it (regardless of the
pdbDatafileDestination and fileNameConvert values )
o If OMF is disabled and the parameter pdbDatafileDestination is set, datafiles will be
saved in the directory pointed by the parameter
o If OMF is disabled and the parameter fileNameConvert is set, datafiles should be saved in
the directory pointed by the parameter but that is not practically happening (looks like a bug)
o If OMF is disable and neither of pdbDatafileDestination or fileNameConvert is set,
then the datafiles will be saved in the following path:
$ORACLE_BASE/oradata/$ORACLE_SID/<pdb>