SlideShare a Scribd company logo
1
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Exploring Oracle Database 12c
Multitenant Best Practices
for your Cloud
Ami Aharonovich
Oracle ACE & OCP
Ami@Brillix.co.il
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.2
About Me
 Oracle ACE
 Oracle Certified Professional DBA (OCP)
 Founder and CEO, DBAces
 President, Israel Oracle User Group
 Oracle DBA consultant and instructor, dealing with
Oracle database core technologies
 Frequent speaker at Oracle Open World annual event
and various user group conferences around the globe
2
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.3
About Brillix-DBAces
We are committed to provide the highest quality of services
delivered by our dedicated team of industry’s top experts.
We offer:
 Complete end-to-end solutions based on best-of-breed
innovations in database, security and big data technologies
 On-site professional customized trainings led by our team of
Oracle ACEs and Oracle Certified Professionals
 Comprehensive security solutions and services for leading
database platforms and business applications, leveraging a
world-class team of security experts
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.4
Our Customers
3
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.5
Database (Storage Structures)
Oracle Database in 11g Release 2
Server
Database
Instance
System Global Area
Process Structures
Instance
Multiple non-CDBs share nothing:
• Too many background processes
• High shared/process memory
• Many copies of Oracle metadata
Pre-12c
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.6
Multitenant Container Database
Instance
System Global Area
Process Structures
Server
Single Instance
Multitenant
container
database
root
Data files Redo Log filesControl files
Application1
Data files
SALES
Data files
Single DB shares:
• Background
processes
• Shared/process
memory
• Oracle metadata
HR
Data files
Multitenant Container Database CDB
4
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.7
Separating SYSTEM and User Data
…
OBJ$ TAB$ SOURCE$
…
EMP DEPT
User metadata only User Data
…
OBJ$ TAB$ SOURCE$
Oracle metadata only
Multitenant
Container Database
Container
for
system
Container for application
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.8
Provisioning a Pluggable Database
Seed
PDB
New
empty
PDB
Imagine this
when the data files
are on a file system
that supports
copy-on-change.
root
Different methods:
• Create new PDB from PDB$SEED pluggable database.
• Plug in a non-CDB.
• Clone a non-CDB into a CDB, or a PDB into the same or
another CDB.
• Plug an unplugged PDB into a CDB.
Multitenant Container Database
5
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.9
Interacting Within Multitenant Container Database
PDB_1 PDB_2 PDB_n
fast intra-CDB db link
root
Multitenant Container Database
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.10
Multitenant Container Database Architecture
Instance
System Global Area
Process Structures
Server
Instance
Multitenant
container
database
root container
Data files Redo Log
files
Control files
UNDO
TEMP
SYSTEM
SYSAUX
seed PDB
Data files
SYSTEM
SYSAUX
SALES PDB
SYSTEM
SYSAUX TBS2
HR PDB
Data files
TEMP1
Data files
TEMP2
PDBid2 PDBid3 PDBid4 PDBid2 PDBid4
Single DB shares:
• Background
processes
• Shared/process
memory
• Oracle metadata
• Redo log files
• Control files
• Undo tablespace
6
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.11
Containers
Two types of containers in V$CONTAINERS:
• The root container:
– The first container created at CDB creation
– Mandatory
– Oracle system-supplied common objects and metadata
– Oracle system-supplied common users and roles
• Pluggable database containers (PDBs):
– A container for an application:
— Tablespaces (permanent and temporary)
— Schemas / objects / privileges
— Created / cloned / unplugged / plugged
– Particular seed PDB:
— PDB$SEED provides fast provisioning of a new PDB
– Limit of 253 PDBs in a CDB including the seed
– Limit of 1024 services in a CDB
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.12
Questions: Root Versus PDBs
What belongs to the CDB and not to a specific container?
• Control files and redo log files
What is in the root that is not in PDBs?
• UNDO tablespace (for each instance)
• System-supplied metadata
• Shared Oracle-supplied data
– PL/SQL Oracle-supplied packages
(DBMS_SQL …)
– PDBs service names
• CDB dictionary views providing information
across PDBs
• CDB Resource Manager plan
UNDO
NAME
PDB_SALES
PDB_HR
TABLE_NAME CON_ID
EMPLOYEES 1
TEST 2
Views CDB_xxx
NAME TYPE
TAB$ 2
USER$ 2
Table SYS.OBJ$
Table SYS.SERVICE$
CDBA
7
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.13
Questions: PDBs Versus Root
What is in a PDB that is not in the root nor in another PDB?
• Application tablespaces
• Local temporary tablespaces
• Local users and local roles
– Local users connect to the PDB where they exist.
• Non-shared local metadata
• Non-shared application data with other PDBs
• PDB Resource Manager plan
HR_TBS
TEMP1
EMP_NAME
SMITH
JOHNTable HR.EMPLOYEES
NAME TYPE
EMPLOYEES 2
JOBS 2
Table SYS.OBJ$
PDBA
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.14
Common and Local Users
Multitenant Container Database
root
PDB_HR
PDB_SALES
Table
HR.REGIONS
USERNAME COMMON
SYS YES
SYSTEM YES
C##DBA YES
C##HR YES
View CDB_USERS
Adding a common user involves adding a
description of that user in the root and in
every PDB.
A local user is a traditional user, known only
in its own PDB.
View DBA_USERS
USERNAME COMMON
SYS YES
SYSTEM YES
C##DBA YES
C##HR YES
SALES NO
USERNAME COMMON
SYS YES
SYSTEM YES
C##DBA YES
C##HR YES
HR_MGR NO
View DBA_USERS
Table
SALES.COUNTRIES
Tablespace
EXAMPLE
Tablespace
EXAMPLE
Tablespace
EXAMPLE
8
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.15
Common and Local Privileges and Roles
Multitenant Container Database
root
PDB_HR
Common users Local users
Common Priv (granted commonly)
Local Priv (granted locally)
Common roles
Local roles
SQL> GRANT c##_r1 TO C##DBA
CONTAINER=ALL;
SQL> GRANT l_priv TO C##DBA
CONTAINER=CURRENT;
Common privilege
Local privilege
Common Role (granted commonly)
Common Role (granted locally)
COMMON role LOCAL role
X
LOCAL role COMMON role
X
Priv/role granted locally
Priv/role granted commonlyX
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.16
CDB_xxx All objects in the multitenant container database across all PDBs
USER_xxx Objects owned by the current user
ALL_xxx Objects accessible by the current user
DBA_xxx All of the objects in a container or pluggable database
Data Dictionary Views
• CDB_pdbs: All PDBS within CDB
• CDB_tablespaces: All tablespaces within CDB
• CDB_users: All users within CDB (common and local)
DBA dictionary views providing information within PDB:
SQL> SELECT view_name FROM dba_views WHERE view_name like 'CDB%';
SQL> SELECT table_name FROM dict WHERE table_name like 'DBA%';
9
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.17
Impacts
• One character set for all PDBs (Unicode recommended)
• PDB initialization parameters but a single SPFILE
• No PDB qualified database object names
– SELECT * FROM HR:apps.tab1
– Use DB Links: SELECT * FROM apps.tab1@HR
• Oracle Data Guard at CDB level
• Oracle Database Vault per PDB only
• One master key per PDB to encrypt PDB data
• Unified audit both at CDB and PDB levels
• Oracle Scheduler
• Oracle GoldenGate
• Oracle Streams
• Oracle XStream both at CDB and PDB levels
Impacts
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.18
SQL*Plus OUI DBCA
EM
Cloud
Control
EM
Database
Express
SQL
Developer
DBUA
Create a
new CDB or
PDB
Yes Yes Yes
Yes
(PDB only)
Yes
(PDB only)
Yes
(PDB only)
Explore
CDB
instance,
architecture
and PDBs
Yes Yes Yes Yes
Upgrade a
12.1 CDB
to 12.x CDB
Yes Yes
Tools
10
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.19
Instance
SGA
Process Structures
Instance
Container
Database
CDB1
root container
seed pluggable database
Steps to Create a Container Database
2
1
Container Database CDB1
Datafiles
Control
files
UNDOSYSTEM
SYSAUX
Redo Log
files
SYSTEM
TEMP1
TEMP
SYSAUX
initCDB1.ora
3
4
Execute scripts from root
catcdb.sql
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.20
Creating a Container Database: Using SQL*Plus
1. Instance startup:
a. Set ORACLE_SID=CDB1
b. Set in initCDB1.ora:
– Set CONTROL_FILES to CDB control file names.
– Set DB_NAME to CDB name.
– Set ENABLE_PLUGGABLE_DATABASE to TRUE.
2. Create the database:
– CDB$ROOT container
– PDB$SEED pluggable database
3. Run the catcdb.sql script.
SQL> CONNECT / AS SYSDBA
SQL> STARTUP NOMOUNT
SQL> CREATE DATABASE CDB1 ENABLE PLUGGABLE DATABASE …
SEED FILE_NAME_CONVERT ('/oracle/dbs','/oracle/seed');
11
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.21
Creating a Container Database: Using DBCA
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.22
After CDB Creation: What Is New in CDBs
A CDB has new characteristics compared to non-CDBs:
• Two containers:
– The root (CDB$ROOT)
– The seed PDB (PDB$SEED)
• Several services: One per container
– Name of root service = name of the CDB (cdb1)
• Common users in root and seed: SYS,SYSTEM …
• Common privileges granted to common users
• Pre-defined common roles
• Tablespaces and data files associated to each container:
– root: SYSTEM (system-supplied metadata and no user data),
SYSAUX, TEMP
– seed: SYSTEM, SYSAUX , TEMP
12
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.23
USER_xxx Objects owned by the current user in a PDB
ALL_xxx Objects accessible by the current user in a PDB
DBA_xxx All of the objects in the root or a pluggable database
Data Dictionary Views: DBA_xxx
DBA dictionary views providing information within PDB:
• DBA_tablespaces: All tablespaces of the PDB
• DBA_data_files: All data files of the PDB
• DBA_tables: All tables in the PDB
• DBA_users: All common and local users of the PDB
SQL> SELECT table_name FROM dict WHERE table_name like 'DBA%';
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.24
CDB_xxx All of the objects in the container database (new column CON_ID)
USER_xxx Objects owned by the current user in a PDB
ALL_xxx Objects accessible by the current user in a PDB
DBA_xxx All of the objects in the root or a pluggable database
Data Dictionary Views: CDB_xxx
CDB dictionary views provide information across PDBs:
• CDB_pdbs: All PDBS within the CDB
• CDB_tablespaces: All tablespaces within the CDB
• CDB_data_files: All data files within the CDB
• CDB_users: All users within the CDB (common and local)
SQL> SELECT view_name FROM dba_views WHERE view_name like 'CDB%';
13
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.25
Data Dictionary Views: Examples
• Comparisons:
• Access to data in V$ or GV$ views showing data from
multiple PDBs can be secured using privilege.
SQL> SELECT name, open_mode FROM v$pdbs;
NAME OPEN_MODE
---------------- ----------
PDB$SEED READ ONLY
PDB1 READ WRITE
PDB2 READ WRITE
SQL> CONNECT / AS SYSDBA
SQL> SELECT role, common, con_id FROM cdb_roles;
SQL> SELECT role, common FROM dba_roles;
1
2
SQL> CONNECT sys@PDB1 AS SYSDBA
SQL> SELECT role, common, con_id FROM cdb_roles;
SQL> SELECT role, common FROM dba_roles;
3
4
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.26
After CDB Creation: To-Do List
After CDB creation, the CDBA has to:
• Set a separate default tablespace for the root and for each
PDB
• Set a default temporary tablespace for each container
• Start the listener
• Plug non-CDBs
• Test startup/shutdown procedures
• Define default PDB state to automate PDBs opening
• Create backup and recovery procedures
12.1.0.2
14
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.27
Provisioning New Pluggable Databases
Different methods:
• Create a new PDB from the seed PDB.
• Plug or clone a non-CDB into a CDB.
• Clone:
– A local PDB into the same CDB
– A remote PDB into a CDB
• Plug an unplugged PDB into another CDB.
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.28
Tools
To provision new PDBs, you can use:
• SQL*Plus
• SQL Developer
• Enterprise Manager Cloud Control
• Enterprise Manager Database Express
• DBCA
– Copy from seed
– By unplugging/plugging method
15
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.29
Method 1: Create New PDB from PDB$SEED
Container Database CDB1
root
Data files/
Tempfiles
Redo Log
files
Control
files
UNDO
TEMP
PDB$SEED
Data files
PDB1
Data files
Create
PDB1
from
PDB$SEED
• Copies the data files from
PDB$SEED data files
• Creates SYSTEM and SYSAUX
tablespaces
• Creates a full catalog including
metadata pointing to Oracle-
supplied objects
• Creates a temporary tablespace,
TEMP
• Creates common users:
– Superuser SYS
– SYSTEM
• Creates a local user (PDBA)
granted local PDB_DBA role
• Creates a new default service
TEMP
SYSAUX
SYSTEM
SYSTEM
USERS
SYSAUX
SYSAUX
SYSTEM
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.30
Steps: With Location Clauses
Connect to the root as a common user with the CREATE
PLUGGABLE DATABASE privilege:
• Use FILE_NAME_CONVERT:
• Use CREATE_FILE_DEST:
• Use views to verify:
SQL> CREATE PLUGGABLE DATABASE pdb1
ADMIN USER admin1 IDENTIFIED BY p1 ROLES=(CONNECT)
FILE_NAME_CONVERT = ('PDB$SEEDdir', 'PDB1dir');
SQL> CONNECT / AS SYSDBA
SQL> SELECT * FROM cdb_pdbs;
SQL> SELECT * FROM cdb_tablespaces;
SQL> SELECT * FROM cdb_data_files;
SQL> CONNECT sys@pdb1 AS SYSDBA
SQL> CONNECT admin1@pdb1
SQL> CREATE PLUGGABLE DATABASE pdb2
ADMIN USER admin2 IDENTIFIED BY p2 ROLES=(CONNECT)
CREATE_FILE_DEST = 'PDB2dir';
12.1.0.2
16
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.31
Synchronization
• If the PDB is in MOUNTED or READ-ONLY mode
• If customer-created common users or roles are created /
modified / dropped
→The PDB needs to be resynchronized with the root.
– Open the PDB in READ-WRITE mode to synchronize the
PDB with the target CDB.
– If you open the PDB in READ-ONLY mode, an error is
returned.
→A compatibility check is automatically performed:
– Any violation is reported in the PDB_PLUG_IN_VIOLATIONS
view.
– If there is no violation, the PDB status is changed to
NORMAL.
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.32
Method 2: Plug a Non-CDB into a CDB
Three possible methods:
• TTS or TDB or full export/import
• XML file definition with DBMS_PDB
• Replication
Entities are created in the new PDB:
• Tablespaces: SYSTEM, SYSAUX,
TEMP
• A full catalog
• Common users: SYS, SYSTEM
• A local administrator (PDBA)
• A new default service
Container Database CDB1
root
Data files/
Temp files
Redo Log
files
Control
files
PDB$SEED
Data files / Temp files
Create
PDB2
from
ORCL
ORCL
Data files Control
files
Redo Log
files
Dump file
PDB2
Data files
impdp TTS
12.1
expdp TTS
ReplicationXML file
DBMS_PDB
Plug
17
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.33
Plug a Non-CDB in to CDB Using DBMS_PDB
Container Database CDB1
root
Data files/
Temp files
Redo Log
files
Control
files
PDB$SEED
PDB2
Data files
Create
PDB2
from
ORCL
DBMS_PDB.DESCRIBE
Plug
XML metadata file
1. Open ORCL in READ ONLY mode.
2.
3. Connect to the target CDB1 CDB as a
common user with CREATE PLUGGABLE
DATABASE privilege.
4. Plug in the unplugged ORCL as PDB2.
5. Run the noncdb_to_pdb.sql script.
6. Open PDB2.
SQL> CREATE PLUGGABLE DATABASE
PDB2 USING '/tmp/ORCL.xml';
SQL> EXEC DBMS_PDB.DESCRIBE
('/tmp/ORCL.xml')
SQL> CONNECT sys@PDB2 AS SYSDBA
SQL> @$ORACLE_HOME/rdbms/admin/noncdb_to_pdb
Data files / Tempfiles
ORCL
Datafiles Control
files
Redo Log
files
12.1
SQL> ALTER PLUGGABLE DATABASE
PDB2 OPEN;
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.34
Method 3: Clone Local PDBs
Container Database CDB1
root
Data files/
Temp files
Redo Log
files
Control
files
PDB$SEED
Data files / Temp files
PDB1
Data files
Create
PDB3
from
PDB1
1. Set the DB_CREATE_FILE_DEST or
DB_FILE_NAME_CONVERT instance
parameter or
use the CREATE_FILE_DEST clause.
2. Connect to the root.
3. Quiesce PDB1:
4. Clone PDB3 from PDB1:
5. Open PDB3 in read-write mode.
6. Reopen PDB1.
PDB3
Data files
PDB3 owns:
• SYSTEM, SYSAUX tablespaces
• Full catalog
• A temporary tablespace
• SYS, SYSTEM common users
• Same local administrator name
• New service name
SQL> ALTER PLUGGABLE DATABASE
pdb1 CLOSE;
SQL> ALTER PLUGGABLE DATABASE
pdb1 OPEN READ ONLY;
SQL> CREATE PLUGGABLE DATABASE
pdb3 FROM pdb1;
SQL> ALTER PLUGGABLE DATABASE
pdb3 OPEN;
12.1.0.2
18
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.35
Method 4: Plug Unplugged PDB in to CDB
Unplug PDB1 from CDB1:
1. Connect to CDB1 as a common user.
2. Verify that PDB1 is closed.
3.
4. Optionally, drop PDB1 from CDB1.
Plug PDB1 in to CDB2:
1. Connect to CDB2 as a common user.
2. Use DBMS_PDB package to check the
compatibility of PDB1 with CDB2.
3.
4. Open PDB1 in read-write mode.
Container Database CDB1
root
PDB$SEED
PDB1
Data files
XML file
USERS
Unplug PDB1
Container Database CDB2
root
PDB$SEED
PDB1
Data files
Plug PDB1
SQL> ALTER PLUGGABLE DATABASE
pdb1 UNPLUG INTO
'xmlfile1.xml';
SQL> CREATE PLUGGABLE DATABASE
pdb1 USING 'xmlfile1.xml'
NOCOPY;
SYSAUX
SYSTEM
USERSSYSAUX
SYSTEM
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.36
Method 4: Flow
Are new PDB files based on
same files that were used to
create existing PDB in CDB?
If not, AS CLONE clause is required and so, it ensures
that Oracle Database generates unique PDB DBID,
GUID, and other identifiers expected for the new PDB.
XML file accurately describes
current locations of files?
Are files in correct location?
Do you want to specify
storage limits for PDB?
If not, the SOURCE_FILE_NAME_CONVERT clause is
required.
If not, specify COPY to copy files to new location or MOVE
to move them to another location.
If yes, use NOCOPY. COPY as the default.
If yes, specify the STORAGE clause.
• FILE_NAME_CONVERT or CREATE_FILE_DEST
clauses of CREATE PLUGGABLE DATABASE statement
• Instances DB_CREATE_FILE_DEST or
PDB_FILE_NAME_CONVERT parameters
Several clauses can be used in conjunction:
19
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.37
Plug Sample Schemas PDB: Using DBCA
1
2
3
4
Plug a new PDB with
Sample Schemas
using a PDB File Set
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.38
Dropping a PDB
Container Database CDB1
root
Data files/
Temp files
Redo Log
files
Control
files
File2
TEMP
PDB$SEED
Data files
File5
File6 File7
File4
File1
File3
PDB1
Data files
File8 Drop PDB1
• Updates control files
• If INCLUDING DATAFILES:
– Removes PDB1 datafiles
• If KEEP DATAFILES (default):
– Retain data files
– Can be plugged in another or
the same CDB
• Requires SYSDBA privilege
• Cannot drop seed PDB
File9 File10
PDB4
Data files
SQL> ALTER PLUGGABLE DATABASE
pdb1 CLOSE;
SQL> DROP PLUGGABLE DATABASE
pdb1 [INCLUDING DATAFILES];…
File7
File8
File9
File10
…
20
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.39
Migrating pre-12.1 Databases to 12.1 CDB
There are two methods:
1. Upgrade an existing pre-12.1
database to 12c.
2. Plug-in non-CDB into a CDB.
Or
1. Pre-create a PDB in CDB.
2. Use 11g expdp / 12c impdp
or replication between non-CDB
and PDB.
CDB CDB1
root
Data files/
Temp files
Redo Log
files
Control
files
ORCL
Data files Control
files
Redo Log
files
expdp
Dump file
PDB1
Data files
impdp
ORCL
Data files Control
files
Redo Log
files
1
2
11g
12c
Replication XML file
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.40
MOUNT
NOMOUNT
SHUTDOWN
Instance
started
– CDB control files opened for
the instance
– Root mounted
– PDBs mounted
– Root opened
– PDBs still mounted,
except seed in RO
OPEN
SQL> STARTUP
SQL> ALTER DATABASE cdb1 OPEN;
Or
SQL> SELECT name,open_mode
2 FROM v$pdbs;
NAME OPEN_MODE
---------------- ----------
PDB$SEED READ ONLY
PDB1 MOUNTED
PDB2 MOUNTED
Opening a CDB
21
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.41
OPEN
MOUNT
NOMOUNT
SHUTDOWN
Instance
started
– CDB control files opened for the
instance
– Root mounted
– PDBs mounted
– Root opened
– PDBs still mounted,
except seed in RO
PDB OPEN
PDBs opened RW,
except seed in RO
SQL> CONNECT sys@CDB1 AS SYSDBA
SQL> ALTER PLUGGABLE DATABASE pdb1 OPEN;
SQL> ALTER PLUGGABLE DATABASE ALL OPEN;
Or
SQL> SELECT name,open_mode
2 FROM v$pdbs;
NAME OPEN_MODE
---------------- ----------
PDB$SEED READ ONLY
PDB1 READ WRITE
PDB2 READ WRITE
Opening a PDB
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.42
CDB OPEN
MOUNT
NOMOUNT
SHUTDOWN
Instance
started
– CDB control files opened for the instance
– Root mounted
– PDBs mounted
– Root opened
– PDBs mounted, except
seed still RO
PDB CLOSE
PDBs closed
SQL> CONNECT / AS SYSDBA
SQL> ALTER PLUGGABLE DATABASE pdb1
CLOSE IMMEDIATE;
SQL> ALTER PLUGGABLE DATABASE
ALL EXCEPT pdb1 CLOSE;
SQL> ALTER PLUGGABLE DATABASE
ALL CLOSE;
SQL> CONNECT sys@pdb1 AS SYSDBA
SQL> ALTER PLUGGABLE DATABASE CLOSE;
Or
SQL> SHUTDOWN IMMEDIATE;
Closing a PDB
22
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.43
SQL> CONNECT sys@CDB1 AS SYSDBA
SQL> SHUTDOWN IMMEDIATE
Shutting Down a CDB Instance
• All PDBs closed (no new specific message)
• CDB closed
• CDB dismounted
• Instance shut down
• PDB closed
SQL> CONNECT sys@PDB1 AS SYSDBA
SQL> SHUTDOWN IMMEDIATE
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Exploring Oracle Database 12c
Multitenant Best Practices
for your Cloud
Ami Aharonovich
Oracle ACE & OCP
Ami@Brillix.co.il

More Related Content

PDF
Amazon OpenSearch Deep dive - 내부구조, 성능최적화 그리고 스케일링
PDF
Designing Apache Hudi for Incremental Processing With Vinoth Chandar and Etha...
PDF
[OpenInfra Days Korea 2018] Day 1 - T4-7: "Ceph 스토리지, PaaS로 서비스 운영하기"
PDF
Oracle RAC - New Generation
PDF
Oracle Active Data Guard: Best Practices and New Features Deep Dive
PDF
The Top 5 Reasons to Deploy Your Applications on Oracle RAC
PDF
AWS CLOUD 2018- Amazon DynamoDB기반 글로벌 서비스 개발 방법 (김준형 솔루션즈 아키텍트)
PDF
AWS Black Belt Online Seminar 2017 AWS X-Ray
Amazon OpenSearch Deep dive - 내부구조, 성능최적화 그리고 스케일링
Designing Apache Hudi for Incremental Processing With Vinoth Chandar and Etha...
[OpenInfra Days Korea 2018] Day 1 - T4-7: "Ceph 스토리지, PaaS로 서비스 운영하기"
Oracle RAC - New Generation
Oracle Active Data Guard: Best Practices and New Features Deep Dive
The Top 5 Reasons to Deploy Your Applications on Oracle RAC
AWS CLOUD 2018- Amazon DynamoDB기반 글로벌 서비스 개발 방법 (김준형 솔루션즈 아키텍트)
AWS Black Belt Online Seminar 2017 AWS X-Ray

What's hot (20)

PDF
How To Model and Construct Graphs with Oracle Database (AskTOM Office Hours p...
PPTX
Anil nair rac_internals_sangam_2016
PDF
Achieving Continuous Availability for Your Applications with Oracle MAA
PPTX
Sun Oracle Exadata Technical Overview V1
PDF
Barman (PostgreSql) manual
PDF
Oracle RAC 19c: Best Practices and Secret Internals
PPTX
Optimize DR and Cloning with Logical Hostnames in Oracle E-Business Suite (OA...
PDF
Oracle RAC 19c with Standard Edition (SE) 2 - Support Update
PDF
Amazon DynamoDB(初心者向け 超速マスター編)JAWSUG大阪
PDF
[Keynote] 슬기로운 AWS 데이터베이스 선택하기 - 발표자: 강민석, Korea Database SA Manager, WWSO, A...
PDF
Understanding Oracle RAC 11g Release 2 Internals
PDF
スキーマレスカラムナフォーマット「Yosegi」で実現する スキーマの柔軟性と処理性能を両立したログ収集システム / Hadoop / Spark Con...
PDF
Amazon Aurora Deep Dive (김기완) - AWS DB Day
PDF
202201 AWS Black Belt Online Seminar Apache Spark Performnace Tuning for AWS ...
PPTX
Dell emc back up solution in azure cloud
PDF
SK Telecom - 망관리 프로젝트 TANGO의 오픈소스 데이터베이스 전환 여정 - 발표자 : 박승전, Project Manager, ...
PDF
VLDB 2009 Tutorial on Column-Stores
PDF
Oracle RAC 12c (12.1.0.2) Operational Best Practices - A result of true colla...
PDF
Hadoop and Kerberos
PDF
Oracle RAC Internals - The Cache Fusion Edition
How To Model and Construct Graphs with Oracle Database (AskTOM Office Hours p...
Anil nair rac_internals_sangam_2016
Achieving Continuous Availability for Your Applications with Oracle MAA
Sun Oracle Exadata Technical Overview V1
Barman (PostgreSql) manual
Oracle RAC 19c: Best Practices and Secret Internals
Optimize DR and Cloning with Logical Hostnames in Oracle E-Business Suite (OA...
Oracle RAC 19c with Standard Edition (SE) 2 - Support Update
Amazon DynamoDB(初心者向け 超速マスター編)JAWSUG大阪
[Keynote] 슬기로운 AWS 데이터베이스 선택하기 - 발표자: 강민석, Korea Database SA Manager, WWSO, A...
Understanding Oracle RAC 11g Release 2 Internals
スキーマレスカラムナフォーマット「Yosegi」で実現する スキーマの柔軟性と処理性能を両立したログ収集システム / Hadoop / Spark Con...
Amazon Aurora Deep Dive (김기완) - AWS DB Day
202201 AWS Black Belt Online Seminar Apache Spark Performnace Tuning for AWS ...
Dell emc back up solution in azure cloud
SK Telecom - 망관리 프로젝트 TANGO의 오픈소스 데이터베이스 전환 여정 - 발표자 : 박승전, Project Manager, ...
VLDB 2009 Tutorial on Column-Stores
Oracle RAC 12c (12.1.0.2) Operational Best Practices - A result of true colla...
Hadoop and Kerberos
Oracle RAC Internals - The Cache Fusion Edition
Ad

Viewers also liked (20)

PDF
Oracle Database 12c Multitenant for Consolidation
PDF
Oracle 12c and its pluggable databases
PPTX
Oracle 12c Multi Tenant
PPTX
Oracle 12c Architecture
PPTX
Best New Features of Oracle Database 12c
PDF
Oracle 12c Multitenant architecture
PDF
Exploring Oracle Multitenant in Oracle Database 12c
PPSX
Oracle database 12c new features
PPTX
DB Forum 2012 - EM12c & DBaaS
PPTX
Ensuring Data Protection Using Oracle Flashback Features - Presentation
PPTX
Simplify Consolidation with Oracle Pluggable Databases
PPTX
EM12c - Chargeback
PPTX
Simplify Consolidation with Oracle Database 12c
PPTX
Webséminaire DBaaS (Novembre 2014)
PPTX
Introduction to Oracle Data Guard Broker
PPTX
Oracle Database 12c Feature Support in Oracle SQL Developer
PDF
Oracle 12c PDB insights
PPTX
Exadata x4 for_sap
PPTX
Oracle 12c - Multitenant Feature
PDF
Cosas que “probablemente” no sabes pero deberías de saber en Oracle 12c
Oracle Database 12c Multitenant for Consolidation
Oracle 12c and its pluggable databases
Oracle 12c Multi Tenant
Oracle 12c Architecture
Best New Features of Oracle Database 12c
Oracle 12c Multitenant architecture
Exploring Oracle Multitenant in Oracle Database 12c
Oracle database 12c new features
DB Forum 2012 - EM12c & DBaaS
Ensuring Data Protection Using Oracle Flashback Features - Presentation
Simplify Consolidation with Oracle Pluggable Databases
EM12c - Chargeback
Simplify Consolidation with Oracle Database 12c
Webséminaire DBaaS (Novembre 2014)
Introduction to Oracle Data Guard Broker
Oracle Database 12c Feature Support in Oracle SQL Developer
Oracle 12c PDB insights
Exadata x4 for_sap
Oracle 12c - Multitenant Feature
Cosas que “probablemente” no sabes pero deberías de saber en Oracle 12c
Ad

Similar to Exploring Oracle Database 12c Multitenant best practices for your Cloud (20)

PPT
173955573244324324324424322adsadsaasd.ppt
PDF
Cdb part i
PPTX
Presentation day1oracle 12c
PDF
Security Multitenant
PDF
Oracle database 12c introduction- Satyendra Pasalapudi
PDF
Multitenant Full Deck Jan 2015 Cloud Team AJ Linkedin
PPTX
apex-42-in-12c-1970039.pptx apex oracle
PPTX
Oracle Multitenant in 50 minutes
PDF
Consolidate and prepare for cloud efficiencies
PPTX
2-day-dba-oracle.pptx
PDF
Oracle_Multitenant_19c_-_All_About_Pluggable_D.pdf
PDF
Migration to Oracle Multitenant
PDF
Under The Hood of Pluggable Databases by Alex Gorbachev, Pythian, Oracle OpeW...
PPTX
Using oracle12c pluggable databases to archive
PPTX
Oracle Database 12c para la comunidad GeneXus - Engineered for clouds
PPTX
TechEvent 18c Multitenant New Features
PDF
Gloc gangler 2018._v4
PDF
Plugging in oracle database 12c pluggable databases
PPTX
Presentation day5 oracle12c
PDF
Oracle Application Containers
173955573244324324324424322adsadsaasd.ppt
Cdb part i
Presentation day1oracle 12c
Security Multitenant
Oracle database 12c introduction- Satyendra Pasalapudi
Multitenant Full Deck Jan 2015 Cloud Team AJ Linkedin
apex-42-in-12c-1970039.pptx apex oracle
Oracle Multitenant in 50 minutes
Consolidate and prepare for cloud efficiencies
2-day-dba-oracle.pptx
Oracle_Multitenant_19c_-_All_About_Pluggable_D.pdf
Migration to Oracle Multitenant
Under The Hood of Pluggable Databases by Alex Gorbachev, Pythian, Oracle OpeW...
Using oracle12c pluggable databases to archive
Oracle Database 12c para la comunidad GeneXus - Engineered for clouds
TechEvent 18c Multitenant New Features
Gloc gangler 2018._v4
Plugging in oracle database 12c pluggable databases
Presentation day5 oracle12c
Oracle Application Containers

Recently uploaded (20)

PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPT
Teaching material agriculture food technology
PDF
A comparative analysis of optical character recognition models for extracting...
PPTX
Machine Learning_overview_presentation.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Approach and Philosophy of On baking technology
PPTX
Big Data Technologies - Introduction.pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Assigned Numbers - 2025 - Bluetooth® Document
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Teaching material agriculture food technology
A comparative analysis of optical character recognition models for extracting...
Machine Learning_overview_presentation.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
Encapsulation_ Review paper, used for researhc scholars
The AUB Centre for AI in Media Proposal.docx
20250228 LYD VKU AI Blended-Learning.pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Approach and Philosophy of On baking technology
Big Data Technologies - Introduction.pptx
Digital-Transformation-Roadmap-for-Companies.pptx
Unlocking AI with Model Context Protocol (MCP)
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
Chapter 3 Spatial Domain Image Processing.pdf
Assigned Numbers - 2025 - Bluetooth® Document

Exploring Oracle Database 12c Multitenant best practices for your Cloud

  • 1. 1 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Exploring Oracle Database 12c Multitenant Best Practices for your Cloud Ami Aharonovich Oracle ACE & OCP [email protected] Copyright © 2014, Oracle and/or its affiliates. All rights reserved.2 About Me  Oracle ACE  Oracle Certified Professional DBA (OCP)  Founder and CEO, DBAces  President, Israel Oracle User Group  Oracle DBA consultant and instructor, dealing with Oracle database core technologies  Frequent speaker at Oracle Open World annual event and various user group conferences around the globe
  • 2. 2 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.3 About Brillix-DBAces We are committed to provide the highest quality of services delivered by our dedicated team of industry’s top experts. We offer:  Complete end-to-end solutions based on best-of-breed innovations in database, security and big data technologies  On-site professional customized trainings led by our team of Oracle ACEs and Oracle Certified Professionals  Comprehensive security solutions and services for leading database platforms and business applications, leveraging a world-class team of security experts Copyright © 2014, Oracle and/or its affiliates. All rights reserved.4 Our Customers
  • 3. 3 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.5 Database (Storage Structures) Oracle Database in 11g Release 2 Server Database Instance System Global Area Process Structures Instance Multiple non-CDBs share nothing: • Too many background processes • High shared/process memory • Many copies of Oracle metadata Pre-12c Copyright © 2014, Oracle and/or its affiliates. All rights reserved.6 Multitenant Container Database Instance System Global Area Process Structures Server Single Instance Multitenant container database root Data files Redo Log filesControl files Application1 Data files SALES Data files Single DB shares: • Background processes • Shared/process memory • Oracle metadata HR Data files Multitenant Container Database CDB
  • 4. 4 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.7 Separating SYSTEM and User Data … OBJ$ TAB$ SOURCE$ … EMP DEPT User metadata only User Data … OBJ$ TAB$ SOURCE$ Oracle metadata only Multitenant Container Database Container for system Container for application Copyright © 2014, Oracle and/or its affiliates. All rights reserved.8 Provisioning a Pluggable Database Seed PDB New empty PDB Imagine this when the data files are on a file system that supports copy-on-change. root Different methods: • Create new PDB from PDB$SEED pluggable database. • Plug in a non-CDB. • Clone a non-CDB into a CDB, or a PDB into the same or another CDB. • Plug an unplugged PDB into a CDB. Multitenant Container Database
  • 5. 5 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.9 Interacting Within Multitenant Container Database PDB_1 PDB_2 PDB_n fast intra-CDB db link root Multitenant Container Database Copyright © 2014, Oracle and/or its affiliates. All rights reserved.10 Multitenant Container Database Architecture Instance System Global Area Process Structures Server Instance Multitenant container database root container Data files Redo Log files Control files UNDO TEMP SYSTEM SYSAUX seed PDB Data files SYSTEM SYSAUX SALES PDB SYSTEM SYSAUX TBS2 HR PDB Data files TEMP1 Data files TEMP2 PDBid2 PDBid3 PDBid4 PDBid2 PDBid4 Single DB shares: • Background processes • Shared/process memory • Oracle metadata • Redo log files • Control files • Undo tablespace
  • 6. 6 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.11 Containers Two types of containers in V$CONTAINERS: • The root container: – The first container created at CDB creation – Mandatory – Oracle system-supplied common objects and metadata – Oracle system-supplied common users and roles • Pluggable database containers (PDBs): – A container for an application: — Tablespaces (permanent and temporary) — Schemas / objects / privileges — Created / cloned / unplugged / plugged – Particular seed PDB: — PDB$SEED provides fast provisioning of a new PDB – Limit of 253 PDBs in a CDB including the seed – Limit of 1024 services in a CDB Copyright © 2014, Oracle and/or its affiliates. All rights reserved.12 Questions: Root Versus PDBs What belongs to the CDB and not to a specific container? • Control files and redo log files What is in the root that is not in PDBs? • UNDO tablespace (for each instance) • System-supplied metadata • Shared Oracle-supplied data – PL/SQL Oracle-supplied packages (DBMS_SQL …) – PDBs service names • CDB dictionary views providing information across PDBs • CDB Resource Manager plan UNDO NAME PDB_SALES PDB_HR TABLE_NAME CON_ID EMPLOYEES 1 TEST 2 Views CDB_xxx NAME TYPE TAB$ 2 USER$ 2 Table SYS.OBJ$ Table SYS.SERVICE$ CDBA
  • 7. 7 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.13 Questions: PDBs Versus Root What is in a PDB that is not in the root nor in another PDB? • Application tablespaces • Local temporary tablespaces • Local users and local roles – Local users connect to the PDB where they exist. • Non-shared local metadata • Non-shared application data with other PDBs • PDB Resource Manager plan HR_TBS TEMP1 EMP_NAME SMITH JOHNTable HR.EMPLOYEES NAME TYPE EMPLOYEES 2 JOBS 2 Table SYS.OBJ$ PDBA Copyright © 2014, Oracle and/or its affiliates. All rights reserved.14 Common and Local Users Multitenant Container Database root PDB_HR PDB_SALES Table HR.REGIONS USERNAME COMMON SYS YES SYSTEM YES C##DBA YES C##HR YES View CDB_USERS Adding a common user involves adding a description of that user in the root and in every PDB. A local user is a traditional user, known only in its own PDB. View DBA_USERS USERNAME COMMON SYS YES SYSTEM YES C##DBA YES C##HR YES SALES NO USERNAME COMMON SYS YES SYSTEM YES C##DBA YES C##HR YES HR_MGR NO View DBA_USERS Table SALES.COUNTRIES Tablespace EXAMPLE Tablespace EXAMPLE Tablespace EXAMPLE
  • 8. 8 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.15 Common and Local Privileges and Roles Multitenant Container Database root PDB_HR Common users Local users Common Priv (granted commonly) Local Priv (granted locally) Common roles Local roles SQL> GRANT c##_r1 TO C##DBA CONTAINER=ALL; SQL> GRANT l_priv TO C##DBA CONTAINER=CURRENT; Common privilege Local privilege Common Role (granted commonly) Common Role (granted locally) COMMON role LOCAL role X LOCAL role COMMON role X Priv/role granted locally Priv/role granted commonlyX Copyright © 2014, Oracle and/or its affiliates. All rights reserved.16 CDB_xxx All objects in the multitenant container database across all PDBs USER_xxx Objects owned by the current user ALL_xxx Objects accessible by the current user DBA_xxx All of the objects in a container or pluggable database Data Dictionary Views • CDB_pdbs: All PDBS within CDB • CDB_tablespaces: All tablespaces within CDB • CDB_users: All users within CDB (common and local) DBA dictionary views providing information within PDB: SQL> SELECT view_name FROM dba_views WHERE view_name like 'CDB%'; SQL> SELECT table_name FROM dict WHERE table_name like 'DBA%';
  • 9. 9 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.17 Impacts • One character set for all PDBs (Unicode recommended) • PDB initialization parameters but a single SPFILE • No PDB qualified database object names – SELECT * FROM HR:apps.tab1 – Use DB Links: SELECT * FROM apps.tab1@HR • Oracle Data Guard at CDB level • Oracle Database Vault per PDB only • One master key per PDB to encrypt PDB data • Unified audit both at CDB and PDB levels • Oracle Scheduler • Oracle GoldenGate • Oracle Streams • Oracle XStream both at CDB and PDB levels Impacts Copyright © 2014, Oracle and/or its affiliates. All rights reserved.18 SQL*Plus OUI DBCA EM Cloud Control EM Database Express SQL Developer DBUA Create a new CDB or PDB Yes Yes Yes Yes (PDB only) Yes (PDB only) Yes (PDB only) Explore CDB instance, architecture and PDBs Yes Yes Yes Yes Upgrade a 12.1 CDB to 12.x CDB Yes Yes Tools
  • 10. 10 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.19 Instance SGA Process Structures Instance Container Database CDB1 root container seed pluggable database Steps to Create a Container Database 2 1 Container Database CDB1 Datafiles Control files UNDOSYSTEM SYSAUX Redo Log files SYSTEM TEMP1 TEMP SYSAUX initCDB1.ora 3 4 Execute scripts from root catcdb.sql Copyright © 2014, Oracle and/or its affiliates. All rights reserved.20 Creating a Container Database: Using SQL*Plus 1. Instance startup: a. Set ORACLE_SID=CDB1 b. Set in initCDB1.ora: – Set CONTROL_FILES to CDB control file names. – Set DB_NAME to CDB name. – Set ENABLE_PLUGGABLE_DATABASE to TRUE. 2. Create the database: – CDB$ROOT container – PDB$SEED pluggable database 3. Run the catcdb.sql script. SQL> CONNECT / AS SYSDBA SQL> STARTUP NOMOUNT SQL> CREATE DATABASE CDB1 ENABLE PLUGGABLE DATABASE … SEED FILE_NAME_CONVERT ('/oracle/dbs','/oracle/seed');
  • 11. 11 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.21 Creating a Container Database: Using DBCA Copyright © 2014, Oracle and/or its affiliates. All rights reserved.22 After CDB Creation: What Is New in CDBs A CDB has new characteristics compared to non-CDBs: • Two containers: – The root (CDB$ROOT) – The seed PDB (PDB$SEED) • Several services: One per container – Name of root service = name of the CDB (cdb1) • Common users in root and seed: SYS,SYSTEM … • Common privileges granted to common users • Pre-defined common roles • Tablespaces and data files associated to each container: – root: SYSTEM (system-supplied metadata and no user data), SYSAUX, TEMP – seed: SYSTEM, SYSAUX , TEMP
  • 12. 12 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.23 USER_xxx Objects owned by the current user in a PDB ALL_xxx Objects accessible by the current user in a PDB DBA_xxx All of the objects in the root or a pluggable database Data Dictionary Views: DBA_xxx DBA dictionary views providing information within PDB: • DBA_tablespaces: All tablespaces of the PDB • DBA_data_files: All data files of the PDB • DBA_tables: All tables in the PDB • DBA_users: All common and local users of the PDB SQL> SELECT table_name FROM dict WHERE table_name like 'DBA%'; Copyright © 2014, Oracle and/or its affiliates. All rights reserved.24 CDB_xxx All of the objects in the container database (new column CON_ID) USER_xxx Objects owned by the current user in a PDB ALL_xxx Objects accessible by the current user in a PDB DBA_xxx All of the objects in the root or a pluggable database Data Dictionary Views: CDB_xxx CDB dictionary views provide information across PDBs: • CDB_pdbs: All PDBS within the CDB • CDB_tablespaces: All tablespaces within the CDB • CDB_data_files: All data files within the CDB • CDB_users: All users within the CDB (common and local) SQL> SELECT view_name FROM dba_views WHERE view_name like 'CDB%';
  • 13. 13 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.25 Data Dictionary Views: Examples • Comparisons: • Access to data in V$ or GV$ views showing data from multiple PDBs can be secured using privilege. SQL> SELECT name, open_mode FROM v$pdbs; NAME OPEN_MODE ---------------- ---------- PDB$SEED READ ONLY PDB1 READ WRITE PDB2 READ WRITE SQL> CONNECT / AS SYSDBA SQL> SELECT role, common, con_id FROM cdb_roles; SQL> SELECT role, common FROM dba_roles; 1 2 SQL> CONNECT sys@PDB1 AS SYSDBA SQL> SELECT role, common, con_id FROM cdb_roles; SQL> SELECT role, common FROM dba_roles; 3 4 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.26 After CDB Creation: To-Do List After CDB creation, the CDBA has to: • Set a separate default tablespace for the root and for each PDB • Set a default temporary tablespace for each container • Start the listener • Plug non-CDBs • Test startup/shutdown procedures • Define default PDB state to automate PDBs opening • Create backup and recovery procedures 12.1.0.2
  • 14. 14 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.27 Provisioning New Pluggable Databases Different methods: • Create a new PDB from the seed PDB. • Plug or clone a non-CDB into a CDB. • Clone: – A local PDB into the same CDB – A remote PDB into a CDB • Plug an unplugged PDB into another CDB. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.28 Tools To provision new PDBs, you can use: • SQL*Plus • SQL Developer • Enterprise Manager Cloud Control • Enterprise Manager Database Express • DBCA – Copy from seed – By unplugging/plugging method
  • 15. 15 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.29 Method 1: Create New PDB from PDB$SEED Container Database CDB1 root Data files/ Tempfiles Redo Log files Control files UNDO TEMP PDB$SEED Data files PDB1 Data files Create PDB1 from PDB$SEED • Copies the data files from PDB$SEED data files • Creates SYSTEM and SYSAUX tablespaces • Creates a full catalog including metadata pointing to Oracle- supplied objects • Creates a temporary tablespace, TEMP • Creates common users: – Superuser SYS – SYSTEM • Creates a local user (PDBA) granted local PDB_DBA role • Creates a new default service TEMP SYSAUX SYSTEM SYSTEM USERS SYSAUX SYSAUX SYSTEM Copyright © 2014, Oracle and/or its affiliates. All rights reserved.30 Steps: With Location Clauses Connect to the root as a common user with the CREATE PLUGGABLE DATABASE privilege: • Use FILE_NAME_CONVERT: • Use CREATE_FILE_DEST: • Use views to verify: SQL> CREATE PLUGGABLE DATABASE pdb1 ADMIN USER admin1 IDENTIFIED BY p1 ROLES=(CONNECT) FILE_NAME_CONVERT = ('PDB$SEEDdir', 'PDB1dir'); SQL> CONNECT / AS SYSDBA SQL> SELECT * FROM cdb_pdbs; SQL> SELECT * FROM cdb_tablespaces; SQL> SELECT * FROM cdb_data_files; SQL> CONNECT sys@pdb1 AS SYSDBA SQL> CONNECT admin1@pdb1 SQL> CREATE PLUGGABLE DATABASE pdb2 ADMIN USER admin2 IDENTIFIED BY p2 ROLES=(CONNECT) CREATE_FILE_DEST = 'PDB2dir'; 12.1.0.2
  • 16. 16 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.31 Synchronization • If the PDB is in MOUNTED or READ-ONLY mode • If customer-created common users or roles are created / modified / dropped →The PDB needs to be resynchronized with the root. – Open the PDB in READ-WRITE mode to synchronize the PDB with the target CDB. – If you open the PDB in READ-ONLY mode, an error is returned. →A compatibility check is automatically performed: – Any violation is reported in the PDB_PLUG_IN_VIOLATIONS view. – If there is no violation, the PDB status is changed to NORMAL. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.32 Method 2: Plug a Non-CDB into a CDB Three possible methods: • TTS or TDB or full export/import • XML file definition with DBMS_PDB • Replication Entities are created in the new PDB: • Tablespaces: SYSTEM, SYSAUX, TEMP • A full catalog • Common users: SYS, SYSTEM • A local administrator (PDBA) • A new default service Container Database CDB1 root Data files/ Temp files Redo Log files Control files PDB$SEED Data files / Temp files Create PDB2 from ORCL ORCL Data files Control files Redo Log files Dump file PDB2 Data files impdp TTS 12.1 expdp TTS ReplicationXML file DBMS_PDB Plug
  • 17. 17 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.33 Plug a Non-CDB in to CDB Using DBMS_PDB Container Database CDB1 root Data files/ Temp files Redo Log files Control files PDB$SEED PDB2 Data files Create PDB2 from ORCL DBMS_PDB.DESCRIBE Plug XML metadata file 1. Open ORCL in READ ONLY mode. 2. 3. Connect to the target CDB1 CDB as a common user with CREATE PLUGGABLE DATABASE privilege. 4. Plug in the unplugged ORCL as PDB2. 5. Run the noncdb_to_pdb.sql script. 6. Open PDB2. SQL> CREATE PLUGGABLE DATABASE PDB2 USING '/tmp/ORCL.xml'; SQL> EXEC DBMS_PDB.DESCRIBE ('/tmp/ORCL.xml') SQL> CONNECT sys@PDB2 AS SYSDBA SQL> @$ORACLE_HOME/rdbms/admin/noncdb_to_pdb Data files / Tempfiles ORCL Datafiles Control files Redo Log files 12.1 SQL> ALTER PLUGGABLE DATABASE PDB2 OPEN; Copyright © 2014, Oracle and/or its affiliates. All rights reserved.34 Method 3: Clone Local PDBs Container Database CDB1 root Data files/ Temp files Redo Log files Control files PDB$SEED Data files / Temp files PDB1 Data files Create PDB3 from PDB1 1. Set the DB_CREATE_FILE_DEST or DB_FILE_NAME_CONVERT instance parameter or use the CREATE_FILE_DEST clause. 2. Connect to the root. 3. Quiesce PDB1: 4. Clone PDB3 from PDB1: 5. Open PDB3 in read-write mode. 6. Reopen PDB1. PDB3 Data files PDB3 owns: • SYSTEM, SYSAUX tablespaces • Full catalog • A temporary tablespace • SYS, SYSTEM common users • Same local administrator name • New service name SQL> ALTER PLUGGABLE DATABASE pdb1 CLOSE; SQL> ALTER PLUGGABLE DATABASE pdb1 OPEN READ ONLY; SQL> CREATE PLUGGABLE DATABASE pdb3 FROM pdb1; SQL> ALTER PLUGGABLE DATABASE pdb3 OPEN; 12.1.0.2
  • 18. 18 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.35 Method 4: Plug Unplugged PDB in to CDB Unplug PDB1 from CDB1: 1. Connect to CDB1 as a common user. 2. Verify that PDB1 is closed. 3. 4. Optionally, drop PDB1 from CDB1. Plug PDB1 in to CDB2: 1. Connect to CDB2 as a common user. 2. Use DBMS_PDB package to check the compatibility of PDB1 with CDB2. 3. 4. Open PDB1 in read-write mode. Container Database CDB1 root PDB$SEED PDB1 Data files XML file USERS Unplug PDB1 Container Database CDB2 root PDB$SEED PDB1 Data files Plug PDB1 SQL> ALTER PLUGGABLE DATABASE pdb1 UNPLUG INTO 'xmlfile1.xml'; SQL> CREATE PLUGGABLE DATABASE pdb1 USING 'xmlfile1.xml' NOCOPY; SYSAUX SYSTEM USERSSYSAUX SYSTEM Copyright © 2014, Oracle and/or its affiliates. All rights reserved.36 Method 4: Flow Are new PDB files based on same files that were used to create existing PDB in CDB? If not, AS CLONE clause is required and so, it ensures that Oracle Database generates unique PDB DBID, GUID, and other identifiers expected for the new PDB. XML file accurately describes current locations of files? Are files in correct location? Do you want to specify storage limits for PDB? If not, the SOURCE_FILE_NAME_CONVERT clause is required. If not, specify COPY to copy files to new location or MOVE to move them to another location. If yes, use NOCOPY. COPY as the default. If yes, specify the STORAGE clause. • FILE_NAME_CONVERT or CREATE_FILE_DEST clauses of CREATE PLUGGABLE DATABASE statement • Instances DB_CREATE_FILE_DEST or PDB_FILE_NAME_CONVERT parameters Several clauses can be used in conjunction:
  • 19. 19 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.37 Plug Sample Schemas PDB: Using DBCA 1 2 3 4 Plug a new PDB with Sample Schemas using a PDB File Set Copyright © 2014, Oracle and/or its affiliates. All rights reserved.38 Dropping a PDB Container Database CDB1 root Data files/ Temp files Redo Log files Control files File2 TEMP PDB$SEED Data files File5 File6 File7 File4 File1 File3 PDB1 Data files File8 Drop PDB1 • Updates control files • If INCLUDING DATAFILES: – Removes PDB1 datafiles • If KEEP DATAFILES (default): – Retain data files – Can be plugged in another or the same CDB • Requires SYSDBA privilege • Cannot drop seed PDB File9 File10 PDB4 Data files SQL> ALTER PLUGGABLE DATABASE pdb1 CLOSE; SQL> DROP PLUGGABLE DATABASE pdb1 [INCLUDING DATAFILES];… File7 File8 File9 File10 …
  • 20. 20 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.39 Migrating pre-12.1 Databases to 12.1 CDB There are two methods: 1. Upgrade an existing pre-12.1 database to 12c. 2. Plug-in non-CDB into a CDB. Or 1. Pre-create a PDB in CDB. 2. Use 11g expdp / 12c impdp or replication between non-CDB and PDB. CDB CDB1 root Data files/ Temp files Redo Log files Control files ORCL Data files Control files Redo Log files expdp Dump file PDB1 Data files impdp ORCL Data files Control files Redo Log files 1 2 11g 12c Replication XML file Copyright © 2014, Oracle and/or its affiliates. All rights reserved.40 MOUNT NOMOUNT SHUTDOWN Instance started – CDB control files opened for the instance – Root mounted – PDBs mounted – Root opened – PDBs still mounted, except seed in RO OPEN SQL> STARTUP SQL> ALTER DATABASE cdb1 OPEN; Or SQL> SELECT name,open_mode 2 FROM v$pdbs; NAME OPEN_MODE ---------------- ---------- PDB$SEED READ ONLY PDB1 MOUNTED PDB2 MOUNTED Opening a CDB
  • 21. 21 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.41 OPEN MOUNT NOMOUNT SHUTDOWN Instance started – CDB control files opened for the instance – Root mounted – PDBs mounted – Root opened – PDBs still mounted, except seed in RO PDB OPEN PDBs opened RW, except seed in RO SQL> CONNECT sys@CDB1 AS SYSDBA SQL> ALTER PLUGGABLE DATABASE pdb1 OPEN; SQL> ALTER PLUGGABLE DATABASE ALL OPEN; Or SQL> SELECT name,open_mode 2 FROM v$pdbs; NAME OPEN_MODE ---------------- ---------- PDB$SEED READ ONLY PDB1 READ WRITE PDB2 READ WRITE Opening a PDB Copyright © 2014, Oracle and/or its affiliates. All rights reserved.42 CDB OPEN MOUNT NOMOUNT SHUTDOWN Instance started – CDB control files opened for the instance – Root mounted – PDBs mounted – Root opened – PDBs mounted, except seed still RO PDB CLOSE PDBs closed SQL> CONNECT / AS SYSDBA SQL> ALTER PLUGGABLE DATABASE pdb1 CLOSE IMMEDIATE; SQL> ALTER PLUGGABLE DATABASE ALL EXCEPT pdb1 CLOSE; SQL> ALTER PLUGGABLE DATABASE ALL CLOSE; SQL> CONNECT sys@pdb1 AS SYSDBA SQL> ALTER PLUGGABLE DATABASE CLOSE; Or SQL> SHUTDOWN IMMEDIATE; Closing a PDB
  • 22. 22 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.43 SQL> CONNECT sys@CDB1 AS SYSDBA SQL> SHUTDOWN IMMEDIATE Shutting Down a CDB Instance • All PDBs closed (no new specific message) • CDB closed • CDB dismounted • Instance shut down • PDB closed SQL> CONNECT sys@PDB1 AS SYSDBA SQL> SHUTDOWN IMMEDIATE Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Exploring Oracle Database 12c Multitenant Best Practices for your Cloud Ami Aharonovich Oracle ACE & OCP [email protected]