Download presentation
Presentation is loading. Please wait.
Published byJonas Morris Modified over 9 years ago
1
REMINDER Check in on the COLLABORATE mobile app Pluggable Databases : Save money and time by harnessing the power of ORACLE for database consolidation Prepared by: John Larkin Sr. Database Administrator, OCP Advanced Database Services, LLC.. Session ID#: 830 John.larkin5@Verizon.net
2
Pluggable Databases : Save money and time cont’d ■Oracle DBA for 18 years. (28 yrs overall). ■OCP ■UNIX (Linux, Solaris, Aix, Windows) ■Multi-year project to migrate to RAC One-Node ■Major Financial, Chemical, publishing and retail industries. ■john.larkin5@verizon.net 2
3
Why do we want to use a Container Database? Retain cost savings and efficiencies of shared resources in the next generation server environment.
4
Pluggable Databases : Agenda ■Consolidation Overview ■Multitenant concepts ▪Scope ▪Currency ▪Services ▪Connections ▪Commonality ■Installation ■Physical Structure ■Migration – Get Plugged In ■Gotcha’s 4
5
Pluggable Databases : Save money and time cont’d ■Consolidation ▪Prior methods worked at different levels — Server — Schema –issues ▪Oracle Database 12c — Integrated into the database — Decreased cost — Higher density –Shared memory –Shared processes 5
6
Pluggable Databases : Save money and time cont’d 6 Figure 2: OLTP Benchmark Comparison Only 3 GB of memory vs. 20 GB memory used for 50 databases. Multitenant architecture scaled to over 250 DBs while separate database
7
Pluggable Databases : Save money and time cont’d ■Multitenant Container Database Concepts ▪The CDB – the backbone of Oracle’s multitenant architecture — holds the Containers — Root Container — Seed Pluggable database — Pluggable database – 0 or more — CDB is the instance –Demo –@d010 7
8
Pluggable Databases : Save money and time cont’d CDB is the instance – cont’d ■(sqlplus / as sysdba) Instance VERSION User Dbname -------------- -------------- --------- ---------------------- orcl12a 12.1.0.2.0 SYS ORCL12A CON_NAME CON_ID (CONTAINER information) ---------------- CDB$ROOT 1 (alter session set container=pdborcl12a1) CON_NAME CON_ID (PDB information) ---------------- PDBORCL12A1 3 8
9
Pluggable Databases : Save money and time cont’d CDB is the instance – cont’d (Windows Services window) 9
10
Pluggable Databases : Save money and time cont’d Some important Terms ■CDB – multitenant container database – the top level. ▪A database that holds the containers. ■Container - all within a CDB ▪collection of schemas, objects, related structures in a CDB ▪Appears to a client (user or application) as a separate database. ▪Unique ID and name within a CDB — Root and all PDB’s. — Indistinguishable from non-CDB (12c and all pre-12c) to users. –Unless… you’re a DBA. — Isolate and insulate 10
11
Pluggable Databases : Save money and time cont’d ■The ROOT container ▪CDB$ROOT ▪Only 1 per CDB ▪All PDB’s belong to it. ▪No user data ▪Common user (prefix/suffix modifiable) 11
12
Pluggable Databases : Save money and time cont’d ■PDB – Pluggable database, a container ▪Compatibility Guarantee — A PDB is fully compatible with a non-CDB — Application to run without code changes and deliver the same results — Init.ora changes might be needed ▪User-created ▪Owned by SYS common user ▪Looks like a standalone database ▪Segregate application data and code ▪Migrations — from one CDB to another — Upgrades 12
13
Pluggable Databases : Save money and time cont’d ■PDB cont’d ▪Services — PDB accessed by a service name that is the same as the PDB name –PDB name must conform to service naming standards ▪SCOPE — Name resolution - dictionary of the container where you’re connected –Dictionary is horizontally partitioned. — Schemas in different databases –Independent, different datastore »Even if owned by a common user — Behaves like a non-CDB 13
14
Pluggable Databases : Save money and time cont’d ■Data Dictionary Architecture/ ▪non-CDB dictionary — a mixture of Oracle-supplied and user-created objects ▪CDB Dictionaries appear to be separated by container — Data dictionary metadata is split between the root and the PDB’s — Views show different row counts in each container. — Keeps the oracle-owned and user-created objects separate. ▪ROOT — Oracle-owned objects ▪PDB — Unique user-created data — Pointers to ROOT dictionary 14
15
Pluggable Databases : Save money and time cont’d ■Data Dictionary Architecture cont’d ▪Reduce unnecessary duplication ▪Efficient upgrade path — i.e. DBMS_SCHEDULER package only in CDB$ROOT ■Dictionary Separation provided by Links ■Metadata Links ▪Managed automatically, not user-modifiable — maintain the metadata about dictionary objects in the root — column definitions for Oracle-owned table exist only in the ROOT — Metadata link in the PDB points to the definition in the ROOT –i.e. OBJ$ - defined in ROOT, data in PDB ▪User-defined objects reside completely in the PDB.(container) ▪Includes init.ora 15
16
Pluggable Databases : Save money and time cont’d ■Metadata Links cont’d ■Object Links - The other side of the coin — Store non-root container data for some special objects in the ROOT –AWR data (DBA_HIST_ACTIVE_SESSION) –Available to all containers. ■Container Data Objects (CDO (my term) ) ▪Tables/views - data from multiple containers and/or the CDB ▪built-in - restricts data based on common user permissions ▪Oracle-Supplied views - V$ and CDB_ are examples of CDO’s — CON_ID column – determine source — CDB_* data returned based on which container you’re connected to: –From ROOT – query metadata across all containers –From PDB – returns data only from that container 16
17
Pluggable Databases : Save money and time cont’d ■Container Data Objects cont’d ▪Container IDMaps To 0The Whole CDB or a non-CDB 1CDB$ROOT 2PDB$SEED 3+User-created PDB ▪DEMO @d020 17
18
Pluggable Databases : Save money and time cont’d ■CDB_ vs DBA_ ■ROOT:PDBORCL12a1: ■select count(*) ■ from CDB_tables ■ COUNT(*)COUNT(*) ■ ---------------------------- ■ 4747 2409 ■ ■select count(*) ■ from DBA_tables ■ COUNT(*)COUNT(*) ■ ---------------------------- ■ 2338 2409 18
19
Pluggable Databases : Save money and time cont’d ■Current Container ■The container in which the current session is running. ▪can be in the root, for common users ▪a PDB. ■A session has only one current container at any point in time. ▪name resolution /privilege authorization – curr. container’s dict. ■Cross container operation ▪DDL statement that affects the CDB, multiple containers, entities in common containers or a container different than the issuing user’s current container. ▪include database recovery and common user modifications. ■DEMO - files @d030 19
20
Pluggable Databases : Save money and time cont’d ■Services and Connections ■connect to a PDB using a service ▪starts a session in a PDB — current container - permanent for the lifetime of the session. 20
21
Pluggable Databases : Save money and time cont’d ■Demo ▪Standalone database — Upgrade to 12c — Other options, but more complicated ▪Read-Only ▪Describe the standalone db – generate xml manifest — dbms_pdb.describe() –Back it up w/ the datafiles – SCN in all must match ▪In CDB: — dbms_pdb.check_plug_compatibility — query pdb_plug_in_violations for ERRORS/WARNINGS(cdb$root) ▪Create PLUGGABLE DATABASE pdb1 using ‘c:\manifiest.xml’ ▪Run noncdb_to_pdb.sql in the NEW PDB. 21
22
Pluggable Databases : Save money and time cont’d DEMO cont’d ■Create description/manifest exec dbms_pdb.describe(pdb_descr_file=> 'C:\Data\Collab2015\noncdb12b.xml'); 22
23
Pluggable Databases : Save money and time cont’d DEMO cont’d DECLARE compatibility CONSTANT VARCHAR2(3) := CASE DBMS_PDB.CHECK_PLUG_COMPATIBILITY( pdb_descr_file => 'C:\Data\Collab2015\noncdb12b.xml', pdb_name => 'PDBORCL12A2') WHEN TRUE THEN 'Db to be PLUGGED in is COMPATIBLE' ELSE 'Db to be PLUGGED in is *** NOT COMPATIBLE ***' END; BEGIN DBMS_OUTPUT.PUT_LINE(compatibility); END; 23
24
Pluggable Databases : Save money and time cont’d DEMO cont’d ■Check for Errors (still in CDB$ROOT) ▪SET lines 200 ▪col message FOR a100 ▪SET pages 100 ▪SELECT name,cause,TYPE,message FROM PDB_PLUG_IN_VIOLATIONS WHERE name='PDBORCL12A2'; 24
25
Pluggable Databases : Save money and time cont’d ■DEMO cont’d ▪DEMO xx@d040 25
26
Pluggable Databases : Save money and time cont’d ■DEMO cont’d 26
27
Pluggable Databases : Save money and time cont’d ■Gotcha’s ▪Windows user accounts ▪Standardization — Database options — Database version ▪Multiple ways to get there ▪Non-CDBs are deprecated in 12c ▪Oracle recommends using CDBs (single-tenant or multitenant) ▪New paradigm – it’s coming, best to get used to it now ▪Noncdb_to_pdb.sql – errors out/closes sqlplus if not run from the PDB - duh. 27
28
Pluggable Databases : Save money and time cont’d 28 ■References ▪Tanel Poder ▪also see http://blog.yannickjaquier.com/oracle/multitenant- standalone-to-pluggable-migration.html
29
Please complete the session evaluation We appreciate your feedback and insight You may complete the session evaluation either on paper or online via the mobile app
30
Demo Scripts 30 -- --- DEMO START 0 ----------------- CDB/PDB select INSTANCE_NAME, CON_ID, VERSION, status, logins, shutdown_pending, DATABASE_STATUS, ACTIVE_STate from v$instance / prompt CDB/PDB info COLUMN name FORMAT A30 prompt SERVICEt info: SELECT name, pdb FROM v$services ORDER BY name / prompt CURRENT CONTAINER info: --col "Container" format a16 --col "Container_ID" format a16 col CON_NAME format a16 col CON_ID format a16 SELECT SYS_CONTEXT('USERENV', 'CON_NAME') "CON_NAME", SYS_CONTEXT('USERENV', 'CON_ID') "CON_ID" FROM dual / -- dupe name - diff datatype -- cdb_info.sql - almost te same as show pdbs col CON_ID format 999999999999 prompt PDB info: select CON_ID, --DBID, NAME, OPEN_MODE, --RESTRICTED SNAPSHOT_PARENT_CON_ID from v$pdbs / -- condollar - show all containers and id's select CON_ID#, DBID from sys.CONTAINER$ / -- cdatafile_info -- cdatafile_info.sql col file_name for a75 col TABLESPACE_NAME for a30 prompt CDB_data_files --select * from cdb_data_files select CON_ID, FILE_NAME, FILE_ID, Rpad(TABLESPACE_NAME, 30, '.') TABLESPACE_NAME, --BYTES --BLOCKS --STATUS --RELATIVE_FNO AUTOEXTENSIBLE, MAXBYTES, --MAXBLOCKS --INCREMENT_BY --USER_BYTES --USER_BLOCKS ONLINE_STATUS from cdb_data_files order by file_id / prompt DBA_DATA_FILES select 'NULL ' Conn_ID, FILE_NAME, FILE_ID, TABLESPACE_NAME, --BYTES --BLOCKS --STATUS --RELATIVE_FNO AUTOEXTENSIBLE, MAXBYTES, --MAXBLOCKS --INCREMENT_BY --USER_BYTES --USER_BLOCKS ONLINE_STATUS from dba_data_files order by file_id / set timing on -- --- CONVERT 1 ------------------ STANDALONE #rem In a PLAIN DOS window set ORACLE_SID=ncdb12b set SQLPATH=C:\Data\DBA\scripts\sql sqlplus / as sysdba set lin 200 set pages 49999 set sqlblanklines on select INSTANCE_NAME, VERSION, status, logins, shutdown_pending, DATABASE_STATUS, ACTIVE_STate, CON_ID from v$instance / -- in noncdb12b shutdown immediate startup mount exclusive select * from v$instance; alter database open read only; select * from v$instance; -- generate the manifest of the NONcdb - --writes SCN into the xml - matching the headers of the datafiles.. exec dbms_pdb.describe(pdb_descr_file=>'C:\Data\Oracle_Training\noncdb12bmodC1a.x ml'); -- --- CONVERT 2 ------------------ CDB -- IN CDB set feedback off SET SERVEROUTPUT ON DECLARE compatibility CONSTANT VARCHAR2(40) := CASE DBMS_PDB.CHECK_PLUG_COMPATIBILITY( pdb_descr_file => 'C:\Data\Oracle_Training\noncdb12bmodC1a.xml', pdb_name => 'PDBORCL12C1') WHEN TRUE THEN 'Db to be PLUGGED-IN is COMPATIBLE' ELSE 'Db to be PLUGGED-IN is *** NOT COMPATIBLE ***' END; BEGIN DBMS_OUTPUT.PUT_LINE('..'); DBMS_OUTPUT.PUT_LINE(compatibility); DBMS_OUTPUT.PUT_LINE('..'); END; / set feedback ON -- --- CONVERT 3 ------------------ non-CDB -- -- shutdown noncdb, prepare to copy the data files shutdown immediate -- copy files if necessary -- --- CONVERT 4 ------------------ CDB --... in the CDB -- this is BEFORE the create. (JM) SET lines 200 col message FOR a100 SET pages 100 SELECT name,cause,TYPE,message FROM PDB_PLUG_IN_VIOLATIONS WHERE name='PDBORCL12C1'; -- OR check for ANY prior db errors --SELECT name,cause,TYPE,message FROM PDB_PLUG_IN_VIOLATIONS --Create a PDB by using the noncdb manifest file. Use the file_name_convert parameter to place the copied data files in a different location. create pluggable database PDBORCL12C1 using 'C:\Data\Oracle_Training\noncdb12bmodC1a.xml' copy file_name_convert=('C:\app\oracle\oradata\ncdb12b', 'C:\APP\ORACLE\ORADATA\ORCL12A\ORCL12A\PDBORCL12B1') tempfile reuse -- CHECK ALERT LOGS for my 1st successful PLUGIN !!!! Tuesday. then recreate a 3rd and see if it was the exit cmd tha closed my window??? --@cdb -- show COntainer information prompt CDB/PDB info COLUMN name FORMAT A30 prompt SERVICEt info: SELECT name, pdb FROM v$services ORDER BY name / prompt CURRENT CONTAINER info: --col "Container" format a16 --col "Container_ID" format a16 col CON_NAME format a16 col CON_ID format a16 SELECT SYS_CONTEXT('USERENV', 'CON_NAME') "CON_NAME", SYS_CONTEXT('USERENV', 'CON_ID') "CON_ID" FROM dual / -- dupe name - diff datatype -- cdb_info.sql - almost te same as show pdbs col CON_ID format 999999999999 prompt PDB info: select CON_ID, --DBID, NAME, OPEN_MODE, --RESTRICTED SNAPSHOT_PARENT_CON_ID from v$pdbs / 3.Finalize the plug-in by opening the new PDB, closing it, and then reopening it. alter pluggable database PDBORCL12C1 open; alter pluggable database PDBORCL12C1 close; alter pluggable database PDBORCL12C1 open; -- change to the PDB !!!!!!! --...in PDB --@altp -- altp.sql -- USAGE - pass the #ic protion of the pdb name, already have the prefix (pdborcl) in place. PROMPT USAGE - pass the #ic portion of the pdb name, already have the prefix (pdborcl) in place. ALTER SESSION SET container = pdborcl&1 / -- script is in the CDB's ORACLE_HOME @?\rdbms\admin\noncdb_to_pdb.sql -- start 1:48, end 2:10 --closes session if not in the NEW PDB! -- WAITING for conversion to complete - review more CDB details --...... approximately 20 min on a laptop -- Notice the datafiles from the new PDB are not visible from the CDB ROOT yet. --@cdatafile_info -- cdatafile_info.sql col file_name for a75 col TABLESPACE_NAME for a30 prompt CDB_data_files --select * from cdb_data_files select CON_ID, FILE_NAME, FILE_ID, Rpad(TABLESPACE_NAME, 30, '.') TABLESPACE_NAME, --BYTES --BLOCKS --STATUS --RELATIVE_FNO AUTOEXTENSIBLE, MAXBYTES, --MAXBLOCKS --INCREMENT_BY --USER_BYTES --USER_BLOCKS ONLINE_STATUS from cdb_data_files order by file_id / prompt DBA_DATA_FILES select 'NULL ' Conn_ID, FILE_NAME, FILE_ID, TABLESPACE_NAME, --BYTES --BLOCKS --STATUS --RELATIVE_FNO AUTOEXTENSIBLE, MAXBYTES, --MAXBLOCKS --INCREMENT_BY --USER_BYTES --USER_BLOCKS ONLINE_STATUS from dba_data_files order by file_id -- check the registry col comp_id for a10 col comp_name for a35 col version for a12 col status for a12 select * from registry$history select COMP_ID, COMP_NAME, VERSION, STATUS, MODIFIED from dba_registry -- The datafiles from the new PDB will be visible from the CDB ROOT AFTER the restart. -- Need close/reopen to get everything in sync alter pluggable database PDBORCL12C1 CLOSE alter pluggable database PDBORCL12C1 OPEN -- now see files across ALL containers. --@cdatafile_info -- cdatafile_info.sql col file_name for a75 col TABLESPACE_NAME for a30 prompt CDB_data_files --select * from cdb_data_files select CON_ID, FILE_NAME, FILE_ID, Rpad(TABLESPACE_NAME, 30, '.') TABLESPACE_NAME, --BYTES --BLOCKS --STATUS --RELATIVE_FNO AUTOEXTENSIBLE, MAXBYTES, --MAXBLOCKS --INCREMENT_BY --USER_BYTES --USER_BLOCKS ONLINE_STATUS from cdb_data_files order by file_id / prompt DBA_DATA_FILES select 'NULL ' Conn_ID, FILE_NAME, FILE_ID, TABLESPACE_NAME, --BYTES --BLOCKS --STATUS --RELATIVE_FNO AUTOEXTENSIBLE, MAXBYTES, --MAXBLOCKS --INCREMENT_BY --USER_BYTES --USER_BLOCKS ONLINE_STATUS from dba_data_files order by file_id /
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.