Exploring Oracle Multitenant in Oracle Database 12c
-
Upload
zohar-elkayam -
Category
Technology
-
view
169 -
download
9
Transcript of Exploring Oracle Multitenant in Oracle Database 12c
Zohar Elkayam www.realdbamagic.com
Twitter: @realmgic
Exploring Oracle Multitenant in Oracle Database 12c
Based on Presentation by Ami Aharonovich
Who am I?
• Zohar Elkayam, CTO at Brillix
• Programmer, DBA, team leader, database trainer, public speaker, and a senior consultant for over 18 years
•Oracle ACE Associate • Part of ilOUG – Israel Oracle User Group• Blogger – www.realdbamagic.com and www.ilDBA.co.il
2 http://brillix.co.il
About Brillix• We offer complete, integrated end-to-end solutions based on best-of-
breed innovations in database, security and big data technologies• We provide complete end-to-end 24x7 expert remote database
services• We offer professional customized on-site trainings, delivered by our
top-notch world recognized instructors
3
http://brillix.co.il
Some of Our Customers
http://brillix.co.il4
Agenda
•The Multitenant Container Database Architecture •Multitenant Benefits and Impacts•CDB and PDB Deployments and Provisioning•Tools and Self-service tools•Live Demo
http://brillix.co.il5
Architecture, Benefits and Impacts
http://brillix.co.il6
Oracle Database in 11g Release 2
• Multiple non-CDBs share nothing:• Too many background processes• High shared/process memory• Many copies of Oracle metadata
Database (Storage Structures)
Server
Database
Instance
System Global Area
Process Structures
Instance
Pre-12c
http://brillix.co.il7
Multitenant Container Database Architecture
• Single DB shares:• Background processes• Shared/process memory• Oracle metadata• Redo log files• Control files• Undo tablespace
Instance
System Global Area
Process Structures
Server
Instance
Multitenantcontainer 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
http://brillix.co.il8
Containers: Root Container
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
http://brillix.co.il9
Containers: Pluggable Database Container• 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 and 1024 services per CDB (before 12.2)
• Limit of 4096 PDBs in a CDB (after 12.2)
http://brillix.co.il10
Files in the CDB• Each PDB has its own set of
tablespaces including SYSTEM and SYSAUX
• PDBs share UNDO, REDOand control files, (s)pfile
• By default the CDB has a single TEMP tablespace but PDBs may create their own
http://brillix.co.il11
Users• Local users are the successors for
customer-created users in a non-CDB
• A local user is defined only in a PDB
• A local user can administer a PDB
• A common user is defined in the rootand is represented in every PDB
• A common user can log into any PDBwhere it has “Create Session” and can therefore administer a PDB
• The Oracle system is owned by common users
http://brillix.co.il12
Common Users and Privileges• Authorization is checked in the same way as as pre-12.1• A common user can be granted privileges locally in a PDB (or root)
and therefore differently in each container• A common user can, alternatively, be granted a system privilege
commonly – the grant is made in root and every PDB, present and future
• You can create a common role• A common role can be granted to a common user commonly• Authorization is checked in the container where the SQL is attempted
considering only the privileges that the user has in that container
http://brillix.co.il13
CDB_xxxAll 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_xxxAll 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)
SQL> SELECT view_name FROM dba_views WHERE view_name like 'CDB%';
http://brillix.co.il14
New Multitenant Architecture: Benefits• Operates multiple databases in a centrally managed
platform to lower costs:• Less instance overhead• Less storage cost
• No application changes• Fast and easy provisioning• Ensures full backwards-compatibility with non-CDBs
http://brillix.co.il15
New Multitenant Architecture: Benefits (2)• Fully operates with RAC and Data Guard• Is supported by Enterprise Manager• Allows central management and administration of multiple
databases• Backups or disaster recovery• Patching and upgrades
http://brillix.co.il16
Impacts (1)• One character set for all PDBs (Unicode recommended)• Shared REDO log file and archive log process• Oracle Data Guard at CDB level• PDB initialization parameters, but a single SPFILE for all
PDBs• One master key per PDB to encrypt PDB data
http://brillix.co.il17
Impacts (2)• No PDB qualified database object names
• SELECT * FROM HR:apps.tab1• Use DB Links: SELECT * FROM apps.tab1@HR
• Oracle Database Vault per PDB only• Unified audit both at CDB and PDB levels• Oracle Scheduler• Oracle GoldenGate
http://brillix.co.il18
Impacts (3)• AWR data is stored in the CDB, visible from any of the PDBs
• The awrrpt.sql script can work on either CDB or PDB level• MOS Note: 1993045.1 – “Reducing AWR Resource Consumption
using LITE Mode snapshots” (12.1.0.2)• PDB new CONTAINERS clause (12.1.0.2):
• Data can be aggregated from a single identical table or view across many PDBs from the root container
• CONTAINERS clause accepts a table or view name as an input parameter that is expected to exists in all PDBs in that container
• Data from specific PDBs can be included with the use of CON_ID in the WHERE clause
http://brillix.co.il19
Impacts (4)• When creating the CDB (DBCA), all options will be created
• MOS Doc ID 2001512.1 – creating a container database (CDB) with a subset of options
• MOS Doc ID 1616554.1 – customization of database options in a multitenant setup
• By default, PDBs need to be started manually• ALTER PLUGGABLE DATABASE pdb SAVE STATE;
• Deprecation of Non-CDB Architecture• “The non-CDB architecture is deprecated in Oracle Database 12c, and may
be desupported and unavailable in a release after Oracle Database 12cRelease 2. Oracle recommends use of the CDB architecture”
http://brillix.co.il20
Deployment and PDB Provisioning
http://brillix.co.il21
Deployment – CDB Creation and Configuration• Use DBCA (GUI or silent mode)• Standardize your database options and character set• Size the CDB as you would a large database
• Configure Linux Huge Pages if SGA > ~30GB• Modify memlock limits accordingly• Use ASMM• Set processes to 100 * physical core• Set SGA_TARGET to 60% of physical memory• Automatic PGA memory management (20% of SGA)• Limit UNDO to grow no more than 20% of SGA• Redo: minimum 4GB and size to switch max <= 10-20 mins, 3-4 redo log groups,
archive
http://brillix.co.il22
Instance
SGA
Process StructuresInstance
Container DatabaseCDB1
root container
seed pluggable database
Steps to Create a Container Database2
1
Container Database CDB1
DatafilesControl
files
UNDO SYSTEM
SYSAUX
Redo Log
files
SYSTEM TEMP1
TEMP
SYSAUX
initCDB1.ora
3
4
Execute scripts from root catcdb.sql
http://brillix.co.il23
Creating a Container Database: Using SQL*Plus1.Instance startup:
a. Set ORACLE_SID=CDB1b. 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');
http://brillix.co.il24
Creating a Container Database: Using DBCA
http://brillix.co.il25
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
http://brillix.co.il26
Provisioning a Pluggable Database
• 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.
Seed
PDB
New
empty
PDB
root
Multitenant Container Database
http://brillix.co.il27
Provisioning Tools•To provision new PDBs, we can use:
• SQL*Plus commands• SQL Developer• Enterprise Manager Cloud Control• Enterprise Manager Database Express• DBCA
• Copy from seed• By unplugging/plugging method
• Self-Service Provisioning Application
http://brillix.co.il28
Deployment – PDB Creation and Configuration• Clone• Configure clone quotas and storage limits• Don’t modify PDB$SEED, create and customize your own SEED• Use CREATE_FILE_DEST for PDB file destination (12.1.0.2)• Use ISPDB_MODIFIABLE to evaluate and adjust parameters in
PDB level (optimizer settings, cursor_sharing…)• Check PDB parameter settings in your session (PDB
parameters are stored in CDB$ROOT dictionary)
http://brillix.co.il29
Method 1: Create New PDB 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
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
TEMP
SYSAUX
SYSTEM
SYSTEM
USERS
SYSAUX
SYSAUX SYSTEM
http://brillix.co.il31
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
http://brillix.co.il32
Method 2: Plug a Non-CDB in to CDB Using DBMS_PDB1. 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
SQL> ALTER PLUGGABLE DATABASE
PDB2 OPEN;
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
Data files / Tempfiles
ORCL
Datafiles Control
files
Redo Log
files
12.1
http://brillix.co.il33
Method 3: Clone Local PDBs1. Set the DB_CREATE_FILE_DEST or
DB_FILE_NAME_CONVERT instance parameter oruse 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 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
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
PDB1PDB3
Data files
http://brillix.co.il34
Method 4: Plug Unplugged PDB in to CDBUnplug 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.
SQL> ALTER PLUGGABLE DATABASE
pdb1 UNPLUG INTO
'xmlfile1.xml';
SQL> CREATE PLUGGABLE DATABASE
pdb1 USING 'xmlfile1.xml'
NOCOPY;
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
SYSAUX
SYSTEM
USERSSYSAUX
SYSTEM
http://brillix.co.il35
Plug Sample Schemas PDB: Using DBCA1
2
3
4
Plug a new PDB with Sample Schemas using a PDB File Set
http://brillix.co.il36
Interacting Within Multitenant Container Database
PDB_1 PDB_2 PDB_nfast intra-CDB db link
root
Multitenant Container Database
http://brillix.co.il37
Dropping a PDB
• 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
SQL> ALTER PLUGGABLE DATABASE
pdb1 CLOSE;
SQL> DROP PLUGGABLE DATABASE
pdb1 [INCLUDING DATAFILES];
root
Data files/
Temp files
Redo Log
files
Control
files
File2
TEMP
PDB$SEED
Data files
File5File6
File7
File4
File1
File3
PDB1
Data files
File8 Drop PDB1File9 File10
PDB4
Data files
…
File7
File8
File9
File10
…
http://brillix.co.il38
Tools
SQL*Plus OUI DBCAEM Cloud
Control
EM
Database
Express
SQL
DeveloperDBUA
Create a new CDB or PDB Yes Yes Yes
Yes
(PDB only)
Yes
(PDB only)
Yes
(PDB only)
Explore CDB instance, architectureand PDBs
Yes Yes Yes Yes
Upgrade a
12.1 CDB
to 12.x CDB
Yes Yes
http://brillix.co.il39
Self-Service Provisioning Application• Self-service provisioning of pluggable databases (PDBs)• Easy and productive way for DBAs and developers to create, clone,
plug and unplug PDBs• Prerequisites:
• Oracle Database 12c Release 1 (12.1.0.2.0 or above)• Oracle Application Express 4.2.5 or above• Oracle REST Data Services 2.0.6 or above
http://www.oracle.com/technetwork/database/multitenant/downloads/multitenant-pdbss-2016324.html
http://brillix.co.il40
Self-Service Provisioning Application (cont.)
http://brillix.co.il41
Q&A
http://brillix.co.il42
Summary
•Pluggable database is good for consolidations• It’s easy to use an seamless to the application•DBAs needs to get used to the new convention•Even single pluggable database might be useful –
for upgrades and for migrations.
http://brillix.co.il43