Heim > Datenbank > MySQL-Tutorial > Hauptteil

ORACLE 12C新特性CDB与PDB

WBOY
Freigeben: 2016-06-07 15:24:49
Original
1222 Leute haben es durchsucht

Oracle 12C引入了CDB与PDB的新特性,在ORACLE 12C数据库引入的多租用户环境(Multitenant Environment)中,允许一个数据库容器(CDB)承载多个可插拔数据库(PDB)。CDB全称为Container Database,中文翻译为数据库容器,PDB全称为Pluggable Database,即可

Oracle 12C引入了CDB与PDB的新特性,在ORACLE 12C数据库引入的多租用户环境(Multitenant Environment)中,允许一个数据库容器(CDB)承载多个可插拔数据库(PDB)。CDB全称为Container Database,中文翻译为数据库容器,PDB全称为Pluggable Database,即可插拔数据库。在ORACLE 12C之前,实例与数据库是一对一或多对一关系(RAC):即一个实例只能与一个数据库相关联,数据库可以被多个实例所加载。而实例与数据库不可能是一对多的关系。当进入ORACLE 12C后,实例与数据库可以是一对多的关系。下面是官方文档关于CDB与PDB的关系图。

 

ORACLE 12C新特性CDB与PDB

其实大家如果对SQL SERVER比较熟悉的话,这种CDB与PDB是不是感觉和SQL SERVER的单实例多数据库架构是一回事呢。像PDB$SEED可以看成是master、msdb等系统数据库,PDBS可以看成用户创建的数据库。而可插拔的概念与SQL SERVER中的用户数据库的分离、附加其实就是那么一回事。看来ORACLE也“抄袭”了一把SQL SERVER的概念,只是改头换面的包装了一番。

 

 

CDB组件(Components of a CDB)

 

一个CDB数据库容器包含了下面一些组件:

ROOT组件

ROOT又叫CDB$ROOT, 存储着ORACLE提供的元数据和Common User,元数据的一个例子是ORACLE提供的PL/SQL包的源代码,Common User 是指在每个容器中都存在的用户。

SEED组件

  Seed又叫PDB$SEED,这个是你创建PDBS数据库的模板,你不能在Seed中添加或修改一个对象。一个CDB中有且只能有一个Seed. 这个感念,个人感觉非常类似SQL SERVER中的model数据库。

PDBS

    CDB中可以有一个或多个PDBS,PDBS向后兼容,可以像以前在数据库中那样操作PDBS,这里指大多数常规操作。

这些组件中的每一个都可以被称为一个容器。因此,ROOT(根)是一个容器,Seed(种子)是一个容器,每个PDB是一个容器。每个容器在CDB中都有一个独一无二的的ID和名称。

 

1)连接到CDB数据库

连接到CDB数据库容器非常简单,跟以前连接数据库是一样的

ORACLE 12C新特性CDB与PDB

<span>[</span><span>oracle@get-orasvr02 ~</span><span>]</span>$ sqlplus <span>/</span> <span>as</span><span> sysdba

SQL</span><span>*</span>Plus: Release <span><strong>12.1</strong></span>.<span><strong>0.1</strong></span>.<span><strong>0</strong></span> Production <span>on</span> Sun Oct <span><strong>20</strong></span> <span><strong>23</strong></span>:<span><strong>41</strong></span>:<span><strong>36</strong></span> <span><strong>2013</strong></span><span>

Copyright (c) </span><span><strong>1982</strong></span>, <span><strong>2013</strong></span>, Oracle.  <span>All</span><span> rights reserved.

Connected </span><span>to</span><span> an idle instance.

SQL</span><span>></span>

<span>[</span><span>oracle@get-orasvr02 ~</span><span>]</span>$ sqlplus sys<span>/</span>password   <span>as</span><span> sysdba

SQL</span><span>*</span>Plus: Release <span><strong>12.1</strong></span>.<span><strong>0.1</strong></span>.<span><strong>0</strong></span> Production <span>on</span> Sun Oct <span><strong>20</strong></span> <span><strong>23</strong></span>:<span><strong>43</strong></span>:<span><strong>17</strong></span> <span><strong>2013</strong></span><span>

Copyright (c) </span><span><strong>1982</strong></span>, <span><strong>2013</strong></span>, Oracle.  <span>All</span><span> rights reserved.

Connected </span><span>to</span><span> an idle instance.

SQL</span><span>></span>
Nach dem Login kopieren

ORACLE 12C新特性CDB与PDB

 

2)查看数据库是否为CDB

ORACLE 12C新特性CDB与PDB

SQL<span>></span> <span>select</span> name, decode(cdb, <span>'</span><span>YES</span><span>'</span>, <span>'</span><span>Multitenant Option enabled</span><span>'</span>, <span>'</span><span>Regular 12c Database: </span><span>'</span>) "Multitenant <span>Option</span>" , open_mode, con_id <span>from</span> v$<span>database</span><span>;

NAME      Multitenant </span><span>Option</span><span>                   OPEN_MODE                CON_ID

</span><span>--</span><span>------- -----------------------------   --------------------         ----------</span>
<span>
EPPS      Multitenant </span><span>Option</span> enabled            <span>READ</span> WRITE                  <span><strong>0</strong></span>
Nach dem Login kopieren

ORACLE 12C新特性CDB与PDB

 

YES表示该数据库是CDB,如果是NO表示是NO-CDB(普通数据库)

 

3)查看当前容器(Container)

3.1

ORACLE 12C新特性CDB与PDB

SQL<span>></span><span> show con_name

CON_NAME

</span><span>--</span><span>----------------------------</span>
<span>
CDB$ROOT

SQL</span><span>></span>

<span><strong>3.2</strong></span><span>

SQL</span><span>></span> <span>select</span> sys_context(<span>'</span><span>userenv</span><span>'</span>, <span>'</span><span>con_name</span><span>'</span>) "Container DB" <span>from</span><span> dual;

Container DB

</span><span>--</span><span>--------------------------------------------------</span>
<span>
CDB$ROOT

SQL</span><span>></span>
Nach dem Login kopieren

ORACLE 12C新特性CDB与PDB

 

4)查看CDB容器中的PDBS信息

查看CDB中有多少个pluggable database

ORACLE 12C新特性CDB与PDB

SQL<span>></span>  <span>select</span> con_id, dbid, guid, name , open_mode <span>from</span><span> v$pdbs;

    CON_ID       DBID GUID                             NAME                           OPEN_MODE

</span><span>--</span><span>-------- ---------- -------------------------------- ------------------------------ ----------</span>

         <span><strong>2</strong></span> <span><strong>4071321146</strong></span> E89E8DA2866E3157E043DE07A8C09238 PDB$SEED                       <span>READ</span> <span>ONLY</span>

         <span><strong>3</strong></span> <span><strong>1930201447</strong></span><span> E89E9418B882350CE043DE07A8C092B6 PDBEPPS                        MOUNTED

SQL</span><span>></span>
Nach dem Login kopieren

ORACLE 12C新特性CDB与PDB

 

5)启动PDB数据库

方式1:

ORACLE 12C新特性CDB与PDB

SQL<span>></span> <span>alter</span> pluggable <span>database</span> PDBEPPS <span>open</span><span>;

Pluggable </span><span>database</span><span> altered.

SQL</span><span>></span> <span>select</span> con_id, dbid, guid, name , open_mode <span>from</span><span> v$pdbs;

    CON_ID       DBID GUID                             NAME                           OPEN_MODE

</span><span>--</span><span>-------- ---------- -------------------------------- ------------------------------ ----------</span>

         <span><strong>2</strong></span> <span><strong>4071321146</strong></span> E89E8DA2866E3157E043DE07A8C09238 PDB$SEED                       <span>READ</span> <span>ONLY</span>

         <span><strong>3</strong></span> <span><strong>1930201447</strong></span> E89E9418B882350CE043DE07A8C092B6 PDBEPPS                         <span>READ</span> WRITE
Nach dem Login kopieren

ORACLE 12C新特性CDB与PDB

 

方式2:

ORACLE 12C新特性CDB与PDB

SQL<span>></span> <span>alter</span> session <span>set</span> container<span>=</span><span>PDBEPPS;

Session altered.

SQL</span><span>></span><span> startup

Pluggable </span><span>Database</span><span> opened.

SQL</span><span>></span>
Nach dem Login kopieren

ORACLE 12C新特性CDB与PDB

 

6)关闭PDB数据库

SQL> alter pluggable database PDBEPPS close;

Pluggable database altered.

SQL> select con_id, dbid, guid, name , open_mode from v$pdbs;

    CON_ID       DBID GUID                             NAME                           OPEN_MODE

---------- ---------- -------------------------------- ------------------------------ ----------

         2 4071321146 E89E8DA2866E3157E043DE07A8C09238 PDB$SEED                       READ ONLY

         3 1930201447 E89E9418B882350CE043DE07A8C092B6 PDBEPPS                        MOUNTED

SQL>

 

 

7)在容器间切换

SQL> alter session set container=PDBEPPS;

Session altered.

SQL> show con_name;

CON_NAME

------------------------------

PDBEPPS

SQL>

SQL> alter session set container=CDB$ROOT;

Session altered.

SQL> show con_name;

CON_NAME

------------------------------

CDB$ROOT


参考资料:

http://docs.oracle.com/cd/E16655_01/server.121/e17636/cdb_intro.htm

http://www.orasos.com/4445.html

http://www.oracle-base.com/articles/12c/multitenant-connecting-to-cdb-and-pdb-12cr1.php

http://www.orasos.com/4445.html

Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage