Below are steps for converting a non CDB/PDB database to PDB database in oracle. i.e Plugging a normal 12c non pdb database to a container database.
READ more about CDB and PDB: Oracle 12c Multitenent architecture
DEMO:
NON-CDB DB -NAME -> NONCDB
CDB DB NAME -> DBATEST
Prerequisites:
Make sure One container database already exists.
STEPS:
1. Open the non-cdb database in read only mode:
SQL> select name from v$database; NAME --------- NONCDB SQL> shutdown immediate; Database closed. Database dismounted. ORACLE instance shut down. SQL> startup open read only ORACLE instance started. Total System Global Area 1.8119E+10 bytes Fixed Size 7641528 bytes Variable Size 1.0133E+10 bytes Database Buffers 7851737088 bytes Redo Buffers 126574592 bytes Database mounted. Database opened. SQL> select name,open_mode from v$database; NAME OPEN_MODE --------- -------------------- NONCDB READ ONLY
2. Check the compatibility of PDB on ( NONCDB)
BEGIN DBMS_PDB.DESCRIBE(pdb_descr_file => '/export/home/oracle/NonCDB.xml'); END; / PL/SQL procedure successfully completed.
3. shutdown the NON-CDB database ( NONCDB)
SQL> shutdown immediate; Database closed. Database dismounted. ORACLE instance shut down. SQL> exit
Now connect to the container database, where it need to be plugged.
SET SERVEROUTPUT ON; DECLARE compatible CONSTANT VARCHAR2(3) := CASE DBMS_PDB.CHECK_PLUG_COMPATIBILITY(pdb_descr_file => '/export/home/oracle/NonCDB.xml') WHEN TRUE THEN 'YES' ELSE 'NO' END; BEGIN DBMS_OUTPUT.PUT_LINE(compatible); END; /
5. Check the violations:
select name,cause,type,message,status from PDB_PLUG_IN_VIOLATIONS where name='NONCDB'; NAME CAUSE TYPE -------------------- -------------------- --------- MESSAGE STATUS ----------------------------------- --------- NONCDB Non-CDB to PDB WARNING PDB plugged in is a non-CDB, PENDING requires noncdb_to_pdb.sql be run. NONCDB Parameter WARNING CDB parameter memory_target PENDING mismatch: Previous 17280M Current 13856M
6. Create pluggable database ( DBATEST)
SQL> create pluggable database NONCDB using '/export/home/oracle/NonCDB.xml' NOCOPY; create pluggable database NONCDB using '/export/home/oracle/NonCDB.xml' NOCOPY * ERROR at line 1: ORA-27038: created file already exists ORA-01119: error in creating database file '/archive/NONCDB/temp01.dbf' --- As tempfile is already there, so mention tempfile reuse tag, to avoid this error. SQL> create pluggable database NONCDB using '/export/home/oracle/NonCDB.xml' NOCOPY tempfile reuse; Pluggable database created.
7 . Run the noncdb_to_pdb.sql script
ALTER SESSION SET CONTAINER=NONCDB; @$ORACLE_HOME/rdbms/admin/noncdb_to_pdb.sql
8. Open the PDB:
SQL> ALTER PLUGGABLE DATABASE OPEN; Pluggable database altered. SQL> SELECT name, open_mode FROM v$pdbs; NAME OPEN_MODE -------------------- ---------- NONCDB READ WRITE 1 row selected. SQL> select name,open_mode from v$pdbs; NAME OPEN_MODE -------------------- ---------- PDB$SEED READ ONLY PDB1 READ WRITE PDB2 READ WRITE NONCDB READ WRITE
Hi. What does nocopy realy do? Do i have after that the whole non pdb as pdb in the cdb? We want to get our dwh into cdb on the same system..same asm..on exadata. Dwh has 30TB. We will not copy the datafiles of course. Br. Wolfgang
Hi Wolfgang,
Nocopy means it wont copy the datafiles. As you are planning to move to cdb(assumption is currently db in oracle 12c with non-cdb).
Just Create a blank cdb database on that server of same version and patch set and follow the steps a mentioned in this article.
And you dont have to copy any datafiles. The xml file generated in step2 will contain information about the datafile locations and the pdb will use those location.
Let us know if you still queries.
Regards
Hi,
DWH DB is still running under 11gR2, but we upgrade to 12.2, after that customer wants to put it into CDB as PDB.
Sounds good. It would be terrible to move files with such a DWH database 🙂
Regards,
Wolfgang
We have 70TB database to be converted to PDB. The same procedure will work?. or after creating pdb, we have to clone it assuming the versions are same?.
Thanks
Suresh
You to put convert the database to PDB in the same server or on new server?
If you doing on the same server, then mentioned steps in this article will work. However for doing on serparate server, cloning is required.
You can put the question on QA FORUM , for further discussion on this topic.
Regards
Admin
ADMIN
Hello, which method is more advantageous from the below?
1. To adopt a non-CDB as a PDB using the DBMS_PDB package
2. Cloning a Remote Non-CDB using db_link
I’m referring to documentation – https://docs.oracle.com/en/database/oracle/oracle-database/18/multi/cloning-a-pdb.html#GUID-3433B3BF-372F-4A4A-988E-919E76C7F2A6
I see both methods do incur some downtime?
Hope you got the answer by this time. But I suggest…pick DBlink method if DB size is small. Else, other one to reduce downtime