Oracle convert Non-Container database to Pluggable database

Oracle convert Non-Container database to Pluggable database


From Oracle 12C database onward multitenancy is a new concept introduced. And it become DBA cores task to convert Non-Container database to Pluggable DB.
In Todays blog , We will see how to convert Non-Container database to Pluggable database on the same server. 

1) Create PDB describe file for Non_Container database. 
Set environment to Non_Container database.
sql>sqlplus / as sysdba
sql>startup mount exclusive
sql>alter database open read only;
sql>exec dbms_pdb.describe(pdb_descr_file=>'/tmp/noncdb.xml');
sql>shutdown immediate

2) Check Plugging Compatibility in Container database.
Set environment for the Container database
sql>sqlplus / as sysdba
sql>startup
sql>SET SERVEROUTPUT ON;
sql>DECLARE
Compatible CONSTANT VARCHAR2(3) :=CASE  DBMS_PDB.CHECK_PLUG_COMPATIBILITY
(pdb_descr_file => '/tmp/noncdb12c_manifest_file.xml')
WHEN TRUE THEN 'YES'
ELSE 'NO'
END;
BEGIN
   DBMS_OUTPUT.PUT_LINE(compatible);
END;

/

Run the following code at the SQL prompt:
sql>SELECT name, cause, type, message, status FROM PDB_PLUG_IN_VIOLATIONS  WHERE name='noncdb12c';

NOTE: Resolve any error if reported by other command before proceeding.

3) Create Pluggable database using describe file from Step 1.
sql>create pluggable database exnoncdb using '/tmp/noncdb.xml'
copy
file_name_convert=('/u01/app/oracle/noncdb','/u01/app/oracle/exnoncdb') ;

NOTE: Below are the three options available with above command.
COPY: The datafiles of the noncdb remain intact, and the noncdb is copied to create a PDB at the new location and keep the original datafiles intact at the original location. This means that a noncdb database is still operational after the creation of the PDB.
MOVE: The datafiles of the noncdb are moved to a new location to create a PDB. In this case, the noncdb database is not available after the PDB is created.
NOCOPY: The datafiles of the noncdb are used to create a PDB2, and it uses the same location as the noncdb. In this case, the noncdb database is not available after the PDB is created.

NOTE2: If Non-Container database is running on remote server. Create DB Link to non-container database from container database & use below commands. 

create pluggable database exnoncdb from NON$CDB@DBLINK
file_name_convert=('/u01/app/oracle/noncdb','/u01/app/oracle/exnoncdb')  parallel 32;

4) Run Conversion script.

sql> alter session set container=exnoncdb;
sql>@$ORACLE_HOME/rdbms/admin/noncdb_to_pdb.sql

This script can take a long time to run (more than 20 minutes).
Open Pluggable database and check Status:
sql>alter pluggable database open;

sql>SELECT name, open_mode FROM v$pdbs;

You can read more about Oracle PDB from below books:

=====================================================================

You can also , Visit our Blogs for related topic on Pluggable and Container Database:
1)Manual Creation and Drop of Pluggable Database - Oracle 12c & 19c





Comments

Popular posts from this blog

Restart Innodb MySQL Cluster after Complete outage(All node Down)

How to clone Pluggable Database from one container to different Container Database

Oracle Block Corruption - Detection and Resolution