Oracle Multitenant Option - 12c : Frequently Asked Questions

Oracle Multitenant Option - 12c : Frequently Asked Questions.



APPLIES TO:

Oracle Database - Enterprise Edition - Version 12.1.0.1 to 12.1.0.1 [Release 12.1]
Information in this document applies to any platform.

PURPOSE

 To document many aspects & usages of pluggable database for better understanding and quick references of this product.

QUESTIONS AND ANSWERS

General CDB / PDB Concept in  12c Multitenant Architecture

What is a pluggable database (PDB) in Multitenant Architecture?

Pluggable Databases (PDBs) is new in Oracle Database 12c Release 1 (12.1). You can have many pluggable databases inside a single Oracle Database occurrence. Pluggable Databases are fully backwards compatible with an ordinary pre-12.1 database.

Why would I consider using the Multitenant option ?

You should consider following Database Consolidation Goals to achieve:
  • Reduce Total Cost of Operation
           - Administration costs
           - Operations costs
           - Data center costs
           - Storage costs
           - Contingency costs
  • Improve Functionalities
            - Resource utilization
            - Manageability
            - Integration
            - Service management
  • Must not need to change applications
  • Must not harm performance
  • Must provide resource management and isolation
    between applications
  • Must simplify patching and upgrade
    of Oracle Database

What other benefits will I get from Multitenant option ?

The benefits of mulitenant Pluggable Databases are:
  • Fast provisioning of a new database or of a copy of an existing database.
  • Fast redeployment, by unplug and plug, of an existing database to a new platform.
  • Quickly patch or upgrade the Oracle Database version for many databases and for the cost of doing it once.
  • Patch or upgrade by unplugging a PDB and plugging it into a different container database (CDB) in a later version.
  • A machine can run more database instances in the form of PDBs than as individual, monolithic databases.
  • Separate the duties of the application administrator from the duties of the administrator of the Oracle-supplied system.

How easy to migrate an existing pre 12.1 database to 12c Multitenant database ?

Migrate to 12c Pluggable database is very simple and easy. You can evaluate and adopt which one best suit  for you.
Plan A.
  • Upgrade an existing pre 12.1 database to 12.1
  • Plug-in the database post upgrade into a CDB
Plan B.
  • Provision empty PDBs per database that need to consolidated
  • Use datapump or golden gate replication to migrate a Database into a PDB

Which Oracle Database features are currently not supported in a Multitenant architecture ?

The following Oracle Database features are currently not supported in a CDB:
  • Continuous Query Notification
  • Flashback Data Archive
  • Heat Maps
  • Automatic Data Optimization
If you must use one or more of these features, then create a non-CDB.

Basic Multitenant CDB / PDB Operations

How do I know if my database is Multitenant or not ?

Establish a SQL Session and run this Query:
SQL> select NAME, DECODE(CDB, 'YES', 'Multitenant Option enabled', 'Regular 12c Database: ') "Multitenant Option ?" , OPEN_MODE, CON_ID from V$DATABASE;
NAME                        Multitenant Option ?                  OPEN_MODE              CON_ID
---------           ------------------------------           --------------------           ----------
CDB2              Multitenant Option enabled                      MOUNTED                       0

What Pluggable databases do we have in this container database ?

SQL>  select CON_ID, NAME, OPEN_MODE from V$PDBS;
    CON_ID NAME                          OPEN_MODE
---------- ------------------------       ------------
         2 PDB$SEED                         READ ONLY
         3 PDB1                                 MOUNTED
         4 PDB2                                 MOUNTED
         5 PDB3                                 MOUNTED
         6 PDB4                                 MOUNTED
         7 PDB5                                 MOUNTED
         8 PDB6                                 MOUNTED
         9 PDB7                                 MOUNTED
 ...

How do I connect to a Pluggable Database , say, PDB6 ?

SQL> alter session set container = pdb6;

How do I switch to main container Database ?

SQL> ALTER SESSION SET CONTAINER = CDB$ROOT;

How do I determine which PDB or CDB I am currently connected to ?

SQL> show con_name
CON_NAME
------------------------------
PDB6
OR
SQL>  select sys_context ( 'Userenv', 'Con_Name') "Container DB" from dual;
Container DB
--------------------------------------------------------------------------------
PDB6

How do I start up a Pluggable database ?

When connect to current PDB:
SQL> alter pluggable database open;
When connect to root:
SQL> alter pluggable database pdb6 open;

How do I shutdown / close a Pluggable database ?

When connect to current PDB:
SQL> alter pluggable database close;
When connect to root:
SQL> alter pluggable database pdb6 close;

How do I shut down / Startup the Container Database ?

Use startup / Shutdown command similar to startup / shutdown of Non CDB.
When the container database is shutdown  , no PDB is accessible.
In a CDB, the root and all of the PDBs share a single instance, or, when using Oracle RAC, multiple concurrent database instances. You start up and shut down an entire CDB, not individual PDBs. However, when the CDB is open, you can change the open mode of an individual PDB by using the ALTER PLUGGABLE DATABASE statement.

Which parameters are modifiable at PDB level ?

select NAME, ISPDB_MODIFIABLE from V$PARAMETER;

What common users do I have in my cdb ?

SQL> select distinct USERNAME from CDB_USERS where common = 'YES';

How do I create a common user ?

SQL> create user c##db_dba1 identified by manager1 container=all;

How do I create a local user ?

 SQL> create user pdb6_dba1 identified by manager1 container=current; 

Multitenant  Architecture

What is the difference between Container ID Zero and One ?

CON_ID "0" means data does not pertain to any particular Container but to the CDB as a whole. For example, a row returned by fetching from V$DATABASE pertains to the CDB and not to any particular Container, so CON_ID is set to "0".  A CONTAINER_DATA object can conceivably return data pertaining to various Containers (including the Root which has CON_ID==1) as well as to the CDB as a whole, and CON_ID in the row for the CDB will be set to 0.

Following table describes  various values of CON_ID Column in Container Data Objects.
0 = The data pertains to the entire CDB
1=  The data pertains to the root
2= The data pertains to the seed
3 - 254 = The data pertains to a PDB, Each PDB has its own container ID.

Are there any background processes ex, PMON, SMON etc associated with PDBs ?

No. There is one set of background processes shared by the root and all PDBs. 

Are there separate control file required for each PDB ?

No. There is a single redo log and a single control file for an entire CDB.

Are there separate Redo log file required for each PDB ?

No. There is a single redo log and a single control file for an entire CDB.

Can I monitor SGA usage on a PDB by PDB basis?

There are single SGA shared by all pluggable databases. However, you can determine SGA consumptions by all containers i.e, root and PDB.
SQL> alter session set container=CDB$ROOT;
SQL> select POOL, NAME, BYTES from V$SGASTAT where CON_ID = '&con_id';
SQL> select CON_ID, POOL, sum(bytes) from  v$sgastat
group by CON_ID, POOL order by  CON_ID, POOL;

Can I monitor PGA usage on a PDB by PDB basis?


select CON_ID, sum(PGA_USED_MEM), sum(PGA_ALLOC_MEM), sum(PGA_MAX_MEM)
from  v$process
group by CON_ID order by  CON_ID;

alter session set container =CDB$ROOT;
select NAME , value from  v$sysstat  where NAME like 'workarea%';

alter session set container = <targetPDB>;
select NAME , value from  v$sysstat  where NAME like 'workarea%';

Do I need separate UNDO tablespaces for  for each of my PDB ?

There is one active undo tablespace for a single-instance CDB. For an Oracle RAC CDB, there is one active undo tablespace for each instance. Only a common user who has the appropriate privileges and whose current container is the root can create an undo tablespace.

Do I need separate SYSTEM tablespaces for each of my PDB ?

There is a separate SYSTEM  tablespace for the root and for each PDB.

Do I need separate SYSAUX  tablespaces for  for each of my PDB ?

There is a separate SYSAUX tablespace for the root and for each PDB.

Do I need Temporary tablespaces for  for each of my PDB ?

There is one default temporary tablespace for the entire CDB. However, you can create additional temporary tablespaces in individual PDBs. One active undo tablespace is needed for a single-instance CDB, or one active undo tablespace is needed for each instance of an Oracle RAC CDB.

Can I specify a separate default tablespace for the root and for each PDB ?

Yes. You can specify a separate default tablespace for the root and for each PDB

Are all physical datafiles separate for root and PDB?

There are separate datafiles for the root, the seed, and each PDB.
Where is user data stored in CDB ?
In a CDB, most user data is in the PDBs. The root contains no user data or minimal user data.

Does Pluggable database support separate database characterset ? 

A CDB uses a single character set. All of the PDBs in the CDB use this character set.

How do I configure Net Files in a Pluggable database environment ? 

There is a single listener.oratnsnames.ora, and sqlnet.ora file for an entire CDB. All of the PDBs in the CDB use these files.

Advance CDB / PDB Operations

How can I install and setup Pluggable Database ?

Use runInstaller to install the Oracle Database software
Use dbca to create databases. You can create many pluggable databases in a single operation.
DBCA enables you to specify the number of PDBs in the CDB when it is created.After a CDB is created, you can use DBCA to plug PDBs into it and unplug PDBs from it.

What Operations act on PDBs as entities ?

These operations act on PDBs as entities:
• create PDB (brand-new, as a clone of an existing PDB, by plugging in an unplugged PDB)
• unplug PDB
• drop PDB
• set the Open_Mode for a PDB

How can I create a pluggable database ?

create pluggable database x admin user a identified by p;
create pluggable database y admin user a identified by p file_name_convert = ('pdbseed', 'y');

How to drop a PDB irrevocably ?

drop pluggable database x
including datafiles;
How easy is it   to manage the provisioning of PDBs using PL/SQL ?
Following an Example of PL/SQL Code to show this.
-- Using Oracle-Managed Files
declare
t0 integer not null := -1;
procedure Show_Time(What in varchar2) is
t varchar2(10);
begin
t := Lpad((DBMS_Utility.Get_Time() - t0), 5);
DBMS_Output.Put_Line('create PDB:'||t||' centiseconds');
end Show_Time;
begin
t0 := DBMS_Utility.Get_Time();
execute immediate '
create pluggable database x
admin user a identified by p
';
Show_Time('create PDB:');
t0 := DBMS_Utility.Get_Time();
execute immediate '
drop pluggable database x
including datafiles
';
Show_Time('drop PDB: ');
end;

How to clone a PDB from an existing PDB ?

 The clonee must be open in read only mode.
 -- Using Oracle-Managed Files
create pluggable database x2
from x;

How to unplug a PDB ?


alter pluggable database x unplug into '/some_directory/x_description.xml' ;
The into keyword must be followed by the full path for a
description of the PDB, in XML, generated by the operation.

Scalabilty & RAC

How  to add or modify a user-managed service ?

srvctl add service … –pdb <pdb_name>
Starting a user-managed service using
srvtcl will open the PDB automatically in all the instances in which the service is started.
 Specifying the empty string ("") as the <pdb_name> will cause the pluggable database
attribute of a service to be set to null. The service can then be used only to connect to the root.


Diagnosibility

Where can I find Alert log for my pluggable Database ?

A Single copy of Alert log is generated which contains warnings and alert information for all PDBs.
XML version of alert can be found in "Diag Alert" and text formatted Aler log can be found in "Diag Trace" of the container database.
 You can find  details by selecting from v$diag_info dynamic view.

Where can I find trace files related for my pluggable Database ?

All traces generated from all PDBs are currently found in "Diag Trace" of the container database.

 You can find  details by selecting from v$diag_info dynamic view.

**********************************************************************

Comments

  1. Great information, thank you!

    ReplyDelete
  2. It's Really great and it clears almost all my 12C releated admin doubts...great piece of work...

    ReplyDelete
  3. Hi
    A Single copy of Alert log is generated which contains warnings and alert information for all PDB.
    But, how to identified in the alert log, what s te PDB where the error is happen?
    Ex.: I have CDB with PDB: PDBa, PDBb, PDBc...all are identical..but in alert, when errors is happen, not show from what PDB is comming...
    In trace files is posibble with CONTAINER ID value but nothing tehere are iin alert log.
    Is possible know Which PDB having problems in alert log?.
    Sorry for my bad english
    Regads

    ReplyDelete
  4. Very useful, indeed.
    Into my library.

    ReplyDelete

Post a Comment

Oracle DBA Information