Migration to the CDB Architecture
30-APR-2020
Mike DietrichMaster Product ManagerDatabase Upgrade and Migrations@MikeDietrichDE
Laura Garcia VillarealOU PreSales Manager
Mike Dietrich
Master Product ManagerDatabase Upgrade and Migrations https://MikeDietrichDE.com
@MikeDietrichDECopyright © 2020 Oracle and/or its affiliates.
Slides | https://MikeDietrichDE.com
Copyright © 2020 Oracle and/or its affiliates.
Agenda
AutoUpgrade and CDB Migration
Oracle Multitenant
Further Information
Copyright © 2020 Oracle and/or its affiliates.
1
2
3
AutoUpgrade
Copyright © 2020 Oracle and/or its affiliates.
The recommended way to upgrade databases
Ph
oto
by
Josh
ua
So
rtin
oo
n U
nsp
lash
Download | Get the latest autoupgrade.jar
• MOS Note: 2485457.1
Copyright © 2020 Oracle and/or its affiliates.
Upgrade | AutoUpgrade
Copyright © 2020 Oracle and/or its affiliates.
upg>
Job Console
11.2.0.412.1.0.2
12.2.0.1
18c
autoupgrade.jarMOS Note: 2485457.1
2MB
config.cfg
autoupgrade.jar
12.2.0.1
18.5.0
19c
19c
AutoUpgrade to Oracle 19c
Migration to Oracle Multitenant
Copyright © 2020 Oracle and/or its affiliates.
Ph
oto
by
Ma
thia
s Je
nse
no
n U
nsp
lash
Oracle Multitenant | Oracle 19c
• You don't have to use Oracle Single-/Multitenant with Oracle 19c
• Oracle 18c and Oracle 19c belong to the Oracle Database 12.2 release family
• For further details see MOS Note: 742060.1
Copyright © 2020 Oracle and/or its affiliates.
And by the way …
• Since Oracle 19c you can have 3 user-created PDBs without need for a Multitenant license!!!
• https://mikedietrichde.com/2019/09/17/3-pdbs-included-with-oracle-19c-and-desupport-of-non-cdbs-with-20c/
Copyright © 2020 Oracle and/or its affiliates.
Upgrade to 19c | Migration to Multitenant
Copyright © 2020 Oracle and/or its affiliates.
Oracle 11.2.04
AutoUpgrade
Oracle 19.7.0
CDB
PDB$SEED
Oracle 19.7.0
CDB
PDB$SEED
1 ⃣ 2 ⃣ Plug into CDB
3️ ⃣ noncdb_to_pdb.sql
Oracle 19.7.0
Conversion with
AutoUpgrade One-Command Orchestration
AutoUpgrade | Migration to Multitenant
• Use this parameter in your config file• The receiving CDB must be precreated already
#
# Specify the SID of the target CDB to plug into after upgrade
#
upg2.target_cdb=CDB2
Copyright © 2020 Oracle and/or its affiliates.
Agenda
AutoUpgrade and CDB Migration
Oracle Multitenant
Further Information
Copyright © 2020 Oracle and/or its affiliates.
1
2
3
Migration
Oracle Multitenant
Copyright © 2020 Oracle and/or its affiliates.
• Non-CDB• No change to
previous releases
Copyright © 2020 Oracle and/or its affiliates.
Oracle Multitenant | Deployments 19c
• CDB: Three Tenants• No extra license
• Available with SE2 / EE
• Three user-created PDBs included
• SPFILE: max_pdbs=3
• CDB: Multitenant• Multitenant license
required
• Available with EE only
• Up to 252 PDBs
• Up to 4096 PDBs in the Cloud and on Engineered Systems
PDB$SEED
PDB$SEED
…
Oracle Multitenant | Concept
CDB1
PDB$SEED
CDB2
PDB$SEED
CDB3
PDB$SEED
PDB$SEED
Copyright © 2020 Oracle and/or its affiliates.
Redo Control Flashbackspfile
PDB$SEED
Oracle Multitenant | Resource Sharing
Copyright © 2020 Oracle and/or its affiliates.
Oracle Multitenant | Connecting
• CDB$ROOT• $> sqlplus / as sysdba
• PDB• $> sqlplus "sys/oracle@PDB1 as sysdba"
• $> sqlplus "sys/oracle@//localhost/pdb1 as sysdba"
• $> export TWO_TASK=pdb1
$> sqlplus "sys/oracle as sysdba"
• Switch between containers• SQL> alter session set container=pdb1;
• SQL> alter session set container=cdb$root;
CDB
PDB$SEED
CDB
PDB$SEED
CDB
PDB$SEED
Copyright © 2020 Oracle and/or its affiliates.
Oracle Multitenant | Resource Manager
• Memory Management• SGA_MIN_SIZE - minimum sga size
• IO Resource Managment [IORM]• MAX_IOPS - maximum I/O requests per second
• MAX_MBPS - maximum MB per second of I/O
• Can't be set in the CDB$ROOT and on Exadata
• Can be dynamically altered
• CPU Consumption• CPU_COUNT - number of cpu cores
Can be set onPDB level
Copyright © 2020 Oracle and/or its affiliates.
Oracle Multitenant | Components/Options
• Create CDBs with fewer options: DBCA's "CUSTOM" mode creation• https://mikedietrichde.com/2018/08/08/creating-cdbs-non-cdbs-with-
less-options/
Copyright © 2020 Oracle and/or its affiliates.
Oracle Multitenant | Components/Options
• Only "Advanced Configuration" + "Custom Database" gives you:
Copyright © 2020 Oracle and/or its affiliates.
Be aware!
Be really aware!
Oracle Multitenant | Components/Options
• Remove or add options• https://mikedietrichde.com/2017/07/26/remove-clean-components-
oracle-11-2-12-2/
Copyright © 2020 Oracle and/or its affiliates.
Oracle Multitenant | catcon.pl
• Execute scripts with catcon.pl• MOS Note: 1932340.1 - How to execute sql scripts in Multitenant environment
(catcon.pl)
• Example: Run preupgrade_fixups.sql in all containers
$> $ORACLE_HOME/perl/bin/perl
$ORACLE_HOME/rdbms/admin/catcon.pl
-n 1
-d $ORACLE_BASE/cfgtoollogs/UPGR/preupgrade
-l /home/oracle/upgrade
-b preupfix
preupgrade_fixups.sql
Copyright © 2020 Oracle and/or its affiliates.
Oracle Multitenant | Local Undo
• Default since Oracle 12.2.0.1• Requirement for Flashback Pluggable Database, Hot Cloning and other features
• In STARTUP UPGRADE mode: SQL> alter database local undo ON;
SYSTEM
SYSAUX
TEMP
UNDO
DATA
SYSTEM
SYSAUX
TEMP
UNDO
DATA
SYSTEM
SYSAUX
TEMP
UNDO
CDB
PDB$SEED
Copyright © 2020 Oracle and/or its affiliates.
Oracle Multitenant | Creation of a PDB
• Fast provisioning:
• Admin user can be deleted afterwards
• PDB is ready to use within seconds
create pluggable database PDB1
admin user adm identified by pwd
file_name_convert=('pdbseed',’pdb1');
CDB1
PDB$SEEDPDB$SEED
Copyright © 2020 Oracle and/or its affiliates.
• Local cloning:
• parallel can speed up the process• Default: cpu_count
• Monitoring in v$session_longops
• kpdbfCopyTaskCbk (datafile copy)
• kcrfremnoc (redo file copy)
Oracle Multitenant | Cloning of a PDB
• Remote cloning via Database Link:
create pluggable database PDB2 from
PDB1 file_name_convert=('pdb1','pdb2')
parallel 8;
create pluggable database PDB1 from
PDB1@dblink_to_cdb1
file_name_convert=('CDB1','CDB2');
CDB1
PDB$SEEDPDB$SEED
CDB1
PDB$SEED
CDB2
PDB$SEED
Copyright © 2020 Oracle and/or its affiliates.
Oracle Multitenant | Hot Cloning insightsP P P P P
P P P P
P P P
PP P
DataFile2DataFile1 Undo
− Source PDB remains open for read and write− Read and copy in parallel− On-going operations imply a “dirty read”− Some data changes not included in initial file copy− Ship and apply redo to catch up with source− Apply undo to rollback uncommitted transactions
DataFile1 DataFile2Undo
Redo Log
P P P P P
P P P P
P P P
PP P
P P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P P
P
P P
P
P
P
P
P
P P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
P
Legend
Uncommitted blockchanged in intervalBlock changed in intervalCommitted in intervalUncommitted redoUndo written in intervalCommitted in interval
P
P
Copyright © 2020 Oracle and/or its affiliates.
Oracle Multitenant | Relocate a PDB
• Relocate via Database Link:create pluggable database PDB1 from PDB1@dblink_to_cdb1
relocate availability max
file_name_convert=('/oradata/CDB1/pdb1','/oradata/CDB2/pdb1');
CDB1
PDB$SEED
CDB2
PDB$SEED
Redo
Redo
Copyright © 2020 Oracle and/or its affiliates.
Oracle Multitenant | Upgrade and Plugin
• Upgrade non-CDB to CDB version
• Start database read only
• Create XML manifest file
• Shutdown database
• Plug into CDB
• Sanity script
• https://mikedietrichde.com/2017/03/08/converting-an-12-1-non-cdb-and-plug-it-into-an-12-2-cdb/
exec DBMS_PDB.DESCRIBE('PDB1.xml');
create pluggable database PDB1
using ('PDB1.xml') nocopy tempfile reuse;
start ?/rdbms/admin/noncdb_to_pdb.sql
CDB1
PDB$SEED
PDB1
xml
Read Only
noncdb_to_pdb.sql
Copyright © 2020 Oracle and/or its affiliates.
Oracle Multitenant | noncdb_to_pdb.sql
• Sanity script when plugging in a stand-alone database
• Irreversible
• Runs only once in the life of a database
• Rerunnable starting with 12.2
• Runtime depends ...
• See also:https://mikedietrichde.com/2017/06/08/noncdb_to_pdb-sql-take-long/
Copyright © 2020 Oracle and/or its affiliates.
Oracle Multitenant | Full Transportable Export/Import
• Create a new PDB
• Create a database link
• Set tablespaces read only in source
• Copy data files
• Run impdp:impdp oow/passwd@PDB1
NETWORK_LINK=DB1 VERSION=12 FULL=Y
TRANSPORTABLE=ALWAYS METRICS=Y
LOGFILE=oow_dir:src112fullimp.log
TRANSPORT_DATAFILES='/oradata/ts1.dbf' …
CDB1
PDB$SEED
TablespacesRead Only
Datab
ase Link
impdp
Copyright © 2020 Oracle and/or its affiliates.
Oracle Multitenant | Upgrade
Everything at once Unplug + Plug + Upgrade
CDB1
PDB$SEED
CDB1
PDB$SEED
PDB$SEED
CDB1
PDB$SEED
CDB2
PDB$SEED
PDB$SEED
Upgrade
UpgradeUpgrade
Upgrade
Upgrade
Copyright © 2020 Oracle and/or its affiliates.
Oracle Multitenant | PDB Archive
• Unplug the PDB including all files
• See also:https://mikedietrichde.com/2017/05/22/issue-with-pdb-archives-in-oracle-12-2-0-1-in-asm
ALTER PLUGGABLE DATABASE pdb1
UNPLUG INTO '/home/oracle/pdb1.pdb'
$ unzip pdb1.pdb
Archive: pdb1.pdb
inflating: system01.dbf
inflating: sysaux01.dbf
inflating: undotbs01.dbf
warning: stripped absolute path spec from /home/oracle/pdb1.xml
inflating: home/oracle/pdb1.xml
Copyright © 2020 Oracle and/or its affiliates.
Oracle Multitenant | Save State
• You need to startup a PDB• ALTER PLUGGABLE DATABASE pdb1 OPEN;
• By default PDBs need to be started manually• ALTER PLUGGABLE DATABASE pdb1 SAVE STATE;
• This preserves the last state of a PDB
• ALTER PLUGGABLE DATABASE pdb1 DISCARD STATE;
• This removes any state preservation
Copyright © 2020 Oracle and/or its affiliates.
Oracle Multitenant | CON_ID
• Views:• USER_...
• ALL_...
• DBA_...
• CDB_... - CDB_views have CON_ID column• Plus some very creative names: PDB_...
• CON_ID
• 0: Pertains to the entire database
• 1: Object belongs to CDB$ROOT container
• 2: Object belongs to PDB$SEEDSet _exclude_seed_cdb_view=FALSE to see PDB$SEED's objects
• 3-4096: Object belongs to PDB with this CON_ID
Copyright © 2020 Oracle and/or its affiliates.
Oracle Multitenant | Character Sets
• Since Oracle 12.2.0.1:• Mix of different character sets is possible
• CDB$ROOT must be AL32UTF8 to allow mixtures
Ph
oto
by
Erik
Eas
tman
on
Un
spla
sh
Copyright © 2020 Oracle and/or its affiliates.
Oracle Multitenant | Flashback PDB
• Requirement: Local Undo configured
• How to?• SQL> alter session set container=PDB1;
• SQL> create restore point GRP guarantee flashback database;
• <…do something …>
• SQL> shutdown immediate
• SQL> flashback pluggable database PDB1 to restore point GRP;
• SQL> alter pluggable database PDB1 open resetlogs; *
• SQL> drop restore point GRP;
Copyright © 2020 Oracle and/or its affiliates.
Multitenant | Silent Compatible Change
• Be aware when youunplug/plug betweendifferent environments• Default COMPATIBLE=19.0.0
• PDB's COMPATIBLE = CDB$ROOT's COMPATIBLE
No issue
• PDB's COMPATIBLE < CDB$ROOT's COMPATIBLE
PDB's COMPATIBLE will be increased automatically
No PDB downgrade will be possible in this case!
• PDB's COMPATIBLE > CDB$ROOT's COMPATIBLE
PDB can't be plugged in
Copyright © 2020 Oracle and/or its affiliates.
Au
tom
atically
COMPATIBLE=12.2.0
COMPATIBLE=19.0.0
COMPATIBLE=19.0.0
CDB1
PDB$SEED
CDB2
PDB$SEED
Migration Strategies
Migration to and Fallback with Oracle Multitenant
Copyright © 2020 Oracle and/or its affiliates.
Ph
oto
by
Jack
man
Ch
iuo
n U
nsp
lash
Move to Multitenant | High Level Overview
• Two approaches• Upgrade to matching version of CDB, then plugin as new PDB, then run sanity
script
• Migrate directly into PDB with Data Pump, TTS or FTEX
• Every approach requires unpredictable, often significant downtime• Can be reduced with Oracle GoldenGate
• Proven upgrade fallback strategies don't work• Export/import with Data Pump necessary as fallback
• Oracle GoldenGate can be used on top
Copyright © 2020 Oracle and/or its affiliates.
Move to Multitenant | Typical Pitfalls
• DB components (e.g. Spatial, Label Security, Java etc.) not matching
• Patch levels
• noncdb_to_pdb.sql requires downtime
• Some features work differently • Unified Auditing
• Standby implementation, especially in ASM
• Performance monitoring, e.g. AWR
Copyright © 2020 Oracle and/or its affiliates.
Move to Multitenant | Your "best" friend
• PDB_PLUG_IN_VIOLATIONS• select con_id, type, message, status from PDB_PLUG_IN_VIOLATIONS
where status<>'RESOLVED' order by time;
Copyright © 2020 Oracle and/or its affiliates.
Non-CDB to CDB | Migrate with any technique
• Includes Data Pump, Transportable Tablespaces etc.
Oracle 10.1.0.2
Provisionnew PDB
Oracle 19.5.0
CDB
PDB$SEED
1⃣
2⃣ Migrate
Copyright © 2020 Oracle and/or its affiliates.
Move to Multitenant | TTS MigrationSource - non-CDB Target - PDB
Views
Code
Grants
Trigger
DATATS
Alter UserCreate User
Set tablespaces read-only
Copy tablespace files DATATS
Export/import tablespace content info
Set tablespaces read-write
Rebuild logic (code, views, grants, roles, synonyms etc)
Views
Code
Grants
Trigger
Create new CDB/PDB
PDB$SEED
PDB
Copyright © 2020 Oracle and/or its affiliates.
Non-CDB to CDB | Data Pump with Dumpfile
Oracle 11.2.0.4
Provisionnew PDB
Oracle 19.3.0
CDB
PDB$SEED
1⃣
2⃣ expdp
DUMP FILE DUMP FILE
3⃣ impdp
Copyright © 2020 Oracle and/or its affiliates.
Non-CDB to CDB | Data Pump over NETWORK_LINK
Oracle 11.2.0.4
Provisionnew PDB
Oracle 19.3.0
CDB
PDB$SEED
1⃣2⃣
3⃣impdp withNETWORK_LINK
CreateDB Link
Copyright © 2020 Oracle and/or its affiliates.
Non-CDB to CDB | Fallback: Data Pump w. dumpfile
Oracle 11.2.0.4
Oracle 19.3.0
CDB
PDB$SEED
1⃣2⃣expdp withVERSION=11.2.0.4
DUMP FILE DUMP FILE
impdp
Copyright © 2020 Oracle and/or its affiliates.
Non-CDB to CDB | Upgrade
Oracle 11.2.0.4
Au
toU
pgr
ade
to O
racl
e 1
9c
Oracle 19.5.0
Oracle 19.5.0
CDB
PDB$SEED
Oracle 19.5.0
CDB
PDB$SEED
1️ ⃣
2️ ⃣ Plug into CDB
3️ ⃣ noncdb_to_pdb.sql
Copyright © 2020 Oracle and/or its affiliates.
Non-CDB to CDB | Upgrade - Fallback
Oracle 11.2.0.4
Au
toU
pgr
ade
to O
racl
e 1
9c
Oracle 19.5.0
Oracle 19.5.0
CDB
PDB$SEED
Oracle 19.5.0
CDB
PDB$SEED
1️ ⃣
2️ ⃣ Plug into CDB
3️ ⃣ noncdb_to_pdb.sql
Flashbackto GRP
Copyright © 2020 Oracle and/or its affiliates.
Move to Multitenant | Fallback for upgrades?
• Move to Multitenant is always a "Migration"
• Usual techniques don't exist• No downgrade
• No flashback to GRP
• Only available options• Data Pump export/import
• Oracle GoldenGate
Copyright © 2020 Oracle and/or its affiliates.
A typical example from the Real World
Migrating to Oracle Multitenant with a distant physical standby database in place
Copyright © 2020 Oracle and/or its affiliates.
Non-CDB to CDB with Standby | Initial Setup
Oracle 12.1.0.2
PROD10 TB size
Oracle 12.1.0.2
STBDY10 TB size
100 km distanceMaximum Protection
Copyright © 2020 Oracle and/or its affiliates.
Non-CDB to CDB with Standby | AutoUpgrade
Oracle 19.7.0
PROD
Oracle 12.1.0.2
STBDY
Disable Broker - Defer Log Transport
Copyright © 2020 Oracle and/or its affiliates.
Oracle 12.1.0.2
PROD
Non-CDB to CDB with Standby | Upgrade
Oracle 19.7.0
PRODOracle 12.1.0.2
STBDY
Oracle 19.7.0
PROD
Enable Log TransportEnable Broker
Copyright © 2020 Oracle and/or its affiliates.
Non-CDB to CDB with Standby | Upgrade
Oracle 12.1.0.2
STBDY
Oracle 19.7.0
PRODOracle 19.7.0
STBDY
Up
grad
evi
a R
edo
Ap
ply
Copyright © 2020 Oracle and/or its affiliates.
Non-CDB to CDB with Standby | Creation of CDB
Oracle 19.7.0
PRODOracle 19.7.0
STBDY
Oracle 19.7.0
PRODOracle 19.7.0
STBDY
CDB
PDB$SEED
CDB
PDB$SEED
Copyright © 2020 Oracle and/or its affiliates.
Non-CDB to CDB with Standby | Conversion
Oracle 19.7.0
PRODOracle 19.7.0
STBDY
Oracle 19.7.0
PRODOracle 19.7.0
STBDY
CDB
PDB$SEED
CDB
PDB$SEED
PDB1
xml
Read Only
noncdb_to_pdb.sql
(runtime varies)
ASMAliasList
Execute in standby ASM instance
>> DOWNTIME <<
Copyright © 2020 Oracle and/or its affiliates.
Non-CDB to CDB with Standby | Plugin of STBY
Oracle 19.7.0
PRODOracle 19.7.0
STBDY
Oracle 19.7.0
PRODOracle 19.7.0
STBDY
CDB
PDB$SEED
CDB
PDB$SEED
>> DOWNTIME <<
Copyright © 2020 Oracle and/or its affiliates.
Non-CDB to CDB with Standby | Plugin of STBY
• Read more …• Data Guard PM:
http://www.stepi.net/2019/06/08/to-cdb-or-not-to-cdb-thats-the-question/
• MAA Team:MOS Note: 2273304.1Reusing the Source Standby Database Files When Plugging a non-CDB as a PDB into the Primary Database of a Data Guard Configuration
Copyright © 2020 Oracle and/or its affiliates.
Move to Multitenant | Summary
• Every migration is an architectural change
• Every migration requires downtime• Incremental backup procedures can lower migration downtime
• Oracle GoldenGate can help decreasing the downtime
Copyright © 2020 Oracle and/or its affiliates.
Agenda
AutoUpgrade and CDB Migration
Oracle Multitenant
Further Information
Copyright © 2020 Oracle and/or its affiliates.
1
2
3
https://mikedietrichde.com/2019/07/22/database-migration-from-non-cdb-to-pdb-overview/
Copyright © 2020 Oracle and/or its affiliates.
https://mikedietrichde.com/2019/07/22/database-migration-from-non-cdb-to-pdb-overview/
Copyright © 2020 Oracle and/or its affiliates.
Further Information
Finally …
Copyright © 2020 Oracle and/or its affiliates.
Slides | https://MikeDietrichDE.com
Copyright © 2020 Oracle and/or its affiliates.
HOL | https://MikeDietrichDE.com
Copyright © 2020 Oracle and/or its affiliates.
Questions?
Thank you for your attention!
Copyright © 2020 Oracle and/or its affiliates.
Copyright © 2020 Oracle and/or its affiliates.
68
Oracle UniversityTraining Solutions
Laura Garcia VillarrealOU PreSales ManagerApril [email protected]
Copyright © 2020 Oracle and/or its affiliates.
Introducing Oracle University
Learning Methods
Oracle Database Multitenant Training
Program Agenda
Introducing Oracle University
Oracle University is the official provider of training and certification for Oracle technologies and products.
Copyright © 2020 Oracle and/or its affiliates.
Oracle University Provides Training Options for Every Learner and Business
Training On Demand
Recorded courses available via streaming for 90 days
Learning Subscription
Digital learning modules available via streaming for 1 year
Classroom Training
Traditional instructor-led training
Live Virtual Class
Instructor-led courses via Internet
Self-study Learning Instructor-led Training
Blended LearningCombination of instructor-led and self-study learning
Copyright © 2020 Oracle and/or its affiliates.
30% Discount on Oracle Learning Subscriptions until May 31st 2020
➢ Pre-recorded Videos
➢ Captions and transcript
➢ Skill Checks
➢ Virtual Labs
➢ Course Manual
➢ Ask the Instructor
Multitenant Training
• Inside Database Administration training path
• Versions supported: 19c, 18c and 12c
• 4 days training
• Main topics: CDB basics, PDB Creation, Security, Upgrades Methods, Backup&Duplicate, Storage, Data Movement…
• Multitenant environment available to run labs
Copyright © 2020 Oracle and/or its affiliates.
Questions?
Thank you for your attention!
Copyright © 2020 Oracle and/or its affiliates.
Copyright © 2020 Oracle and/or its affiliates.
75
Contact Me
Laura Garcia VillarrealOU PreSales ManagerApril [email protected]