Steps to migrate Non-container Database to Container Pluggable Database
Introduction:
This document is intended for DBA’s who need to know how to migrate the Non-container database to container PDB. This blog outlines the essential steps to facilitate a smooth and successful transition, ensuring efficiency and optimal utilization of Oracle Multitenant architecture.
Why we need to do:
If a client expresses interest in transitioning from a non-CDB to a container pluggable database, it’s essential to assess the feasibility, propose a tailored plan, and then execute the migration steps. This article delves into the process of migrating a non-container database to a container PDB, offering insights and guidance for a smooth transition.
Steps to Migrate:
a. Perform clean shutdown at Non-CDB
Connect and shutdown the Non-cdb database
sqlplus / as sysdba
SQL>shut immediate;
b. Start the Non-CDB database in READ ONLY mode
sqlplus / as sysdba
SQL> startup open read only;
c. Generate manifest XML file for Non-CDB database
sqlplus / as sysdba
SQL> exec DBMS_PDB.DESCRIBE(pdb_descr_file => ‘/tmp/noncdb_manifest.xml’);.
d. Shutdown the Non-CDB database,
sqlplus / as sysdba
SQL>shut immediate;
Note – From here, all steps will be performed on the Container database
e. Start container database if not running
SQL> sqlplus / as sysdba
SQL> startup
f. Check Non-CDB (non-container database) compatibility with CDB (container database)
SQL> SET SERVEROUTPUT ON
DECLARE
compatible CONSTANT VARCHAR2(3) := CASE DBMS_PDB.CHECK_PLUG_COMPATIBILITY(pdb_descr_file => ‘/tmp/noncdb_manifest.xml’)
WHEN TRUE THEN ‘YES’
ELSE ‘NO’
END;
BEGIN
DBMS_OUTPUT.PUT_LINE(compatible);
END;
/
Output:
YES
PL/SQL procedure successfully completed.
g. Check for any errors resulting from the above step
SQL> col name for a10
col cause for a10
col type for a20
col message for a80
set lines 230
SELECT name, cause, type, message, status FROM PDB_PLUG_IN_VIOLATIONS WHERE name='<DB_NAME>’;
Note: If there are any errors, fix them before proceeding.
h. Plug the Non-CDB database into the container database.
SQL> create pluggable database <PDB_NAME> using ‘/tmp/noncdb_manifest.xml’ NOCOPY tempfile reuse;
Note: below are some other options that can also be used with the “create pluggable database”.
COPY:
The COPY option is used to create a PDB by copying all data files from the source PDB.
This is the default behavior if neither COPY nor NOCOPY is specified.
NOCOPY:
The NOCOPY option is used to create a PDB without copying data files. Instead, it creates links to the data files of the source PDB.
MOVE:
The MOVE option is used to relocate data files to a different location when creating the new PDB.
It is often used in conjunction with the NOCOPY option to move data files to a new location.
i. Run the PDB conversion script provided by Oracle
sqlplus / as sysdba
SQL> alter session set container=<PDB_NAME>;
SQL> @$ORACLE_HOME/rdbms/admin/noncdb_to_pdb.sql
Note: Now PDB will be in MOUNT state
j. Start PDB and verify the state
sqlplus / as sysdba
SQL> alter pluggable database open;
SQL> SELECT name, open_mode FROM v$pdbs;
Conclusion:
Using the above steps DBA can easily Migrate a Non-container database to a container pluggable database.