November 18, 2020

How to Convert/unplug and plugin the NON-CDB to CDB in 12cR1 database

Posted by Shaik Ahmed Ali on November 18, 2020 in , , , | No comments

 Hi guys, in this era of technology Oracle upgrading its product day by day so we also need to upgrade our selves on regular basis so in this article  will explain to you how to convert the NON-CDB to CDB in the 12c database or unplug and plugin the NON-CDB to CDB

Steps to do it are :

1) connect to the non-cdb and shutdown the database and open in the read-only mode as shown below in the screenshot



After performing the above task and opening the database in the read-only mode now create the manifest file using the below command :

exec DBMS_PDB.DESCRIBE (pdb_descr_file => '/u01/app/oracle/noncdb1.xml');


Now shutdown the NON-CDB database as below  


after the shutdown of the non-cdb database connect to your CDB database  and run the compatible command @ CDB database and if the output is YES then proceed, if its output is NO go and check the violation from the below query:
 
select name,cause,type,message,status from PDB_PLUG_IN_VIOLATIONS where name='NCDBNAME';

check the compatibility by running the below query at CDB 

SET SERVEROUTPUT ON;
DECLARE

Compatible CONSTANT VARCHAR2(3) :=CASE
DBMS_PDB.CHECK_PLUG_COMPATIBILITY
  (pdb_descr_file => '/u01/app/oracle/noncdb1.xml')
   
  WHEN TRUE THEN 'YES'

  ELSE 'NO'
  
  END;

  BEGIN
  DBMS_OUTPUT.PUT_LINE(compatible);
  END;

 /


After this, now time to create the Pluggable database using the manifest file created from the NON-CDB  show as below 


While creating the pluggable database there is 3 option for the datafile location which are 
  • COPY: it is the default, it means that data file will copy to the new location mention in the file_name_convert parameter and keep the original as it is while creating PDB so the NON-CDB database will be accessible after the creation of PDB 
create pluggable database orcl using '/u01/app/oracle/noncdb1.xml' copy  FILE_NAME_CONVERT =    ('old datafile loc/',' new datafile loc');
  • NOCOPY: it means it will use the original location of the datafile of NON-CDB to create PDB  so NON_CDB will not be available after creating the CDB
create pluggable database PDB2 using '/u01/app/oracle/noncdb1.xml' nocopy tempfile reuse;
  • MOVE: it will move the datafile to a new location and NON-CDB will not be available after PDB created.
create pluggable database orcl using '/u01/app/oracle/noncdb1.xml' move FILE_NAME_CONVERT =    ('old datafile loc/','new datafile loc');

 I am using the copy option while creating the PDB 

After PDB got created switch to PDB using the below command and run the @?/rdbms/admin/noncdb_to_pdb.sql


the end of the script looks like this shown in the below screenshot
          

now open the PDB in read-write mode using the below command 
alter pluggable database PDBNAME open;





Note: when your CDB is on a different host you need to copy the manifest file and datafile to the CDB host and update the new location in the XML file.


hope you all enjoy reading this article of convert or unplug/plugin NON-CDB to CDB, happy learning and give feedback which is appreciated 
thanks in advance.








0 comments:

Post a Comment