Migrate Oracle 12c non-cdb to pdb in Oracle 19c
Migrate Oracle 12c non-cdb to pdb in Oracle 19c
It's been a long time from my last post, but again it's time to show you something interesting. In this article, I will show how to migrate a Non-Container Database to a Pluggable Database.
I will use Oracle 12c noncdb which will migrate to Oracle 19c PDB. For that purpose, I had to install Oracle 19c software with an empty container.
The installation of Oracle 19c doesn't have any specifics. So we can proceed with the main steps.
At the first place, we have to describe the noncdb database. For that purpose, we will use DBMS_PDB package which allows us to generate an XML file from a noncdb.
Now connecting to our Oracle 12c database, shutting it down and starting it in read-only mode:
[oracle@polya-rac1 ]$ env |grep ORA [oracle@polya-rac1 ]$sqlplus / as sysdba |
Now describe the DB using DBMS_PDB.DESCRIBE procedure. It is describing the database the same way when you are unplugging a PDB database.
BEGIN PL/SQL procedure successfully completed. |
We can see that the xml file is created and check its content:
[oracle@polya-rac1 oracle]$ ls -lart NonCDB.xml -rw-r--r--. 1 oracle oinstall 8987 Jun 28 13:02 NonCDB.xml |
------ Click to see the content of the XML file ------
Now we can proceed with creating the PDB, plug in in Oracle 19, upgrade it and convert from NonCDB to PDB. So ... let's see
[oracle@polya-rac1 ]$ env |grep ORA [oracle@polya-rac1 ]$sqlplus / as sysdba SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED * Chek the compatibility where the otput should be YES. If NO, you can check for violations (pdb_plug_in_violations). Have in mind that most of the cases that I've experienced with the compatibility 'NO' were related to mismatch with database components or different patch levels. * SET SERVEROUTPUT ON create pluggable database ORCL19PDB using '/opt/oracle/NonCDB.xml' |
After PDB is created, we can check for any violations with the below select statement:
select message from pdb_plug_in_violations where type like '%ERR%' and status <> 'RESOLVED';
CON_ID NAME TYPE MESSAGE STATUS 1 ORCL19PDB ERROR PDB's version does not match CDB's version PENDING
|
Now, as we expected to have is to execute the script noncdb_to_pdb.sql which will clean up the new PDB from things that should no be presented there.
ALTER SESSION SET CONTAINER=ORCL19PDB; ALTER SESSION SET CONTAINER=ORCL19PDB; |
Now we can select again for violation and check what are the messages there:
select message from pdb_plug_in_violations where type like '%ERR%' and status <> 'RESOLVED';
|
It is time to start with the upgrade. We can do the upgrade in two ways as below. I've been tested both, but in this article will attach the log from the dbupgrade:
dbupgrade -c 'ORCL19PDB' -l /home/oracle/logs -n 2 cd $ORACLE_HOME/rdbms/admin ( this is important step ) |
------ Here you can see the output from the upgrade in the attached file ------
dbupgrade.txt
Now it's time to login in the database and to check for any violations left:
SQL> select message from pdb_plug_in_violations where type like '%ERR%' and status <> 'RESOLVED'; no rows selected |
This is the result that we were expecting in the end. Create Oracle 19c pluggable database without any violations after converting it from a non container database and upgrade from 12.2 version.
Now you can test in order to exchange experience. :)
Feel free to comment!