DBA.BG BlogDBA CommunityKrasimir KovachkiRadoslav StanoevPolya MilkovaAbout this siteContactLog in
  • DBA Community
  • Krasimir Kovachki
  • Radoslav Stanoev
  • Polya Milkova
  • About this site
  • Contact

Polya Milkova

  • Front Page
  • Categories
  • Archives
  • Latest comments
  • Security Issues after Patching Oracle BI Publisher 11.1.1.9.0 »
Migrate Oracle 12c non-cdb to pdb in Oracle 19c

Migrate Oracle 12c non-cdb to pdb in Oracle 19c

posted on 20 Sep 2019 by polya in Oracle migration

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_SID=ORCL12
ORACLE_HOME=/opt/oracle/product/12.2.0/dbhome_1

[oracle@polya-rac1 ]$sqlplus / as sysdba
shutdown immediate;
startup open read only;

 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
DBMS_PDB.DESCRIBE(pdb_descr_file => '/opt/oracle/NonCDB.xml');
END;
/

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 ------

noncdb.xml

 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_UNQNAME=ORCL19
ORACLE_SID=ORCL19
ORACLE_BASE=/opt/app/oracle
ORA_INVENTORY=/opt/app/oraInventory
ORACLE_HOME=/opt/app/oracle/product/19.0.0/dbhome_1

[oracle@polya-rac1 ]$sqlplus / as sysdba

SQL> show pdbs

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

* 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
DECLARE
compatible CONSTANT VARCHAR2(3) :=
CASE DBMS_PDB.CHECK_PLUG_COMPATIBILITY(
pdb_descr_file => '/opt/oracle/NonCDB.xml')
WHEN TRUE THEN 'YES'
ELSE 'NO'
END;
BEGIN
DBMS_OUTPUT.PUT_LINE(compatible);
END;
/
--- Creating the PDB 19 ---

create pluggable database ORCL19PDB using '/opt/oracle/NonCDB.xml'
COPY
FILE_NAME_CONVERT=('/opt/oracle/oradata/ORCL12','/opt/oracle/oradata/ORCL19CDB/ORCL19PDB');

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     WARNING    PDB plugged in is a non-CDB, requires              PENDING
                                                                 noncdb_to_pdb.sql be run.

      1         ORCL19PDB     ERROR        PDB's version does not match CDB's version      PENDING
                                                                PDB'sversion 12.2.0.1.0. CDB's version 19.0.0.0.0.

 

 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;

@$ORACLE_HOME/rdbms/admin/noncdb_to_pdb.sql

 ALTER SESSION SET CONTAINER=ORCL19PDB;
ALTER PLUGGABLE DATABASE ORACL19PDB OPEN;

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';


CON_ID   NAME                 TYPE            MESSAGE                                                              STATUS
------         --------                  ---------          -------------------------------------------------------------        -------------
      1       ORCL19PDB        ERROR         PDB's version does not match CDB's version      PENDING
                                                                  PDB'sversion 12.2.0.1.0. CDB's version 19.0.0.0.0.

 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
--- or ---

cd $ORACLE_HOME/rdbms/admin ( this is important step )
$ORACLE_HOME/perl/bin/perl catctl.pl -c "ORCL19PDB" -l /tmp catupgrd.sql 

------ 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! 

Tags: #convert #migrate #noncdb #oracle #oracle12c #oracle19c #pdb

No feedback yet


Form is loading...

This collection ©2021 by Polya Milkova • Contact • Help • Multiblog engine • cheap web hosting

Social CMS

Cookies are required to enable core site functionality.