Step-by-Step Guide: Converting a Non-CDB to PDB with an Existing CDB

 

In this comprehensive guide, we'll walk you through the process of converting a Non-CDB (Non-Container Database) to a Pluggable Database (PDB) using an existing CDB (Container Database). Follow these clear and concise steps for a seamless transformation:

Assumption: Before converting a Non-CDB oracle instance into CDB , it is assumed an oracle CDB instance is already running.

 

Step 1: Cleanly Shutdown the Non-CDB Database(orcl)

  • Execute the following commands to gracefully shut down the Non-CDB Database named "orcl":

Invoke environment for orcl

[oracle@ocisoumya ~]$ . oraenv

ORACLE_SID = [orcl] ? orcl

The Oracle base remains unchanged with value /u01/app

 

[oracle@ocisoumya ~]$ sqlplus / as sysdba

 

SQL*Plus: Release 19.0.0.0.0 - Production on Mon Jan 15 15:45:10 2024

Version 19.21.0.0.0

 

Copyright (c) 1982, 2022, Oracle.  All rights reserved.

 

 

Connected to:

Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production

Version 19.21.0.0.0

 

SQL> show pdbs

SQL> shu immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

 

Step 2: Open the Database in Read-Only Mode

  • Once the database is cleanly shutdown, open it in read-only mode

SQL> startup open read only

ORACLE instance started.

 

Total System Global Area 4949276544 bytes

Fixed Size                  8935296 bytes

Variable Size             973078528 bytes

Database Buffers         3959422976 bytes

Redo Buffers                7839744 bytes

Database mounted.

Database opened.

 

 

Step 3: Describe the Database and Generate the XML File

  • Generate an XML file describing the database:

SQL> BEGIN
DBMS_PDB.DESCRIBE(pdb_descr_file => '/u01/orcl.xml');
END;
/

 

PL/SQL procedure successfully completed.

 

Step 4: Shutdown the Database

  • Shutdown the database again:

SQL> shu immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

 

Step 5: Check Compatibility and Resolve Issues

  • Verify compatibility with the target CDB and address any issues:

Invoke CDB environment and login to sqlplus

[oracle@ocisoumya ~]$ . oraenv

ORACLE_SID = [orcl] ? orclcdb

The Oracle base remains unchanged with value /u01/app

 

SQL> SET SERVEROUTPUT ON;

DECLARE

  compatible CONSTANT VARCHAR2(3) := CASE DBMS_PDB.CHECK_PLUG_COMPATIBILITY(pdb_descr_file => '/u01/orcl.xml')

    WHEN TRUE THEN 'YES'

    ELSE 'NO'

  END;

BEGIN

  DBMS_OUTPUT.PUT_LINE(compatible);

END;

/

 

  • Check the PDB_PLUG_IN_VIOLATIONS view from the CDB for any errors.

SQL> select NAME,ERROR_NUMBER,type,MESSAGE,STATUS from PDB_PLUG_IN_VIOLATIONS;

 

NAME            ERROR_NUMBER TYPE      MESSAGE                                                      STATUS

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

PDB$SEED                   0 ERROR     '19.21.0.0.0 Release_Update 2309301519' is installed in the  RESOLVED

                                       CDB but no release updates are installed in the PDB

 

ORCL                       0 WARNING   PDB plugged in is a non-CDB, requires noncdb_to_pdb.sql be r PENDING

                                       un.

 

ORCL                       0 WARNING   Undo mode mismatch: PDB using LOCAL undo.  CDB using SHARED  PENDING

                                       undo.

 

 

 

 

Step 6: Connect to the Target CDB

  • Connect to the CDB where the database will be plugged in:

[oracle@ocisoumya ~]$ . oraenv

ORACLE_SID = [orcl] ? orclcdb

The Oracle base remains unchanged with value /u01/app

 

Step 7: Create a Pluggable Database

  • Execute the following SQL command to create a Pluggable Database:

SQL> CREATE PLUGGABLE DATABASE ORCLPDB USING '/u01/orcl.xml'

COPY FILE_NAME_CONVERT = ('/u01/app/oradata/ORCL/', '/u01/app/oradata/ORCLCDB/ORCLPDB/'); 

 

Pluggable database created.

 

Step 8: Run the noncdb_to_pdb.sql Script

·       Switch to the PDB container and run the script for the conversion:



sql> ALTER SESSION SET CONTAINER=ORCLPDB;

sql> @$ORACLE_HOME/rdbms/admin/noncdb_to_pdb.sql

 

Step 9: Startup the PDB and Verify

·       Start up the PDB and confirm its open mode:

SQL> ALTER PLUGGABLE DATABASE OPEN;

Pluggable database altered.

 

SQL> SELECT name, open_mode FROM v$pdbs;

 

NAME            OPEN_MODE

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

ORCLPDB         READ WRITE

 

 

Step by step guide to apply CPU patch on Oracle 19c database home

 


In this post I will be showing step by step guide to apply CPU patch on oracle database 19c. I will be applying CPU patch for December 2023(Patch no :- 35643107)




Activity Steps:

1. Check Opatch Tool Version:

  • Verify the current version of the Opatch tool. As per read me of Patch 35643107 , minimum required Opatch version should be 12.2.0.1.37 or later

 

2.Download Opatch Tool (if needed):

  • Upgrade the Opatch utility if the current version is outdated.  Download Opatch latest version or as mentioned in patch readme. In this case I will be installing 12.2.0.1.40 (Patch no 6880880)


3. Install Opatch Tool :

Take backup of existing Opatch directory before installing Opatch

[oracle@ocisoumya ~]$ cd $ORACLE_HOME

[oracle@ocisoumya dbhome_1]$ mv OPatch/ OPatch_bkp

[oracle@ocisoumya u01]$ cp -r p6880880_190000_Linux-x86-64.zip $ORACLE_HOME

[oracle@ocisoumya dbhome_1]$ unzip p6880880_190000_Linux-x86-64.zip

[oracle@ocisoumya dbhome_1]$ cd OPatch

[oracle@ocisoumya OPatch]$ ./opatch version

OPatch Version: 12.2.0.1.40

 

OPatch succeeded.

 

 

3. Backup ORACLE_HOME and orainventory:

  • Take a comprehensive backup of the ORACLE_HOME directory and orainventory.

[oracle@ocisoumya 19.3.0]$ cd /u01/app/oracle/19.3.0

[oracle@ocisoumya 19.3.0]$ zip -r oracle_19c_home.zip /u01/app/oracle/19.3.0/dbhome_1

[oracle@ocisoumya 35643107]$ cd /u01/app/

[oracle@ocisoumya app]$ ls

admin  audit  cfgtoollogs  checkpoints  diag  oracle  oradata  oraInventory

[oracle@ocisoumya app]$ cp -r oraInventory/ oraInventory_bkp

 

 

4. Shutdown Database and Listener:

  • Safely shut down the database and listener associated with the ORACLE_HOME to be patched.

[oracle@ocisoumya ~]$ sqlplus / as sysdba

 

SQL*Plus: Release 19.0.0.0.0 - Production on Sun Jan 14 08:02:02 2024

Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

Connected to:

Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production

Version 19.3.0.0.0

 

SQL> shu immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> exit

 

[oracle@ocisoumya ~]$ lsnrctl stop

 

LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 14-JAN-2024 08:02:40

 

Copyright (c) 1991, 2019, Oracle.  All rights reserved.

 

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))

The command completed successfully

 

5. Apply PSU Patch:

  • Apply the CPU patch 35643107  to the specified ORACLE_HOME.

Navigate to patch directory and check for conflict using following

[oracle@ocisoumya ~]$ export PATH=/u01/app/oracle/19.3.0/dbhome_1/OPatch:$PATH

[oracle@ocisoumya ~]$ cd /u01/35643107/

 

[oracle@ocisoumya 35643107]$ opatch prereq CheckConflictAgainstOHWithDetail -ph ./

Oracle Interim Patch Installer version 12.2.0.1.40

Copyright (c) 2024, Oracle Corporation.  All rights reserved.

 

PREREQ session

 

Oracle Home       : /u01/app/oracle/19.3.0/dbhome_1

Central Inventory : /u01/app/oraInventory

   from           : /u01/app/oracle/19.3.0/dbhome_1/oraInst.loc

OPatch version    : 12.2.0.1.40

OUI version       : 12.2.0.7.0

Log file location : /u01/app/oracle/19.3.0/dbhome_1/cfgtoollogs/opatch/opatch2024-01-14_08-11-35AM_1.log

 

Invoking prereq "checkconflictagainstohwithdetail"

 

Prereq "checkConflictAgainstOHWithDetail" passed.

 

OPatch succeeded.

 

Install Patch

[oracle@ocisoumya 35643107]$ opatch apply

Oracle Interim Patch Installer version 12.2.0.1.40

Copyright (c) 2024, Oracle Corporation.  All rights reserved.

 

 

Oracle Home       : /u01/app/oracle/19.3.0/dbhome_1

Central Inventory : /u01/app/oraInventory

   from           : /u01/app/oracle/19.3.0/dbhome_1/oraInst.loc

OPatch version    : 12.2.0.1.40

OUI version       : 12.2.0.7.0

Log file location : /u01/app/oracle/19.3.0/dbhome_1/cfgtoollogs/opatch/opatch2024-01-14_08-13-23AM_1.log

 

Verifying environment and performing prerequisite checks...

OPatch continues with these patches:   35643107

 

Do you want to proceed? [y|n]

y

User Responded with: Y

All checks passed.

 

Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.

(Oracle Home = '/u01/app/oracle/19.3.0/dbhome_1')

 

 

Is the local system ready for patching? [y|n]

y

User Responded with: Y

Backing up files...

Applying interim patch '35643107' to OH '/u01/app/oracle/19.3.0/dbhome_1'

ApplySession: Optional component(s) [ oracle.network.gsm, 19.0.0.0.0 ] , [ oracle.pg4mq, 19.0.0.0.0 ] , [ oracle.rdbms.ic, 19.0.0.0.0 ] , [ oracle.rdbms.tg4db2, 19.0.0.0.0 ] , [ oracle.tfa, 19.0.0.0.0 ] , [ oracle.rdbms.tg4msql, 19.0.0.0.0 ] , [ oracle.ons.cclient, 19.0.0.0.0 ] , [ oracle.rdbms.tg4sybs, 19.0.0.0.0 ] , [ oracle.options.olap.api, 19.0.0.0.0 ] , [ oracle.network.cman, 19.0.0.0.0 ] , [ oracle.sdo.companion, 19.0.0.0.0 ] , [ oracle.xdk.companion, 19.0.0.0.0 ] , [ oracle.rdbms.tg4tera, 19.0.0.0.0 ] , [ oracle.net.cman, 19.0.0.0.0 ] , [ oracle.ons.eons.bwcompat, 19.0.0.0.0 ] , [ oracle.oid.client, 19.0.0.0.0 ] , [ oracle.rdbms.tg4ifmx, 19.0.0.0.0 ] , [ oracle.options.olap, 19.0.0.0.0 ] , [ oracle.jdk, 1.8.0.191.0 ]  not present in the Oracle Home or a higher version is found.

 

Patching component oracle.rdbms.util, 19.0.0.0.0...

 

Patching component oracle.rdbms.rsf, 19.0.0.0.0...

 

Patching component oracle.rdbms, 19.0.0.0.0...

 

 

Patching component oracle.assistants.acf, 19.0.0.0.0...

 

Patching component oracle.assistants.deconfig, 19.0.0.0.0...

 

Patching component oracle.assistants.server, 19.0.0.0.0...

 

Patching component oracle.blaslapack, 19.0.0.0.0...

 

Patching component oracle.buildtools.rsf, 19.0.0.0.0...

 

Patching component oracle.ctx, 19.0.0.0.0...

 

Patching component oracle.dbdev, 19.0.0.0.0...

 

Patching component oracle.dbjava.ic, 19.0.0.0.0...

 

Patching component oracle.dbjava.jdbc, 19.0.0.0.0...

 

Patching component oracle.dbjava.ucp, 19.0.0.0.0...

 

Patching component oracle.duma, 19.0.0.0.0...

 

Patching component oracle.javavm.client, 19.0.0.0.0...

 

Patching component oracle.ldap.owm, 19.0.0.0.0...

 

Patching component oracle.ldap.rsf, 19.0.0.0.0...

 

Patching component oracle.ldap.security.osdt, 19.0.0.0.0...

 

Patching component oracle.marvel, 19.0.0.0.0...

 

Patching component oracle.network.rsf, 19.0.0.0.0...

 

Patching component oracle.odbc.ic, 19.0.0.0.0...

 

Patching component oracle.ons, 19.0.0.0.0...

 

Patching component oracle.ons.ic, 19.0.0.0.0...

 

Patching component oracle.oracore.rsf, 19.0.0.0.0...

 

Patching component oracle.perlint, 5.28.1.0.0...

 

Patching component oracle.precomp.common.core, 19.0.0.0.0...

 

Patching component oracle.precomp.rsf, 19.0.0.0.0...

 

Patching component oracle.rdbms.crs, 19.0.0.0.0...

 

Patching component oracle.rdbms.dbscripts, 19.0.0.0.0...

 

Patching component oracle.rdbms.deconfig, 19.0.0.0.0...

 

Patching component oracle.rdbms.oci, 19.0.0.0.0...

 

Patching component oracle.rdbms.rsf.ic, 19.0.0.0.0...

 

Patching component oracle.rdbms.scheduler, 19.0.0.0.0...

 

Patching component oracle.rhp.db, 19.0.0.0.0...

 

Patching component oracle.sdo, 19.0.0.0.0...

 

Patching component oracle.sdo.locator.jrf, 19.0.0.0.0...

 

Patching component oracle.sqlplus, 19.0.0.0.0...

 

Patching component oracle.sqlplus.ic, 19.0.0.0.0...

 

Patching component oracle.wwg.plsql, 19.0.0.0.0...

 

Patching component oracle.ldap.rsf.ic, 19.0.0.0.0...

 

Patching component oracle.ldap.client, 19.0.0.0.0...

 

Patching component oracle.rdbms.dv, 19.0.0.0.0...

 

Patching component oracle.rdbms.install.common, 19.0.0.0.0...

 

Patching component oracle.rdbms.hsodbc, 19.0.0.0.0...

 

Patching component oracle.nlsrtl.rsf, 19.0.0.0.0...

 

Patching component oracle.xdk.rsf, 19.0.0.0.0...

 

Patching component oracle.odbc, 19.0.0.0.0...

 

Patching component oracle.xdk.parser.java, 19.0.0.0.0...

 

Patching component oracle.ctx.atg, 19.0.0.0.0...

 

Patching component oracle.network.listener, 19.0.0.0.0...

 

Patching component oracle.ctx.rsf, 19.0.0.0.0...

 

Patching component oracle.rdbms.hs_common, 19.0.0.0.0...

 

Patching component oracle.dbtoolslistener, 19.0.0.0.0...

 

Patching component oracle.xdk, 19.0.0.0.0...

 

Patching component oracle.rdbms.rman, 19.0.0.0.0...

 

Patching component oracle.rdbms.drdaas, 19.0.0.0.0...

 

Patching component oracle.install.deinstalltool, 19.0.0.0.0...

 

Patching component oracle.ovm, 19.0.0.0.0...

 

Patching component oracle.rdbms.install.plugins, 19.0.0.0.0...

 

Patching component oracle.mgw.common, 19.0.0.0.0...

 

Patching component oracle.xdk.xquery, 19.0.0.0.0...

 

Patching component oracle.network.client, 19.0.0.0.0...

 

Patching component oracle.ldap.ssl, 19.0.0.0.0...

 

Patching component oracle.oraolap.api, 19.0.0.0.0...

 

Patching component oracle.javavm.server, 19.0.0.0.0...

 

Patching component oracle.sdo.locator, 19.0.0.0.0...

 

Patching component oracle.oraolap, 19.0.0.0.0...

 

Patching component oracle.oraolap.dbscripts, 19.0.0.0.0...

 

Patching component oracle.rdbms.lbac, 19.0.0.0.0...

 

Patching component oracle.precomp.common, 19.0.0.0.0...

 

Patching component oracle.precomp.lang, 19.0.0.0.0...

 

Patching component oracle.jdk, 1.8.0.201.0...

Patch 35643107 successfully applied.

Sub-set patch [29517242] has become inactive due to the application of a super-set patch [35643107].

Please refer to Doc ID 2161861.1 for any possible further required actions.

Log file location: /u01/app/oracle/19.3.0/dbhome_1/cfgtoollogs/opatch/opatch2024-01-14_08-13-23AM_1.log

 

OPatch succeeded.

 

 

6. Validate Patch in Inventory:

  • Confirm the successful application of the patch in the inventory.

[oracle@ocisoumya 35643107]$ opatch lsinventory | grep 35643107

Patch  35643107     : applied on Sun Jan 14 08:16:16 GMT 2024

Patch description:  "Database Release Update : 19.21.0.0.231017 (35643107)"

 

7. Startup Database and Listener:

  • Start up the database and listener services associated with the patched Oracle home.

[oracle@ocisoumya ~]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Sun Jan 14 08:23:17 2024

Version 19.21.0.0.0

Copyright (c) 1982, 2022, Oracle.  All rights reserved.

 

Connected to an idle instance.

 

SQL> startup

ORACLE instance started.

 

Total System Global Area 4949276544 bytes

Fixed Size                  8935296 bytes

Variable Size             889192448 bytes

Database Buffers         4043309056 bytes

Redo Buffers                7839744 bytes

Database mounted.

Database opened.

SQL> exit

 

[oracle@ocisoumya ~]$ lsnrctl start

 

LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 14-JAN-2024 08:25:10

 

Copyright (c) 1991, 2023, Oracle.  All rights reserved.

 

Starting /u01/app/oracle/19.3.0/dbhome_1/bin/tnslsnr: please wait...

 

TNSLSNR for Linux: Version 19.0.0.0.0 - Production

Log messages written to /u01/app/diag/tnslsnr/ocisoumya/listener/alert/log.xml

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ocisoumya.example.com)(PORT=1521)))

 

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))

STATUS of the LISTENER

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

Alias                     LISTENER

Version                   TNSLSNR for Linux: Version 19.0.0.0.0 - Production

Start Date                14-JAN-2024 08:25:10

Uptime                    0 days 0 hr. 0 min. 0 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Log File         /u01/app/diag/tnslsnr/ocisoumya/listener/alert/log.xml

Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ocisoumya.example.com)(PORT=1521)))

The listener supports no services

The command completed successfully

 

 

8. Execute Post-installation Steps (datapatch):

  • Run post-installation steps, including the execution of datapatch.

[oracle@ocisoumya ~]$ datapatch -verbose

SQL Patching tool version 19.21.0.0.0 Production on Sun Jan 14 08:26:08 2024

Copyright (c) 2012, 2023, Oracle.  All rights reserved.

 

Log file for this invocation: /u01/app/cfgtoollogs/sqlpatch/sqlpatch_25436_2024_01_14_08_26_08/sqlpatch_invocation.log

 

Connecting to database...OK

Gathering database info...done

Bootstrapping registry and package to current versions...done

Determining current state...done

 

Current state of interim SQL patches:

  No interim patches found

 

Current state of release update SQL patches:

  Binary registry:

    19.21.0.0.0 Release_Update 230930151951: Installed

  SQL registry:

    Applied 19.3.0.0.0 Release_Update 190410122720 successfully on 04-OCT-23 04.48.01.858067 AM

 

Adding patches to installation queue and performing prereq checks...done

Installation queue:

  No interim patches need to be rolled back

  Patch 35643107 (Database Release Update : 19.21.0.0.231017 (35643107)):

    Apply from 19.3.0.0.0 Release_Update 190410122720 to 19.21.0.0.0 Release_Update 230930151951

  No interim patches need to be applied

 

Installing patches...

Patch installation complete.  Total patches installed: 1

 

Validating logfiles...done

Patch 35643107 apply: SUCCESS

  logfile: /u01/app/cfgtoollogs/sqlpatch/35643107/25405995/35643107_apply_ORCL_2024Jan14_08_26_38.log (no errors)

 

Automatic recompilation incomplete; run utlrp.sql to revalidate.

SQL Patching tool complete on Sun Jan 14 08:31:34 2024

 

9. Verify Patch Status from dba_registry_sqlpatch:

  • Check the status of the applied patch in the dba_registry_sqlpatch view.

SQL> COLUMN action_time FORMAT A20

SQL> COLUMN action FORMAT A10

SQL> COLUMN status FORMAT A10

SQL> COLUMN description FORMAT A60

SQL> SELECT TO_CHAR(action_time, 'DD-MON-YYYY HH24:MI:SS') AS action_time,action,status,description,patch_id FROM sys.dba_registry_sqlpatch ORDER by action_time;

 ACTION_TIME          ACTION     STATUS     DESCRIPTION                                                    PATCH_ID

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

04-OCT-2023 04:48:01 APPLY      SUCCESS    Database Release Update : 19.3.0.0.190416 (29517242)           29517242

14-JAN-2024 08:31:33 APPLY      SUCCESS    Database Release Update : 19.21.0.0.231017 (35643107)          35643107





 

10. Run utlrp.sql to validate any invalid objects :

SQL> @?/rdbms/admin/utlrp.sql

 

 

This concludes the PSU patching activity on oracle home.