8i | 9i | 10g | 11g | 12c | 13c | 18c | 19c | 21c | 23c | Misc | PL/SQL | SQL | RAC | WebLogic | Linux

Home » Articles » 18c » Here

Multitenant : DBCA PDB Clone and DBCA CDB Duplicate in Oracle Database 18c

The Database Configuration Assistant (DBCA) includes a number of enhancements in Oracle 18c, but there are two that are specific to the multitenant environments. In Oracle 18c it's now possible to clone a pluggable database (PDB) and duplicate a container database (CDB) using the Database Configuration Assistant (DBCA).

Multitenant : Clone

Related articles.

Clone a PDB with the DBCA

In 18c the DBCA -createPluggableDatabase command accepts a new value for the -createPDBFrom parameter, allowing us to create a new PDB by cloning an existing PDB.

   [-createPDBFrom {DEFAULT | FILEARCHIVE | RMANBACKUP | USINGXML | PDB}
      [-pdbArchiveFile pdb_archive_file_name_with_directory_path]
      [-PDBBackUpfile pdb_backup_file_name_with_directory_path]
      [-PDBMetadataFile pdb_metadata_file_name_with_directory_path]
      [-pdbAdminUserName pdb_administrator_name]
      [-pdbAdminPassword pdb_administrator_password]
      [-createNewPDBAdminUser {true | false}]
      [-sourceFileNameConvert method_to_locate_pdb_files]
      [-fileNameConvert names_of_pdb_files]
      [-pdbStorageMAXSizeInMB maximum_storage_size_for_the_pdb_in_MB]
      [-pdbStorageMAXTempSizeInMB maximum_temporary_storage_size_for_the_pdb_in_MB]
      [-workArea directory_to_unzip_PDB_archive_files_for_FILEARCHIVE_option]
      [-copyPDBFiles  {true | false}]
      [-sourcePDB name_of_the_pdb_to_clone]

You can see the full syntax for the -createPluggableDatabase command here.

In the following example we have a container database called "cdb1" and an existing pluggable database called "pdb1". We use the DBCA to create a new PDB called "pdb2" as a clone of "pdb1".

export ORACLE_SID=cdb1
export ORAENV_ASK=NO
. oraenv
export ORAENV_ASK=YES

dbca -silent \
     -createPluggableDatabase \
     -sourceDB cdb1 \
     -pdbName pdb2 \
     -createAsClone true \
     -createPDBFrom PDB \
     -sourcePDB pdb1
[WARNING] [DBT-15030] The Pluggable database (pdb1) will be closed and opened in read only mode to perform the clone operation.
Prepare for db operation
13% complete
Creating Pluggable Database
15% complete
19% complete
23% complete
31% complete
53% complete
Completing Pluggable Database Creation
60% complete
Executing Post Configuration Actions
100% complete
Pluggable database "pdb2" plugged successfully.
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/cdb1/pdb2/cdb11.log" for further details.
$

Notice the warning about the source PDB being switched into read-only mode. This is because the database wasn't in archivelog mode. Let's delete the new PDB.

dbca -silent \
     -deletePluggableDatabase \
     -sourceDB cdb1 \
     -pdbName pdb2
Prepare for db operation
25% complete
Deleting Pluggable Database
40% complete
41% complete
86% complete
93% complete
100% complete
Pluggable database "pdb2" deleted successfully.
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/cdb1/pdb2/cdb12.log" for further details.
$

Switch the CDB into archivelog mode.

sqlplus / as sysdba <<EOF
shutdown immediate;
startup mount;
alter database archivelog;
alter database open;
exit
EOF

If we repeat the clone command we ran before, we can see it now performs a hot clone of the PDB.

dbca -silent \
     -createPluggableDatabase \
     -sourceDB cdb1 \
     -pdbName pdb2 \
     -createAsClone true \
     -createPDBFrom PDB \
     -sourcePDB pdb1
Prepare for db operation
13% complete
Creating Pluggable Database
15% complete
19% complete
23% complete
31% complete
53% complete
Completing Pluggable Database Creation
60% complete
Executing Post Configuration Actions
100% complete
Pluggable database "pdb2" plugged successfully.
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/cdb1/pdb2/cdb13.log" for further details.
$

Let's clean up by deleting the "pdb2" pluggable database.

dbca -silent \
     -deletePluggableDatabase \
     -sourceDB cdb1 \
     -pdbName pdb2
Prepare for db operation
25% complete
Deleting Pluggable Database
40% complete
85% complete
92% complete
100% complete
Pluggable database "pdb2" deleted successfully.
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/cdb1/pdb2/cdb14.log" for further details.
$

Duplicate a CDB with the DBCA

In Oracle 18c we have several new parameters for the DBCA -createDuplicateDB command, but none of them look directly related to the multitenant architecture.

dbca -createDuplicateDB 
    -gdbName global_database_name 
    -primaryDBConnectionString easy_connect_string_to_the_primary_database
    -sid database_system_identifier
    [-initParams initialization_parameters
        [-initParamsEscapeChar initialization_parameters_escape_character]]
    [-policyManaged | -adminManaged]
    [-policyManaged
        -serverPoolName server_pool_names
        [-pqPoolName pq_pool_name]
        [-createServerPool new_server_pool_name
            [-pqPoolName new_pq_pool_name]
            [-force]
            [-pqCardinality pq_cardinality_of_the_new_server_pool]
            [-cardinality cardinality_of_the_new_server_pool]]]
    [-adminManaged]
    [-datafileDestination data_files_directory]
    [-databaseConfigType {SINGLE | RAC | RACONENODE}
        [-RACOneNodeServiceName service_name_for_RAC_One_Node_database]]
    [-createAsStandby 
        [-dbUniqueName db_unique_name_for_standby_database]]
    [-customScripts custom_sql_scripts_to_run_after_database_creation]
   [-useWalletForDBCredentials {true | false}
        -dbCredentialsWalletPassword wallet_account_password
        -dbCredentialsWalletLocation wallet_files_directory]

You can see the full syntax for the -createDuplicateDB command here.

There is a multitenant change, but it has happened under the hood. In Oracle 12.2 it was not possible to duplicate a container database using DBCA. Attempting to do so would result in the following error.

dbca -silent \
     -createDuplicateDB \
     -gdbName cdb2 \
     -primaryDBConnectionString "localhost:1521/cdb1" \
     -sid cdb2 \
     -sysPassword SysPassword1
[FATAL] [DBT-16057] Specified primary database is a container database (CDB).
   CAUSE: Duplicate database operation is supported only for non container databases.
$

In Oracle 18c the DBCA can now duplicate container databases. In the following example we have a container database called "cdb1". We use the following command to attempt to create a new CDB called "cdb2" as a clone of "cdb1", but it fails because the source database is not in archivelog mode.

dbca -silent \
     -createDuplicateDB \
     -gdbName cdb2 \
     -primaryDBConnectionString "localhost:1521/cdb1" \
     -sid cdb2 \
     -sysPassword SysPassword1
[FATAL] [DBT-16051] Archive log mode is not enabled in the primary database.
   ACTION: Primary database should be configured with archive log mode for creating a duplicate or standby database.

If we switch the database into archivelog mode, the duplication completes, even though it's a container database being duplicated.

dbca -silent \
     -createDuplicateDB \
     -gdbName cdb2 \
     -primaryDBConnectionString "localhost:1521/cdb1" \
     -sid cdb2 \
     -sysPassword SysPassword1
[WARNING] [DBT-10331] Specified SID Name (cdb2) may have a potential conflict with an already existing database on the system.
   CAUSE: The specified SID Name without the trailing numeric characters ({2}) may have a potential conflict with an already existing database on the system.
   ACTION: Specify a different SID Name that does not conflict with existing databases on the system.
Prepare for db operation
22% complete
Listener config step
44% complete
Auxiliary instance creation
67% complete
RMAN duplicate
89% complete
Post duplicate database operations
100% complete

Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/cdb2/cdb2.log" for further details.
$

Let's clean up by deleting the "cdb2" instance.

dbca -silent \
     -deleteDatabase \
     -sourceDB cdb2 \
     -sysPassword SysPassword1
[WARNING] [DBT-19202] The Database Configuration Assistant will delete the Oracle instances and datafiles for your database. All information in the database will be destroyed.
Prepare for db operation
32% complete
Connecting to database
35% complete
39% complete
42% complete
45% complete
48% complete
52% complete
65% complete
Updating network configuration files
68% complete
Deleting instance and datafiles
84% complete
100% complete
Database deletion completed.
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/cdb2/cdb20.log" for further details.
$

For more information see:

Hope this helps. Regards Tim...

Back to the Top.