This article I will show you, How to migrating a non-CDB/PDB database to a PDB using DBMS_PDB.
The DBMS_PDB package allows you to generate an XML metadata file from a
non-CDB 12c database, effectively allowing it to be describing it the way you
do when unplugging a PDB database. This allows the non-CDB to be plugged in as
a PDB into an existing CDB.
Lab :-
Source 12.1.0.1 non-cdb :ORCL
Target
CDB
: CDB1
Target
PDB
: ORCL
Overview:
1. Log into ORCL as sys
2.
Get the database in a consistent state by
shutting it down cleanly.
3.
Open the database in read only mode
4.
Run DBMS_PDB.DESCRIBE to create an XML file describing
the database.
5.
Shut down ORCL
6.
Connect to target CDB (CDB1)
7.
Check whether non-cdb (ORCL) can be plugged
into CDB(CDB1)
8.
Plug-in Non-CDB (ORCL) as PDB(ORCL) into
target CDB(CDB1).
9.
Access the PDB and run the noncdb_to_pdb.sql
script.
10. Open the new PDB in
read/write mode.
Task 1) Log
into ORCL as sys
To Check database whether Non CDB
or CDB/PDB
Note: Connect to an existing CDB and create a new PDB using the file
describing the non-CDB database. Remember to configure the
FILE_NAME_CONVERT parameter to convert the existing files to the
new location.
Find out names
of datafiles for ORCL (needed for FILE_NAME_CONVERT)
Task 2) Get
the database in a consistent state by shutting it down cleanly.
Task 3) Open
the database in read only mode.
Task 4) Run
DBMS_PDB.DESCRIBE to create an XML file describing the database.
BEGIN
DBMS_PDB.DESCRIBE(
pdb_descr_file => '/oradata/ORCL/orcl.xml');
END;
/
Task 5) Shut
down ORCL.
Now we can plug NONCDB into a existing CDB database cdb1
Task 6) Connect
to target CDB (CDB1).
Task 7) Check
whether non-cdb (ORCL) can be plugged into CDB(CDB1).
SET SERVEROUTPUT ON
DECLARE
compatible CONSTANT VARCHAR2(3) :=
CASE DBMS_PDB.CHECK_PLUG_COMPATIBILITY(
pdb_descr_file => '/oradata/ORCL/orcl.xml',
pdb_name => 'ORCL')
WHEN TRUE THEN 'YES'
ELSE 'NO'
END;
BEGIN
DBMS_OUTPUT.PUT_LINE(compatible);
END;
/
If the scripts
return NO, then check PDB_PLUG_IN_VIOLATIONS view.
col cause for a10
col name for a10
col message for a35 word_wrapped
select
name,cause,type,message,status from PDB_PLUG_IN_VIOLATIONS where name='ORCL';
Note
:- Showing “There are WARNING’s only”. We can
continue.
Task 8) Plug-in
Non-CDB (ORCL) as PDB(ORCL) into target CDB(CDB1).
Plug-in
Non-CDB (ORCL) as PDB (ORCL).
I am going to plugging
the database in to a CDB on the same server with COPY clause and hence using
FILE_NAME_CONVERT.
CREATE PLUGGABLE DATABASE ORCL USING
'/oradata/ORCL/orcl.xml'
COPY
file_name_convert=('/oradata/ORCL','/oradata/CDB1/ORCL');
To check that datafiles
for the plugagble database ORCL have been created in the location specified in
FILE_NAME_CONVERT
Check that newly
created PDB ORCL is in mounted state
check that status of newly created PDB ORCL is NEW.
col pdb_name for a15
select pdb_name, status
from dba_pdbs where pdb_name = 'ORCL';
Task 9) Access
the PDB and run the noncdb_to_pdb.sql script.
Switch to the PDB
container and run the $ORACLE_HOME/rdbms/admin/noncdb_to_pdb.sql"
script to clean up the new PDB, removing any items that should not be present
in a PDB.
To Access the newly created PDB.
Task 10)
Open the new PDB in read/write mode.
Hope
it helps. Please stay tuned, add me to your G+ Circles!! Your feedback always
helps me and motivates me to blog more, please leave your valuable comment that
is always a pleasure to read.
Many
Thanks,
Regards
Senthilkumar
Devaraj





























































