Oracle Application

EBS Database Clone-Renaming Source PDB to Target PDB

Photo by Kadyn Pierce on Unsplash

Cloning a container-based EBS database is similar to the traditional approach where we clone the Database by rman duplicate.

Similar way, we can clone CDB-based EBS databases also. Additional steps will come into the picture when we have to rename the PDB as cloned CDB will have a source PDB name and it can’t be renamed during rman duplicate process, unlike CDB.

For a detailed cloning procedure, refer to Oracle Support Doc ID 2552208.1 and 1383621.1.

In this particular blog, I’ll try to cover the PDB renaming part with and without an encryption wallet.

Source Database:

SQL> select name from v$database;

NAME
--------
prd_cdb

SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED

---------- ------------------------------ ---------- ----------

        2 PDB$SEED READ ONLY NO

        3 prd_pdb READ WRITE NO

Assuming that the CDB clone is completed, the PDB name needs to be changed from prd_pdb to dev_pdb.

Target Database after CDB clone :

SQL> select name from v$database; 

NAME 
-------- 
dev_cdb

SQL> show pdbs

   CON_ID CON_NAME OPEN MODE RESTRICTED

---------- ------------------------------ ---------- ----------

        2 PDB$SEED READ ONLY NO

        3 prd_pdb READ WRITE NO

Do note the PDB name which is still prd_pdb.

Steps to change PDB name with no encryption wallet in place.

$ sqlplus / as sysdba

SQL> alter pluggable database "prd_pdb" close;

SQL> alter pluggable database "prd_pdb" unplug into '<ORACLE_HOME>/dbs/prd_pdb.xml';

SQL> drop pluggable database "prd_pdb";

Now we'll create pluggable database with desired name and the xml file which is having original pdb metadata. 

SQL>create pluggable database "dev_pdb" using '<ORACLE_HOME>/dbs/prd_pdb.xml' NOCOPY SERVICE_NAME_CONVERT=('ebs_prd_pdb','ebs_dev_pdb','prd_pdb_ebs_patch','dev_pdb_ebs_patch');

SQL> alter pluggable database "dev_pdb" open read write;

Save PDB state:

SQL> alter pluggable database all save state instances=all;

SQL> shut immediate;

SQL> startup;

Run the library update script against the Oracle Database.

$ cd <ORACLE_HOME>/appsutil/install/<CONTEXT_NAME>
$ sqlplus / as sysdba @adupdlib.sql <libext>

If you have an encryption wallet, then follow the below steps to change PDB name.

Close the auto-login wallet:

$ sqlplus / as sysdba
SQL> select WRL_PARAMETER from V$ENCRYPTION_WALLET;

WRL_PARAMETER
-------------------------------------------------------------------------------
<wallet_location>

$ cd <wallet_location>

$ mv cwallet.sso cwallet.sso.bkp

$ sqlplus / as sysdba

SQL> administer key management set keystore close;

SQL> administer key management set keystore open identified by <keystore_pwd>;

SQL> select * from v$encryption_wallet;

SQL> alter session set container="prd_pdb";

SQL> administer key management set keystore open identified by <keystore_pwd>;

SQL> ADMINISTER KEY MANAGEMENT EXPORT ENCRYPTION KEYS WITH SECRET "<secret_pwd>" TO '<wallet_location>/exp_tde.exp' IDENTIFIED BY <keystore_pwd>;
 
       > Here, provide a secret password which will be used later while importing the wallet.

SQL> exit;

$ sqlplus / as sysdba

SQL> alter pluggable database "prd_pdb" close;

SQL> alter pluggable database "prd_pdb" unplug into '<ORACLE_HOME>/dbs/prd_pdb.xml';

SQL> exit;

$ sqlplus / as sysdba

SQL> drop pluggable database "prd_pdb";

     > This will not delete the content of the PDB.

SQL> create pluggable database "dev_pdb" using '<ORACLE_HOME>/dbs/prd_pdb.xml' NOCOPY SERVICE_NAME_CONVERT=('ebs_prd_pdb','ebs_dev_pdb','prd_pdb_ebs_patch','dev_pdb_ebs_patch');

Now if you will open the PDB, it will give a warning as we have not imported the wallet yet.

SQL> alter pluggable database "dev_pdb" open read write;
Warning: PDB altered with errors.

We can see the error in pdb_plug_in_violations table also.

SQL> select name, cause, type, status,action,message,time from pdb_plug_in_violations;

dev_pdb Wallet Key Needed ERROR PENDING Import keys from the source. PDB needs to import keys from 15-APR-22 09.45.54.966950 PM

IMPORT encryption keys from the backup taken earlier.

SQL> alter session set container="dev_pdb";
Session altered.

SQL> ADMINISTER KEY MANAGEMENT SET KEYSTORE OPEN IDENTIFIED BY <keystore_pwd>;

keystore altered.

SQL> ADMINISTER KEY MANAGEMENT IMPORT ENCRYPTION KEYS WITH SECRET <secret_pwd> FROM '<wallet_location>/exp_tde.exp' IDENTIFIED BY <keystore_pwd> WITH BACKUP;

keystore altered.

SQL> shut immediate;

Pluggable Database closed.

SQL> startup

Pluggable Database opened.

SQL> show pdbs

   CON_ID CON_NAME OPEN MODE RESTRICTED

---------- ------------------------------ ---------- ----------

        4 dev_pdb READ WRITE NO

Re-enable auto login

$ sqlplus / as sysdba
SQL> administer key management create AUTO_LOGIN keystore from keystore '<wallet_location> identified by <keystore_pwd> ;

Save PDB state:

SQL> alter pluggable database all save state instances=all;

SQL> shut immediate;

SQL> startup;

Run the library update script against the Oracle Database.

$ cd <ORACLE_HOME>/appsutil/install/<CONTEXT_NAME>
$ sqlplus / as sysdba @adupdlib.sql <libext>

SQL> show parameter name

db_name string dev_cdb

SQL> show pdbs

   CON_ID CON_NAME OPEN MODE RESTRICTED

---------- ------------------------------ ---------- ----------

        2 PDB$SEED READ ONLY NO

        4 dev_pdb READ WRITE NO

This completes PDB renaming in EBS Database.

Leave a Reply