Transcript Chapter 1
CHAPTER 23
Pluggable Databases
Oracle Multitenant (Pluggable Databases)
• New with Oracle Database 12c is Oracle Multitenant. This feature
•
•
•
•
•
allows you to create and maintain many pluggable databases within
an overarching multitenant container database.
A multitenant container database (CDB) is defined as a database
capable of housing one or more pluggable databases.
A container is defined as a collection of data files and metadata that
exist within a CDB. A pluggable database is a special type of
container that can be easily provisioned by cloning another database.
If need be, a pluggable database can also be transferred from one
CDB to another.
Every CDB contains a master set of data files and metadata known
as the root container.
Each CDB also contains a seed container, which is used as a
template for creating other pluggable databases. Each CDB consists
of one master root container, one seed container, and zero, or one or
more, pluggable databases.
Pluggable Terms
Container database (CDB), multitenant database
A database capable of housing one or more pluggable databases
Pluggable database, (PDB)
A set of data files and metadata that can be seamlessly transferred
from one CDB to another
Root container
A master set of data files and metadata containing information
regarding all containers within a CDB. The root container is named
CDB$ROOT.
Container
A collection of data files and metadata. Can be root, seed, or a
pluggable database.
Seed pluggable database
A template of data files and metadata used to create new pluggable
databases. The seed pluggable database is named PDB$SEED.
Plugging
Associating the metadata and data files of a pluggable database with a
CDB
Unplugging
Disassociating the metadata and data files of a pluggable database
from a CDB
Cloning
Creating a pluggable database from a copy of another database (seed,
PDB, or non-CDB)
CON_ID
A unique identifier for each container within a CDB. The CDB-level
views contain a CON_ID column that identifies the container with which
the information being viewed is associated.
CDB data dictionary views
Views that contain metadata regarding all pluggable databases within a
CDB. These views only display meaningful information when queried
via a privileged connection from the root container. The pluggable
databases must be open for use.
non-CDB database
An Oracle database created without the pluggable database feature
enabled (the only type of database that was available prior to 12c)
Pluggable Architecture
Paradigm Shift
• Allows DBA to manage many databases as one
• B&R performed as if one database, but have the option of
backup and restore at pluggable level
• Easily provision new databases
• Pluggable can be created from seed, another pluggable,
or a non-CDB database
Containers: Strength in Numbers
• Security
• Granularity
• Synergy
• Provisioning
• Transferability
Creating a CDB: initialization parameters
db_name='CDB'
enable_pluggable_database=true
audit_trail='db'
control_files='/u01/dbfile/CDB/control01.ctl','/u01/dbfile/CDB/cont
rol02.ctl'
db_block_size=8192
db_domain=''
memory_target=629145600
memory_max_target=629145600
open_cursors=300
processes=300
remote_login_passwordfile='EXCLUSIVE'
undo_tablespace='UNDOTBS1'
Create CDB Database Statement
CREATE DATABASE CDB
MAXLOGFILES 16
MAXLOGMEMBERS 4
MAXDATAFILES 1024
MAXINSTANCES 1
MAXLOGHISTORY 680
CHARACTER SET US7ASCII
NATIONAL CHARACTER SET AL16UTF16
DATAFILE
'/u01/dbfile/CDB/system01.dbf' SIZE 500M
EXTENT MANAGEMENT LOCAL
UNDO TABLESPACE undotbs1 DATAFILE
'/u01/dbfile/CDB/undotbs01.dbf' SIZE 800M
SYSAUX DATAFILE
'/u01/dbfile/CDB/sysaux01.dbf' SIZE 500M
DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE
'/u01/dbfile/CDB/temp01.dbf' SIZE 500M
DEFAULT TABLESPACE USERS DATAFILE
'/u01/dbfile/CDB/users01.dbf' SIZE 50M
LOGFILE GROUP 1
('/u01/oraredo/CDB/redo01a.rdo') SIZE 50M,
GROUP 2
('/u01/oraredo/CDB/redo02a.rdo') SIZE 50M
USER sys IDENTIFIED BY foo
USER system IDENTIFIED BY foo
USER_DATA TABLESPACE userstbs DATAFILE
'/u01/dbfile/CDB/userstbsp01.dbf' SIZE 500M
ENABLE PLUGGABLE DATABASE
SEED FILE_NAME_CONVERT = ('/u01/dbfile/CDB','/u01/dbfile/CDB/pdbseed');
Creating a CDB with DBCA
• Set OS variables
dbca -silent -createDatabase -templateName
General_Purpose.dbc -gdbname CDB
-sid CDB -responseFile NO_VALUE -characterSet
AL32UTF8 -memoryPercentage 30
-emConfiguration LOCAL -createAsContainerDatabase true
-sysPassword foo -systemPassword foo
Verifying CDB Details
SQL> select name, cdb from v$database;
SQL> select con_id, name from v$containers;
SQL> select con_id, file_name from cdb_data_files order
by 1;
Tasks Administered from Root Container
• Starting/stopping instance
• Enabling/disabling archive log mode
• Managing instance settings that affect all databases within
•
•
•
•
•
•
the CDB, such as overall memory size
B&R of all data files within the database
Managing control files (adding, restoring, removing, and
so on)
Managing online redo logs
Managing the root UNDO tablespace
Managing the root TEMP tablespace
Creating common users and roles
Displaying Currently Connected Container
SELECT SYS_CONTEXT('USERENV', 'CON_ID') AS
con_id,
SYS_CONTEXT('USERENV', 'CON_NAME') AS
cur_container,
SYS_CONTEXT('USERENV', 'SESSION_USER') AS
cur_user
FROM DUAL;
Common Users and Roles
• Create while connected to SYS root container
• Must use names starting with c##
• Spans all containers
Creating a Pluggable Database
• With the CREATE PLUGGABLE DATABASE statement,
you can use any of the following sources to create a
pluggable database:
• Seed database
• Existing pluggable database (either local or remote)
• Non-CDB database
• Unplugged pluggable database
Managing a Listener in Pluggable
Environment
• Oracle recommends that you create a service (besides
the default service) for each pluggable databases
• Applications should connect to pluggable database via the
manually created service
• Caution: If you have multiple CDB databases on one
server, ensure that the pluggable database service names
are unique across all CDB databases on the server. It’s
not advisable to register two pluggable database
databases with the exact same name with one common
listener. This will lead to confusion as to which pluggable
database you are actually connecting to.
Summary
• New with Oracle Database 12c, a pluggable database is a collection
•
•
•
•
•
of data files and metadata that exist within a CDB. Pluggable
databases have several interesting architectural features:
When connected to a pluggable database, you have no visibility to
other pluggable databases that exist within the CDB. It’s as if you are
connected to an isolated database.
Multiple pluggable databases share common database resources
(memory structures, background processes, and so on) within the
CDB. From the root container level, you can manage many DBA
databases as if they were one database.
You can shut down a pluggable database without affecting other
pluggable databases within the CDB.
New pluggable databases can be quickly created by cloning the seed
database, an existing pluggable database, or a non-CDB.
Pluggable databases can be easily transferred from one CDB to
another by unplugging from one CDB and plugging the pluggable
database into another CDB.