Convert your 19c non-CDB to PDB in Oracle Cloud

Introduction

Oracle Multitenant has been around since Oracle Database version 12c was released in 2013. With that, the previous architecture, since then called non-CDB was deprecated. Starting with version 21c, non-CDB architecture is not supported and available anymore.

In the Oracle Cloud, all databases created via Cloud Tooling use the Multitenant Architecture. On VM DB Systems, it is also the only possible and supported architecture, actually. As Oracle Cloud provides an automated upgrade to Oracle Database version 19c, you’ll end up with a 19c non-CDB if you are upgrading from Database version 11.2.0.4, which is also supported in this case.

Now, a new feature has been released to convert the non-CDB to PDB in a new CDB via Cloud Tooling. In this blog post, we will take a look at the conversion process.

The Environment

  • VM DB System version 11.2.0.4 which has been upgraded to 19c via Cloud Tooling.

Metadata in the UI

The database details page shows a new property regarding the database architecture.

The OCI CLI get database command response contains the new JSON key “isCdb”.

[opc@automation ~]$ oci raw-request --http-method GET --target-uri https://database.eu-frankfurt-1.oraclecloud.com/20160918/databases/ocid1.database.oc1.eu-frankfurt-1...
...
"isCdb": false
...

Convert to PDB – Precheck

From the database details page, click on “More Actions”, then on “Convert to PDB”.

Choose a name for the new CDB, enter the required SYS and TDE passwords, and finally click on “Run Precheck”.

The database status changes to “Converting”.

After a while, the non-CDB will be replaced by the CDB in Provisioning state in the Cloud Console.

However, if in this stage something went wrong, e.g. the wrong TDE wallet password was provided, the conversion will fail and the CDB will switch into the Terminated state. The physical non-CDB database on the server will be fully intact. The correct status in the Cloud Console, the non-CDB in Available state, will be shown again after sync, which might take few hours.

After the conversion is completed, check the Work Request on the database details page.

For detailed information during the conversion, check the process on the database host. As user root:

[root@host115 ~]# dbcli list-jobs
...
a57afe37-1022-400c-b15f-ff8b3eecf3f0     Non-cdb database to pdb conversion precheck                                 Tuesday, October 05, 2021, 09:03:27 UTC Success

[root@host115 ~]# dbcli describe-job -i a57afe37-1022-400c-b15f-ff8b3eecf3f0
Task Name                                                      Start Time                          End Time                            Status
-------------------------------------------------------------- ----------------------------------- ----------------------------------- ----------
Validating non-cdb tde password                                October 5, 2021 9:03:29 AM UTC      October 5, 2021 9:03:33 AM UTC      Success
Validating space in DATA disk group                            October 5, 2021 9:03:34 AM UTC      October 5, 2021 9:03:35 AM UTC      Success
Validating space in default TEMP tablespace                    October 5, 2021 9:03:35 AM UTC      October 5, 2021 9:03:40 AM UTC      Success

Convert to PDB

From the database details page, click on “More Actions”, then on “Convert to PDB”.

Again, choose a name for the new CDB, enter the required SYS and TDE passwords, and finally click on “Convert to PDB” this time.

Your database will be shut down and downtime begins. Check the database alert log. As user oracle:

[oracle@host115 ~]$ view /u01/app/oracle/diag/rdbms/db115_fra1xj/DB115/trace/alert_DB115.log
...
2021-10-05T09:57:02.685886+00:00
Instance shutdown complete (OS id: 64526)

Check the process details on the database host for information about all steps being executed. As user root:

[root@host115 ~]# dbcli list-jobs
...
656186b4-76cd-4c21-be65-41b04f25dda9     Non-cdb database to pdb conversion precheck                                 Tuesday, October 05, 2021, 09:53:07 UTC Success
eea283ad-7050-4c98-9861-9e6d351c27fc     Non-cdb database to pdb conversion                                          Tuesday, October 05, 2021, 09:54:32 UTC Running

[root@host115 ~]# dbcli describe-job -i eea283ad-7050-4c98-9861-9e6d351c27fc
Task Name                                                      Start Time                          End Time                            Status
-------------------------------------------------------------- ----------------------------------- ----------------------------------- ----------
Validating non-cdb tde password                                October 5, 2021 9:54:38 AM UTC      October 5, 2021 9:54:43 AM UTC      Success
Validating space in DATA disk group                            October 5, 2021 9:54:43 AM UTC      October 5, 2021 9:54:44 AM UTC      Success
Validating space in default TEMP tablespace                    October 5, 2021 9:54:44 AM UTC      October 5, 2021 9:54:51 AM UTC      Success
Export TDE keys from Non-CDB                                   October 5, 2021 9:54:51 AM UTC      October 5, 2021 9:54:54 AM UTC      Success
Generate pdb xml file                                          October 5, 2021 9:55:55 AM UTC      October 5, 2021 9:56:03 AM UTC      Success
CDB Creation                                                   October 5, 2021 9:57:09 AM UTC      October 5, 2021 9:57:09 AM UTC      Running

Actually, at this stage, while CDB creation, the non-CDB does not necessarily need to be shut down. On the other hand, we need to make sure in case something went wrong during the conversion process, we can switch back to the previous state without data loss.

In Exadata Cloud Service you will be able to create the new CDB beforehand yourself, or use an existing one, before initiating the conversion process, which will reduce the downtime needed.

Check the tasks again:

[root@host115 ~]# dbcli describe-job -i eea283ad-7050-4c98-9861-9e6d351c27fc
...
CDB Creation                                                   October 5, 2021 9:57:09 AM UTC      October 5, 2021 10:29:22 AM UTC     Success
Verify Compatibility of PDB:DB115 in CDB: CDB01_fra15q         October 5, 2021 10:29:35 AM UTC     October 5, 2021 10:29:40 AM UTC     Success
Import TDE keys to CDB                                         October 5, 2021 10:29:40 AM UTC     October 5, 2021 10:29:43 AM UTC     Success
Convert non-cdb database to pdb                                October 5, 2021 10:29:43 AM UTC     October 5, 2021 10:30:49 AM UTC     Success
Running noncdb_to_pdb.sql                                      October 5, 2021 10:30:49 AM UTC     October 5, 2021 10:30:49 AM UTC     Running

At this stage, the new CDB is already running, and the PDB (the previous non-CDB) is open in RESTRICTED mode:

SQL> show pdbs

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

Wait until all steps are executed successfully. As user root:

[root@host115 ~]# dbcli describe-job -i eea283ad-7050-4c98-9861-9e6d351c27fc
...
Running noncdb_to_pdb.sql                                      October 5, 2021 10:30:49 AM UTC     October 5, 2021 10:49:55 AM UTC     Success
Import TDE keys to PDB                                         October 5, 2021 10:50:00 AM UTC     October 5, 2021 10:50:14 AM UTC     Success
set MasterKey For Pdb: DB115                                   October 5, 2021 10:51:08 AM UTC     October 5, 2021 10:51:11 AM UTC     Success
Database Deletion                                              October 5, 2021 10:51:17 AM UTC     October 5, 2021 10:51:21 AM UTC     Success

The PDB is open in READ WRITE mode now:

SQL> show pdbs

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

It might take few hours until the PDB (the previous non-CDB) shows up in the Cloud Console:

During this time, your database is fully accessible and you are able to create further PDBs.

For all updates so far, check the Update History.

Finally, your database metadata show “Container Database” in the Cloud Console

OCI CLI also responses with “isCdb”: true.

[opc@automation ~]$ oci raw-request --http-method GET --target-uri https://database.eu-frankfurt-1.oraclecloud.com/20160918/databases/ocid1.database.oc1.eu-frankfurt-1.antheljsgxomteaaqvdfr4h4r6wyjy3gm7gdq6c36zt43xujoaxiatlvj42q | grep isCdb
    "isCdb": true,

Data Guard Environments

Converting a non-CDB to PDB is not available in Data Guard environments. When you try it, you’ll get the following message:

Convert to pluggable database operation is not supported currently for Data Guard associated database.

You need to remove the standby database first, convert it to PDB, and create a standby database again.

Conclusion

Oracle Multitenant is the only database architecture supported in 21c and later. It is also the recommended architecture for almost a decade now. After migrating from 11.2.0.4 to 19c via Cloud Tooling, now you have the option to convert your 19c non-CDB to a PDB in a new CDB using Clout Tooling by the click of the button, which I only can encourage you to do.

The following steps will automatically be executed in the background:

The conversion process takes around an hour.

As VM DB Systems supports only one database at a time, creating the CDB is part of the conversion process, which takes a significant amount of time. On Exadata Cloud Service, you will be able to provision a new CDB or use an existing one before starting the conversion process, which will reduce the downtime needed.

Further Reading

Would you like to get notified when the next post is published?