Manual Method
1. The non-CDB details are as follows
SQL> select instance_name from v$instance; INSTANCE_NAME ---------------- test SQL> select cdb from v$database; CDB --- NO SQL> select name from v$datafile; NAME -------------------------------------------------------------------------------- +DATA/test/datafile/system.260.1030288905 +DATA/test/datafile/sysaux.261.1030288913 +DATA/test/datafile/undotbs1.262.1030288917 +DATA/test/datafile/users.264.1030288923 +DATA/TEST/DATAFILE/audit.284.1063984491 +DATA/TEST/DATAFILE/box.285.1063984495 +DATA/TEST/DATAFILE/lobs.286.1063984499 +DATA/TEST/DATAFILE/indexes.287.1063984501 +DATA/TEST/DATAFILE/repository.288.1063984505 +DATA/TEST/DATAFILE/dbaudit.289.1063984509 +DATA/TEST/DATAFILE/audindexes.290.1063984513 +DATA/TEST/DATAFILE/audlobs.291.1063984515 +DATA/TEST/DATAFILE/catbs.292.1063984519 +DATA/TEST/DATAFILE/caindexes.293.1063984523 +DATA/TEST/DATAFILE/ctbs.294.1063984527 +DATA/TEST/DATAFILE/wtbs.295.1063984529 +DATA/TEST/DATAFILE/exptbs.296.10639845332. Claenly shutdown the non-CDB and open in read only mode.
shutdown immediate; startup mount; alter database open read only;3. Create the descriptor file for the non-CDB and shutdown the non-CDB.
SQL> exec dbms_pdb.describe(pdb_descr_file=>'/home/oracle/test_non_cdb.xml'); PL/SQL procedure successfully completed. shutdown immediate4. CDB details are as follows
SQL> select instance_name from v$instance; INSTANCE_NAME ---------------- testcdb5. Run the compatibility check on the CDB using the non-CDB descriptor file.
set serveroutput on declare compa boolean; begin compa := dbms_pdb.CHECK_PLUG_COMPATIBILITY(pdb_descr_file=>'/home/oracle/test_non_cdb.xml'); if compa = true then dbms_output.put_line('compatible'); else dbms_output.put_line('not compatible'); end if; end; / compatible PL/SQL procedure successfully completed.6. As compatible status is shown run the create PDB statement
CREATE PLUGGABLE DATABASE testpdb1 USING '/home/oracle/test_non_cdb.xml' copy; Pluggable database created.7. This creates the PDB in mount state.
SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 5 TESTPDB1 MOUNTEDConnect to the new PDB and check all data files are available
SQL> alter session set container=testpdb1; Session altered. SQL> show con_name CON_NAME ------------------------------ TESTPDB1 SQL> select name from v$datafile; NAME -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/system.305.1063985599 +DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/sysaux.304.1063985599 +DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/undotbs1.303.1063985599 +DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/users.309.1063985599 +DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/audit.308.1063985599 +DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/box.307.1063985599 +DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/lobs.310.1063985599 +DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/indexes.282.1063985599 +DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/repository.280.1063985599 +DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/dbaudit.281.1063985599 +DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/audindexes.283.1063985599 +DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/audlobs.297.1063985599 +DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/catbs.298.1063985599 +DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/caindexes.299.1063985599 +DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/ctbs.300.1063985599 +DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/wtbs.301.1063985599 +DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/exptbs.302.1063985599 17 rows selected.8. As the last step before opening the new PDB run noncdb_to_pdb.sql.
@?/rdbms/admin/noncdb_to_pdb.sql SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 5 TESTPDB1 MOUNTED SQL> alter pluggable database open; Pluggable database altered. SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 5 TESTPDB1 READ WRITE NO
Autoupgrade Method
The same could be acheived with few steps using autoupgrade.jar (which is now the recommended tool for database upgrades). The same non-CDB and the CDB is used earlier is used for this case as well.
1. Create a autoupgrade configuration file with both source and target home set to the same versions. In this case both non-CDB and CDB were running out of the same home. Also the other main paramtere is target_pdb_copy_option which is set to "file_name_convert=NONE" since both non-CDB and CDB are using ASM. A new name oculd be specified to be used when the non-CDB is plugged in as a PDB (uatpdb in this case). The full configuration file used is shown below.
global.autoupg_log_dir=/home/oracle/upgr_log upg1.sid=test upg1.source_home=/opt/app/oracle/product/19.x.0/dbhome_1 upg1.target_home=/opt/app/oracle/product/19.x.0/dbhome_1 upg1.target_cdb=testcdb upg1.target_pdb_name=uatpdb upg1.target_pdb_copy_option=file_name_convert=NONE2. The version of the autoupgrade is 19.9
java -jar autoupgrade.jar -version build.hash bf4ccd4 build.version 19.9.2 build.date 2020/08/31 13:47:51 build.max_target_version 19 build.supported_target_versions 12.2,18,19 build.type production3. Run the autoupgrade with deploy option. This processes pluggin the non-CDB as with the copy option in the manual method.
java -jar autoupgrade.jar -config noncdb_pdb.cfg -mode deploy4. End of the run the PDB is created and in read/write mode
SQL> show pdbs 2 PDB$SEED READ ONLY NO 3 TESTPDB2 MOUNTED 4 DEVPDB READ WRITE NO 5 UATPDB READ WRITE NO5. The data files of the PDB are copied into directory under $asm_diskgroup/cdb_sid/pdb_guid format.
+DATA/TESTCDB/BAFE73D2E50633B2E053060C1FAC8FBD/DATAFILE/system.345.1064159817 +DATA/TESTCDB/BAFE73D2E50633B2E053060C1FAC8FBD/DATAFILE/sysaux.344.1064159817 +DATA/TESTCDB/BAFE73D2E50633B2E053060C1FAC8FBD/DATAFILE/undotbs1.343.1064159817 +DATA/TESTCDB/BAFE73D2E50633B2E053060C1FAC8FBD/DATAFILE/users.329.1064159817 +DATA/TESTCDB/BAFE73D2E50633B2E053060C1FAC8FBD/DATAFILE/audit.330.1064159817 +DATA/TESTCDB/BAFE73D2E50633B2E053060C1FAC8FBD/DATAFILE/box.331.1064159817 +DATA/TESTCDB/BAFE73D2E50633B2E053060C1FAC8FBD/DATAFILE/lobs.332.1064159817 +DATA/TESTCDB/BAFE73D2E50633B2E053060C1FAC8FBD/DATAFILE/indexes.333.1064159817 +DATA/TESTCDB/BAFE73D2E50633B2E053060C1FAC8FBD/DATAFILE/repository.334.1064159817 +DATA/TESTCDB/BAFE73D2E50633B2E053060C1FAC8FBD/DATAFILE/dbaudit.335.1064159817 +DATA/TESTCDB/BAFE73D2E50633B2E053060C1FAC8FBD/DATAFILE/audindexes.336.1064159817 +DATA/TESTCDB/BAFE73D2E50633B2E053060C1FAC8FBD/DATAFILE/audlobs.337.1064159817 +DATA/TESTCDB/BAFE73D2E50633B2E053060C1FAC8FBD/DATAFILE/catbs.338.1064159817 +DATA/TESTCDB/BAFE73D2E50633B2E053060C1FAC8FBD/DATAFILE/caindexes.339.1064159817 +DATA/TESTCDB/BAFE73D2E50633B2E053060C1FAC8FBD/DATAFILE/ctbs.340.1064159817 +DATA/TESTCDB/BAFE73D2E50633B2E053060C1FAC8FBD/DATAFILE/wtbs.341.1064159817 +DATA/TESTCDB/BAFE73D2E50633B2E053060C1FAC8FBD/DATAFILE/exptbs.342.1064159817 17 rows selected.
The comparision shows that autoupgrade method require few steps and less manaul intervention.
Related Posts
Plugging non-CDB as a PDB into a CDB in the Same Host
Plugging in non-CDB to CDB and reusing the non-CDB Datafiles in Standby