DOYENSYS Knowledge Portal




We Welcome you to visit our DOYENSYS KNOWLEDGE PORTAL : Doyensys Knowledge Portal




Monday, January 19, 2015

Adopting a Non-CDB as a Pluggable Database in a Multitenant Container Database

    Introduction

    You can easily plug an Oracle Database 12c non-CDB into a CDB. Just create a PDB manifest file for the non-CDB, and then use the manifest file to create a cloned PDB in the CDB.

    Prerequisites 

    • Ensure that you have enough disk space to hold a second copy of the non-CDB.
    • Install Oracle Database 12c.
    • Create a non-CDB and a CDB.
The environment used in the development of this tutorial is as follows:
  • ORACLE_HOME: /u01/app/oracle/product/12.1.0
  • TNS Listener port: 1521
  • Container databases:
    • SID: cdb1
    • SID: cdb2
  • Pluggable databases (in cdb1):
    • pdb1
    • pdb2

 

Setting the Non-CDB to Read-Only Mode

    Set the ORACLE_SID variable to noncdb.
    . oraenv
    [enter noncdb at the prompt]
    Connect to the noncdb instance.
    sqlplus / as sysdba
    If the instance is up, shut it down.
    shutdown immediate
    Start the database in mount exclusive mode.
    startup mount exclusive
    Open the database in read-only mode.
    alter database open read only;
 

Generating a Pluggable Database Manifest File for the Non-CDB

    Execute the dbms_pdb.describe procedure to generate the manifest file.
    exec dbms_pdb.describe(pdb_descr_file=>'/u01/app/oracle/oradata/noncdb/noncdb.xml');
    Shut down the noncdb instance to prepare to copy the data files in the next section.
    shutdown immediate
    exit
 

Creating and Plugging in a PDB into cdb2 by Using the noncdb Manifest File

    Connect to cdb2. If it is down, start it.
    . oraenv
    [enter cdb2 at the prompt]
    sqlplus / as sysdba
    Create a PDB by using the noncdb manifest file. Use the file_name_convert parameter to place the copied data files in a different location.
    create pluggable database exnoncdb
    as clone
    using '/u01/app/oracle/oradata/noncdb/noncdb.xml'
    file_name_convert=('/u01/app/oracle/oradata/noncdb','/u01/app/oracle/oradata/exnoncdb')
    copy;
    Finalize the plug-in by opening the new PDB, closing it, and then reopening it.
    alter pluggable database exnoncdb open;
    alter pluggable database exnoncdb close;
    alter pluggable database exnoncdb open;
    exit
 

Converting to the PDB Data Dictionary (Optional)

    At this point, the new PDB cloned from the non-CDB will work fine. However, if you need to upgrade the CDB later, you should run the noncdb_to_pdb.sql script to remove superfluous non-CDB data from the PDB data dictionary. This step is optional in this tutorial, but it is recommended in a production environment.
    Connect to the new exnoncdb PDB.
    sqlplus sys/oracle@localhost:1521/exnoncdb as sysdba
    Run $ORACLE_HOME/rdbms/admin/noncdb_to_pdb.sql. This script can take a long time to run (more than 20 minutes).
    @$ORACLE_HOME/rdbms/admin/noncdb_to_pdb.sql
 

Resetting Your Environment

    Perform the following steps to reset your environment prior to repeating the activities covered in this OBE or starting another OBE.
    Close the newly created exnoncdb PDB.
    . oraenv
    [enter cdb2 at the prompt]
    sqlplus / as sysdba
    alter pluggable database exnoncdb close immediate;
    Delete the exnoncdb PDB and its data files.
    drop pluggable database exnoncdb including datafiles;
 

No comments: