Non-CDB database name: dupdb
CDB database name: prdcdb
Step-1: Shutdown non-cdb database (dupdb)
SQL> show parameter uniq
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_unique_name string DUPDB
SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
Step-2: Startup non-cdb database in read-only mode
SQL> startup mount
ORACLE instance started.
Total System Global Area 1073741824 bytes
Fixed Size 8628936 bytes
Variable Size 373294392 bytes
Database Buffers 687865856 bytes
Redo Buffers 3952640 bytes
Database mounted.
SQL> alter database open read only;
Database altered.
SQL> select name,open_mode from v$database;
NAME OPEN_MODE
--------- --------------------
DUPDB READ ONLY
Step-3: Generate the XML file required for CDB conversion.
SQL> BEGIN
2 DBMS_PDB.DESCRIBE
3 (pdb_descr_file=>'/tmp/dupdb.xml');
4 END;
5 /
PL/SQL procedure successfully completed.
Step-4: Shutdown the non-cdb database (dupdb)
SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
Step-5: Connect to CDB database and check the compatibility of PDB
SQL> SET SERVEROUTPUT ON;
SQL> DECLARE
2 compatible CONSTANT VARCHAR2(3) := CASE
3 DBMS_PDB.CHECK_PLUG_COMPATIBILITY(pdb_descr_file =>'/tmp/dupdb.xml')
4 WHEN TRUE THEN 'YES'
5 ELSE 'NO'
6 END;
7 BEGIN
8 DBMS_OUTPUT.PUT_LINE(compatible);
9 END;
10 /
YES ----- Output is Yes, then it is compatible
PL/SQL procedure successfully completed.
Step-6: Now, lets check the violation from the above step
SQL> col CAUSE for a20
SQL> col name for a15
SQL> col MESSAGE for a100
SQL> select name,cause,type,message,status from PDB_PLUG_IN_VIOLATIONS where name='DUPDB';
NAME CAUSE TYPE MESSAGE STATUS
--------------- -------------------- --------- ---------------------------------------------------------------------------------------------------- ---------
DUPDB Non-CDB to PDB WARNING PDB plugged in is a non-CDB, requires noncdb_to_pdb.sql be run. PENDING
DUPDB Parameter WARNING CDB parameter sga_target mismatch: Previous 1G Current 0 PENDING
DUPDB Parameter WARNING CDB parameter pga_aggregate_target mismatch: Previous 379M Current 0 PENDING
Above violations can be ignore.
Step-7: Create pluggable database using the XML file which was create in Step-3
SQL> CREATE PLUGGABLE DATABASE pdb3 using '/tmp/dupdb.xml' NOCOPY;
CREATE PLUGGABLE DATABASE pdb3 using '/tmp/dupdb.xml' NOCOPY
*
ERROR at line 1:
ORA-27038: created file already exists
ORA-01119: error in creating database file '/u01/app/oracle/oradata/dupdb/temp01.dbf'
You see the above error because the tempfile is already exists and to avoid the above error just use "TEMPFILE REUSE" option.
SQL> CREATE PLUGGABLE DATABASE pdb3 using '/tmp/dupdb.xml' NOCOPY tempfile reuse;
Pluggable database created.
Step-8: Run the noncdb_to_pdb script to clean up the newly created PDB, and make sure to set the newly created pdb before you run the script.
SQL> alter session set container=PDB3;
Session altered.
SQL> @$ORACLE_HOME/rdbms/admin/noncdb_to_pdb.sql
Alert log contents:
2022-06-10T18:25:29.364402-04:00
alter pluggable database "PDB3" close immediate instances=all
ORA-65020 signalled during: alter pluggable database "PDB3" close immediate instances=all...
alter pluggable database "PDB3" open upgrade
PDB3(6):Autotune of undo retention is turned on.
2022-06-10T18:25:29.449556-04:00
PDB3(6):Endian type of dictionary set to little
PDB3(6):[17764] Successfully onlined Undo Tablespace 2.
PDB3(6):Undo initialization finished serial:0 start:6733627 end:6733644 diff:17 ms (0.0 seconds)
Opatch validation is skipped for PDB PDB3 (con_id=6)
PDB3(6):Deleting old file#1 from file$
PDB3(6):Deleting old file#2 from file$
PDB3(6):Deleting old file#3 from file$
PDB3(6):Deleting old file#4 from file$
PDB3(6):Deleting old file#5 from file$
PDB3(6):Deleting old file#7 from file$
PDB3(6):Adding new file#18 to file$(old file#1)
PDB3(6):Adding new file#19 to file$(old file#3)
PDB3(6):Adding new file#20 to file$(old file#4)
PDB3(6):Adding new file#21 to file$(old file#7)
PDB3(6):Successfully created internal service pdb3 at open
****************************************************************
Post plug operations are now complete.
Pluggable database PDB3 with pdb id - 6 is now marked as NEW.
****************************************************************
PDB3(6):Database Characterset for PDB3 is AL32UTF8
PDB3(6):Resource Manager disabled during database migration: plan '''' not set
PDB3(6):Opening pdb with Resource Manager plan: ''
PDB3(6):ORA-7452: resource plan '''' does not exist
PDB3(6):INTERNAL_PLAN is enabled instead
Pluggable database PDB3 opened in upgrade mode
Completed: alter pluggable database "PDB3" open upgrade
last few lines from alert log:
PDB3(6):INTERNAL_PLAN is enabled instead
Pluggable database PDB3 opened in upgrade mode
PDB3(6):Completed: alter pluggable database "PDB3" open upgrade
2022-06-10T18:38:31.732267-04:00
PDB3(6):Resize operation completed for file# 20, old size 860160K, new size 870400K
2022-06-10T18:38:33.482320-04:00
PDB3(6):alter pluggable database "PDB3" close immediate instances=all
2022-06-10T18:38:33.489889-04:00
PDB3(6):JIT: pid 17764 requesting stop
Pluggable database PDB3 closed
PDB3(6):Completed: alter pluggable database "PDB3" close immediate instances=all
Step-9: Startup and Validate the PDB.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
6 PDB3 MOUNTED
SQL> alter pluggable database PDB3 open;
Pluggable database altered.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
6 PDB3 READ WRITE NO
.
SQL> set lines 200 pages 200
SQL> col name for a15
SQL> select name,open_mode from v$containers;
NAME OPEN_MODE
--------------- ----------
CDB$ROOT READ WRITE
PDB$SEED READ ONLY
PDB1 READ WRITE
PDB2 READ WRITE
PDB3 READ WRITE
Comments
Post a Comment