首页 » Cloud, ORACLE 9i-23ai » oracle 12c Database Architecture (CDB、PDB)

oracle 12c Database Architecture (CDB、PDB)

In Oracle Database Server 12C, there is an architectural separation (Split Data Dictionary) between Core Oracle System with User Applications they are loosely coupled. Pluggable

Database Architecture consists of
1) Container Database (CDB)
2) Pluggable Database (PDB)

1) Container Database (CDB) : Holds Oracle System dictionary , functionality and metadata required to run the database. Memory and Process required for multiple PDB will be

handled by a single CDB.

2) Pluggable Database (PDB) : This holds only user application metadata or customer metadata or dictionary. This has read only permission on oracle dictionary. In cloud each

Pluggable Database is analogous to single Customer. There is clean separation between each pluggable database .


[oracle@db231 ~]$ ls
adr_purge   login.sql     ora10stdby.env  ora12cenv.sh  show_segment_above_size.sql
backup     datapump      ora10genv.sh  ora11genv.sh    printtab.sql  upgrade_info.log

[oracle@db231 ~]$source  ora12cenv.sh
[oracle@db231 ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.1.0 Production on Fri Jun 28 10:53:33 2013

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

sys@ORA12C>show con_name
CON_NAME
------------------------------
CDB$ROOT

sys@ORA12C>select dbid,db_unique_name,name,cdb,con_id,con_dbid from v$database;
                DBID DB_UNIQUE_NAME                 NAME      CDB               CON_ID             CON_DBID
-------------------- ------------------------------ --------- --- -------------------- --------------------
           197013683 ora12c                         ORA12C    YES                    0            197013683

sys@ORA12C>select con_id,dbid,con_uid,name,open_mode from v$pdbs;
              CON_ID                 DBID              CON_UID NAME                           OPEN_MODE
-------------------- -------------------- -------------------- ------------------------------ ----------
                   2           4061817652           4061817652 PDB$SEED                       READ ONLY
                   3           3326953675           3326953675 PDB1                           READ WRITE



sys@ORA12C>alter session set container=pdb1;
Session altered.

sys@ORA12C>show con_name
CON_NAME
------------------------------
PDB1

sys@ORA12C>select dbid,db_unique_name,name,cdb,con_id,con_dbid from v$database;
                DBID DB_UNIQUE_NAME                 NAME      CDB               CON_ID             CON_DBID
-------------------- ------------------------------ --------- --- -------------------- --------------------
           197013683 ora12c                         ORA12C    YES                    0           3326953675

sys@ORA12C>alter session set container=cdb$root;
Session altered.

Single CDB will support 250 pluggable databases or more.This new feature is compatible with older Oracle databases also .pluggable databases can be plugged or unplugged to the container database at any point of time.

sys@ORA12C>alter pluggable database pdb1 close;
Pluggable database altered.

sys@ORA12C>select con_id,dbid,con_uid,name,open_mode from v$pdbs;

              CON_ID                 DBID              CON_UID NAME                           OPEN_MODE
-------------------- -------------------- -------------------- ------------------------------ ----------
                   2           4061817652           4061817652 PDB$SEED                       READ ONLY
                   3           3326953675           3326953675 PDB1                           MOUNTED

sys@ORA12C>alter pluggable database pdb1 open;
Pluggable database altered.

Patching and upgrades : Apply patch once then all pluggable databases will be updated. You can clone a PDB within the same CDB or into another CDB. PDBs can also be provisioned very fast as each CDB comes with a “PDB Seed” from where the new PDB can be fast provisioned. So the provisioning becomes very fast.

Redeployment becomes much easier as we can unplug the database from one platform or a CDB version and then plug it into a CDB which is in another platform or version. This will make the upgrade, patching and redeployment efforts much faster! When you upgrade the CDB, all the PDBs will get upgraded. If you would like to control when the PDBs should

be upgraded, you can create another CDB version and then unplug from the old release and then plug in to the new database release. All PDB contents are separate from each other PDB so the “separation of duties” works very well as well.

sys@ORA12C>alter session set container=pdb1;
Session altered.

sys@ORA12C>select file_name from dba_data_files;
FILE_NAME
--------------------------------------------------
/u01/app/oracle/oradata/ora12c/pdb1/system01.dbf
/u01/app/oracle/oradata/ora12c/pdb1/sysaux01.dbf
/u01/app/oracle/oradata/ora12c/pdb1/pdb1_users01.dbf

sys@ORA12C>alter session set container=pdb$seed;
Session altered.

sys@ORA12C>select file_name from dba_data_files;
FILE_NAME
--------------------------------------------------
/u01/app/oracle/oradata/ora12c/pdbseed/system01.dbf
/u01/app/oracle/oradata/ora12c/pdbseed/sysaux01.dbf

Creating a PDB from the Seed. (you can cloning a Remote PDB with db_link)

sys@ORA12C>alter session set pdb_file_name_convert='pdbseed','pdb2';
Session altered.

sys@ORA12C>create pluggable database erpdb admin user anbob identified by anbob;
Pluggable database created.

sys@ORA12C>select con_id,dbid,con_uid,name,open_mode from v$pdbs;

              CON_ID                 DBID              CON_UID NAME                           OPEN_MODE
-------------------- -------------------- -------------------- ------------------------------ ----------
                   2           4061817652           4061817652 PDB$SEED                       READ ONLY
                   3           3326953675           3326953675 PDB1                           READ WRITE
                   4           4263343173           4263343173 ERPDB                          MOUNTED

sys@ORA12C>alter session set container=erpdb;

sys@ORA12C>alter pluggable database erpdb open;

sys@ORA12C>select file_name from dba_data_files;
FILE_NAME
--------------------------------------------------
/u01/app/oracle/oradata/ora12c/pdb2/system01.dbf
/u01/app/oracle/oradata/ora12c/pdb2/sysaux01.dbf

Cloning a Local PDB Using No Clauses,The source PDB must be in open read-only mode.

sys@ORA12C>show con_name
CON_NAME
------------------------------
ERPDB
sys@ORA12C>create pluggable database drmdb from erpdb ;
create pluggable database drmdb from erpdb
                                          *
ERROR at line 1:
ORA-65016: FILE_NAME_CONVERT must be specified


sys@ORA12C>alter session set pdb_file_name_convert='pdb2','drmdb';
Session altered.

sys@ORA12C>create pluggable database drmdb from erpdb ;
create pluggable database drmdb from erpdb
*
ERROR at line 1:
ORA-65040: operation not allowed from within a pluggable database

sys@ORA12C>alter session set container=cdb$root;
Session altered.

sys@ORA12C>create pluggable database drmdb from erpdb ;
create pluggable database drmdb from erpdb
*
ERROR at line 1:
ORA-65081: database or pluggable database is not open in read only mode


sys@ORA12C>alter pluggable database erpdb close;
Pluggable database altered.

sys@ORA12C>alter pluggable database erpdb open read only;
Pluggable database altered.

sys@ORA12C>create pluggable database drmdb from erpdb ;
Pluggable database created.

create account in CDB and PDB

in cdb account name must start with c##  or C##

sys@ORA12C>alter session set container=cdb$root;
sys@ORA12C>create user c##anbob identified by anbob ;
sys@ORA12C>conn c##anbob/anbob
Connected.
c##anbob@ORA12C>

in pdb


sys@ORA12C>alter session set container=erpdb;
sys@ORA12C>create user anbob identified by anbob;

[oracle@db231 ~]$ lsnrctl status
...
Services Summary...
Service "drmdb" has 1 instance(s).
  Instance "ora12c", status READY, has 1 handler(s) for this service...
Service "erpdb" has 1 instance(s).
  Instance "ora12c", status READY, has 1 handler(s) for this service...
Service "ora12c" has 1 instance(s).
  Instance "ora12c", status READY, has 1 handler(s) for this service...
Service "ora12cXDB" has 1 instance(s).
  Instance "ora12c", status READY, has 1 handler(s) for this service...
Service "pdb1" has 1 instance(s).
  Instance "ora12c", status READY, has 1 handler(s) for this service...
The command completed successfully

[oracle@db231 ~]$ sqlplus anbob/anbob@192.168.168.231/erpdb

SQL*Plus: Release 12.1.0.1.0 Production on Fri Jun 28 12:50:02 2013

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

anbob@ERPDB>

sys@ORA12C>l
  1  select con_id, tablespace_name, file_name
  2* from cdb_data_files
sys@ORA12C>/

              CON_ID TABLESPACE_NAME                FILE_NAME
-------------------- ------------------------------ ------------------------------------------------------------
                   5 SYSTEM                         /u01/app/oracle/oradata/ora12c/drmdb/system01.dbf
                   5 SYSAUX                         /u01/app/oracle/oradata/ora12c/drmdb/sysaux01.dbf
                   4 SYSTEM                         /u01/app/oracle/oradata/ora12c/pdb2/system01.dbf
                   4 SYSAUX                         /u01/app/oracle/oradata/ora12c/pdb2/sysaux01.dbf
                   3 SYSTEM                         /u01/app/oracle/oradata/ora12c/pdb1/system01.dbf
                   3 SYSAUX                         /u01/app/oracle/oradata/ora12c/pdb1/sysaux01.dbf
...
                   1 UNDOTBS1                       /u01/app/oracle/oradata/ora12c/undotbs01.dbf
                   1 USERS                          /u01/app/oracle/oradata/ora12c/users01.dbf
                   2 SYSTEM                         /u01/app/oracle/oradata/ora12c/pdbseed/system01.dbf
                   2 SYSAUX                         /u01/app/oracle/oradata/ora12c/pdbseed/sysaux01.dbf

Open all Oracle 12c Pluggable Databases (PDB)
alter pluggable database all open

Close all Oracle 12c Pluggable Databases (PDB) in CDB

alter pluggable database all close

–just writen for test

打赏

目前这篇文章有1条评论(Rss)评论关闭。

  1. admin | #1
    2013-06-28 at 13:13

    drop a pdb

    DROP PLUGGABLE DATABASE salespdb
    INCLUDING DATAFILES; — or keep datafiles