Tuesday, 3 December 2013

How to migrating a non-CDB/PDB database to a PDB using DBMS_PDB


This article I will show you, How to migrating a non-CDB/PDB database to a PDB using DBMS_PDB.

     

The DBMS_PDB package allows you to generate an XML metadata file from a non-CDB 12c database, effectively allowing it to be describing it the way you do when unplugging a PDB database. This allows the non-CDB to be plugged in as a PDB into an existing CDB.

Lab :-

                        Source 12.1.0.1 non-cdb             :ORCL
                        Target CDB                                 : CDB1
                        Target PDB                                 : ORCL

Overview:

1.     Log into ORCL as sys
2.     Get the database in a consistent state by shutting it down cleanly.
3.     Open the database in read only mode
4.     Run DBMS_PDB.DESCRIBE to create an XML file describing the database.
5.     Shut down ORCL
6.     Connect to target CDB (CDB1)
7.     Check whether non-cdb (ORCL) can be plugged into CDB(CDB1)
8.     Plug-in Non-CDB (ORCL) as PDB(ORCL) into target CDB(CDB1).
9.     Access the PDB and run the noncdb_to_pdb.sql script.


10.   Open the new PDB in read/write mode.

Task 1) Log into ORCL as sys

            To Check database whether Non CDB or CDB/PDB


Note: Connect to an existing CDB and create a new PDB using the file describing the non-CDB database. Remember to configure the FILE_NAME_CONVERT parameter to convert the existing files to the new location.

Find out names of datafiles for ORCL (needed for FILE_NAME_CONVERT)


Task 2) Get the database in a consistent state by shutting it down cleanly.


Task 3) Open the database in read only mode.


Task 4) Run DBMS_PDB.DESCRIBE to create an XML file describing the database.

BEGIN
  DBMS_PDB.DESCRIBE(
    pdb_descr_file => '/oradata/ORCL/orcl.xml');
END;
/



Task 5) Shut down ORCL.



Now we can plug NONCDB into a existing CDB database cdb1

Task 6) Connect to target CDB (CDB1).



Task 7) Check whether non-cdb (ORCL) can be plugged into CDB(CDB1).

SET SERVEROUTPUT ON
DECLARE
compatible CONSTANT VARCHAR2(3) :=
CASE DBMS_PDB.CHECK_PLUG_COMPATIBILITY(
pdb_descr_file => '/oradata/ORCL/orcl.xml',
pdb_name => 'ORCL')
WHEN TRUE THEN 'YES'
ELSE 'NO'
END;
BEGIN
DBMS_OUTPUT.PUT_LINE(compatible);
END;
/


If the scripts return NO, then check PDB_PLUG_IN_VIOLATIONS view.

col cause for a10
col name for a10
col message for a35 word_wrapped
select name,cause,type,message,status from PDB_PLUG_IN_VIOLATIONS where name='ORCL';


Note :-  Showing “There are WARNING’s only”.   We can continue.

Task 8) Plug-in Non-CDB (ORCL) as PDB(ORCL) into target CDB(CDB1).


Plug-in Non-CDB (ORCL) as PDB (ORCL).

I am going to plugging the database in to a CDB on the same server with COPY clause and hence using FILE_NAME_CONVERT.


CREATE PLUGGABLE DATABASE ORCL USING '/oradata/ORCL/orcl.xml'
COPY
file_name_convert=('/oradata/ORCL','/oradata/CDB1/ORCL');



To check that datafiles for the plugagble database ORCL have been created in the location specified in FILE_NAME_CONVERT




Check that newly created PDB ORCL is in mounted state



check that status of newly created PDB ORCL is NEW.

col pdb_name for a15


select pdb_name, status from dba_pdbs where pdb_name = 'ORCL';



Task 9) Access the PDB and run the noncdb_to_pdb.sql script.

Switch to the PDB container and run the $ORACLE_HOME/rdbms/admin/noncdb_to_pdb.sql" script to clean up the new PDB, removing any items that should not be present in a PDB.

To Access the newly created PDB.







Task 10) Open the new PDB in read/write mode.



Hope it helps. Please stay tuned, add me to your G+ Circles!! Your feedback always helps me and motivates me to blog more, please leave your valuable comment that is always a pleasure to read.

Many Thanks,

Regards
Senthilkumar Devaraj

Monday, 18 November 2013

Creating a Multitenant Container Database and Pluggable Database


      This article I am going to show you how to create multitenant container database and pluggable databases  

  
Oracle Database 12c brings a new architecture that lets you have many pluggable databases
inside a single Oracle Database (Container database (CDB)).

The Container Database is standard contains the following containers.

Root container - It is the core of the CDB, contains all Oracle supplied metadata like packages, core dictionary objects, and common users. It is denoted as CDB$ROOT

SEED Container (SEED PDB) - This is a template database distributed for new PDBs, whenever we create a new PDB, Oracle copies mandatory datafiles (common datafiles) for creation of PDB from this SEED Database. This is by default in READ-ONLY mode, can't be altered or modified. This is denoted as PDB$SEED

User defined PDB Container (PDB) - This is the Pluggable Database created for Application purpose, contains only Consumer Data or USER Data

Some of the characteristics of a CDB:-
  • There is a separate SYSTEM and SYSAUX tablespace for the root container of the CDB and each PDB
  • Only one UNDO tablespace for the entire CDB
  • Only one set of control files and online redo logs files for the entire CDB.
  • PDB’s have their own data files (which contain the user data)
  • We can create on default temporary tablespace for the entire CDB or each PDB can have its own additional temporary tablespaces
  • There is only one set of background processes shared by the root and all PDBs
  • There is a single SGA shared by all  PDB’s
Benefits :-

Cost reduction in terms of Product licensing and Hardware procurement as we require less number of processors and less memory compare to a Non-CDB environment

Easier Database maintenance, Pluggable Databases can easily be moved or copied locally or remotely across Physical machines in the network, Upgrading Operating System, Upgrading or Patching Databases itself is a lot easier and "often" a one shot process, that greatly improves the availability

Performance tuning becomes a lot easier as all PDBs in a CDB environment share the same Hardware/Platform/Network resources like CPUs/Memory/OS/Bandwidth etc.. For example, It is quite easy to tune one single piece of SGA/PGA on one single instance rather than tuning each SGA on each physical machine

Create a CDB named CDB1 using DBCA 


Window/Page Description:- Database Operation , Choices or Values:-  Select "Create Database" , Click Next


Window/Page Description:- Creation Mode , Choices or Values:-  Select "Advance Mode"
Click Next



Window/Page Description:- Database Template , Choices or Values:- Select  " General Purpose or Transaction Processing " , Click Next




Window/Page Description:- Database Identification

Enter :-
Global Database Name :- CDB1
                                    SID:- CDB1 ,                 
         Choices or Values:- Select "Create As Container Database"
                                     Select "Create An Empty Container Database,   Click Next



Window/Page Description:- Management options
                    Choices or Values:- Select "Configure Enterprise Manager(EM) Database Express" (Optional) , Click Next


Window/Page Description:- Database Credentials
                    Choices or Values:- Select "Use same Administrative Password"
                    Click Next

Window/Page Description:- Network Configuration
                    Choices or Values :- “Listener Selection"
                     Name of Listener  :- LISTENER_CDB1
                     Port Number         :-1521
                     Click Next

Window/Page Description:- Storage Location
                   Confirm Storage Type is "File system"
                    Choices or Values:- Select "Use Common Location for All Databases Files"


                    Click Next


Window/Page Description:- Enable archive
                    Choices or Values:- Select "Archive log location"
                    Click Next



Window/Page Description:- Database option ,  Click Next



Window/Page Description:- Initialization Parameter ,  Click Next


Window/Page Description:- Pre Requisite Checks , Click Next

Window/Page Description:- Summary, Click Finsh


Window/Page Description:- Progress Page


Window/Page Description:-  on the database Configuration Assistant page(for password management),

 Click :- Exit.

  Click :- Close



Connect to the multitenant container database CDB1 ,Check if the database is  a multitenant container database



Check services :-


Create Pluggable Database (PDB1) Using DBCA



Window/Page Description:- Database Operation
            Choices or Values:- Select  " Manage Pluggable Databases "
             Click Next



Window/Page Description:- Manage Pluggable Databases
             Choices or Values:- Select  " Create a Pluggable Database "
              Click Next

Window/Page Description:- Database List
            Choices or Values:- Select  a container database which the pluggable database can be created, Click Next





Window/Page Description:- Create Pliggable Database
            Choices or Values:- Select  " Create a new Pluggable Database "
             Click Next


Window/Page Description:- Pluggable Database Options
                    Choices or Values:-
                     Pluggable Database Name :- PDB1
                     Administrator Username :- oracle_4u
                     Administrator Password :- XXXXXX
                     Confirm ADMIN Password:- XXXXX
                     Click Next


Window/Page Description:- Summary
                                         Click Finish


Window/Page Description:- Progress Page


Window/Page Description:- Progress Page
                                         Click Close


Check the Pluggable Database status 



Configure tnsname for Pluggable database

                                          













Connect to any of the PDB in your CDB1 except PDB$SEED.






Shutdown PDB:-


Verify PDB down or not :-


Startup PDB:-


End of this article , You have learned how to created CDB and PDB database , How to bring down and up  PDB database . 

                                      Thank You all for watch this Demo .