一、多租户框架

多租户技术(英语:multi-tenancy technology)或称多重租赁技术,是一种软件架构技术,它是在探讨与实现如何于多用户的环境下共用相同的系统或程序组件,并且仍可确保各用户间数据的隔离性。

1.1CDB与PDB

多租户技术(英语:multi-tenancy technology)或称多重租赁技术,是一种软件架构技术,它是在探讨与实现如何于多用户的环境下共用相同的系统或程序组件,并且仍可确保各用户间数据的隔离性。

Oracle 12c Multitenant Architecture多租户框架最重要的2个概念是容器数据库(CDB,multitenant container database)和可热插拔数据库(pluggable databases,PDB)。可以把CDB想象成一个大的容器,这个大的容器在物理上是一个整体,在这个大的容器中还有一些小的容器PDB。容器的目的是将Oracle固有元数据和用户数据(包括用户元数据)隔离。

The multitenant architecture enables an Oracle database to function as a multitenant container database (CDB) that includes zero, one, or many customer-created pluggable databases (PDBs). A PDB is a portable collection of schemas, schema objects, and nonschema objects that appears to an Oracle Net client as a non-CDB.

CDB(容器数据库) :

其实就是我们以前的数据库,只是它被分成了几部分,每一部分(即PDB)都能作为一个整体(数据库)对外独立提供服务,就像多个以前传统的非容器数据库。

PDB(可插拔式数据库):

一系列Schema的集合,从用户和应用看来是一个逻辑上独立的数据库。但是在物理角度上,实例和所有数据库文件都是属于容器数据库(CDB)的。

Container Database (CDB) :

On the surface this seems very similar to a conventional Oracle database, as it contains most of the working parts you will be already familiar with (controlfiles, datafiles, undo, tempfiles, redo logs etc.). It also houses the data dictionary for those objects that are owned by the root container and those that are visible to all PDBs.

Pluggable Database (PDB) :

Since the CDB contains most of the working parts for the database, the PDB only needs to contain information specific to itself. It does not need to worry about controlfiles, redo logs and undo etc. Instead it is just made up of datafiles and tempfiles to handle it's own objects. This includes it's own data dictionary, containing information about only those objects that are specific to the PDB.

1.2和传统非容器数据库的对比

使用

CREATE DATABASE ... ENABLE PLUGGABLE DATABASE

可以创建一个新的CDB. 如果不带 ENABLE PLUGGABLE DATABASE, 则新创建的数据库为非容器数据库(non-CDB ),不能包含PDB。我们将容器数据库和传统的非容器数据库放在同一个server上比对,很容易概括出Oracle公司即将推出的Oracle 12c容器数据库和可插拔式数据库的基本架构。

从文件角度:

图示PDBA、PDBB、PDBC、CDB1和NDB。其中PDBA、PDBB、PDBC均属于容器数据库CDB1的可插拔式数据库,NDB则为传统的非容器数据库。所以也可以这样描述:只有两个数据库CDB1和NDB保存在存储设备上。

从实例角度:

在图示服务器节点上,运行着两个实例,对应的数据库分别是CDB1和NDB。可以清楚地看到只有容器数据库和非容器数据库才有对应的实例,可插拔式数据库PDBA、PDBB和PDBC共用容器数据库的实例,并没有自身对应的实例。

从服务角度:

传统的非容器数据库可以通过实例名或服务名链接,但是可插拔式数据库只能通过服务名链接。至于容器数据库,就像一个非容器数据库一样,同样可以通过实例名或服务名链接。

二、CDB中的container

2.1三种容器类型

一个容器数据库CDB含有3种类型的容器(如下图所示)

1、 ROOT容器,  CDB$ROOT,有且只有一个。包含元数据信息和Common User(在各个容器内都有效的用户,比如sys),

2、 SEED容器,  PDB$SEED,有且只有一个。它就是一个模板,新的PDB可以基于这个模板进行创建

3、 PDB容器,    0~n个,也是最重要的,包含用户数据,我们的创建的表就放在这里。

Exactly one root

The root stores Oracle-supplied metadata and common users. An example of metadata is the source code for Oracle-supplied PL/SQL packages (see "Data Dictionary Architecture in a CDB"). A common user is a database user known in every container (see "Common Users in a CDB"). The root container is named CDB$ROOT.

Exactly one seed PDB

The seed PDB is a system-supplied template that the CDB can use to create new PDBs. The seed PDB is named PDB$SEED. You cannot add or modify objects in PDB$SEED.Since the bulk of the working parts are already present in the root container, creating a new PDB is a comparatively quick and simple task. When creating a completely new PDP, the PDB is created as a copy of a seed PDB, so it only takes as long as the files take to copy.

 Zero or more user-created PDBs

A PDB is a user-created entity that contains the data and code required for a specific set of features. For example, a PDB can support a specific application, such as a human resources or sales application. No PDBs exist at creation of the CDB. You add PDBs based on your business requirements.

2.2三种容器类型的进一步解释:

Seed是生成PDB的模板。可以通过直接复制Seed快速创建PDB

每个容器里都包含一个SYSTEM表空间保存数据字典信息:

1. 在Root容器中的SYSTEM数据字典里只保存Oracle固有元数据(只针对Oracle提供的对象,比如DBMS_%的包等等)。

2. 在每个可插拔式数据库(容器)中的SYSTEM数据字典只保存用户在可插拔式数据库创建的对象的元数据。

如图所示,EMP和DEPT表的数据字典信息只保存在可插拔式数据库的OBJ$和TAB$里,Root容器中的OBJ$和TAB$里并没有EMP和DEPT表的相关信息。不管一个容器数据库里有多少个可插拔式数据库,物理上的数据库只有一个,但是它的SYSTEM表空间确有许多个,数量等于可插拔式数据库的数量加一(Root容器的SYSTEM表空间)。

如上图,逻辑层,包含一个Root,一个Seed,两个PDB.不同的应用使用不同的PDB.不同的PDB 管理员管理各自的PDB.而整个CDB的Common User(比如sys)可以管理整个CDB包含的所有的Container。而在物理层,只对应一个数据库实例。

三、多租户(Multitenant)的实现对比

 

3.1.独立数据库

这是第一种方案,即一个租户一个数据库,这种方案的用户数据隔离级别最高,安全性最好,但成本也高。

优点:

为不同的租户提供独立的数据库,有助于简化数据模型的扩展设计,满足不同租户的独特需求;如果出现故障,恢复数据比较简单。

缺点:

一个客户、一套数据、一套部署。增大了数据库的安装数量,随之带来维护成本和购置成本的增加。如果面对的是银行、医院等需要非常高数据隔离级别的租户,可以选择这种模式,否则这种方案一般来说是无法承受的。

3.2. 共享数据库、独立 Schema

这是第二种方案,即多个或所有租户共享Database,但一个Tenant一个Schema。(下图的上半部分)

优点:

为安全性要求较高的租户提供了一定程度的逻辑数据隔离,并不是完全隔离;每个数据库可以支持更多的租户数量。

缺点:

如果出现故障,数据恢复比较困难,因为恢复数据库将牵扯到其他租户的数据;如果需要跨租户统计数据,存在一定困难。管理、安全性、数据迁移都有困难。

因此就发生了如下的变化

3.3不同的PDB

好处:

  • 整合多个小系统的数据库
  • 统一管理,物理上共用REDO和UNDO;
  • 节省成本
  • 数据便捷移动
  • 易于迁移
  • 易于应用测试
  • 便于物理数据库的管理和监控
  • PDB级别的数据恢复、隔离
  • 减少数据库管理任务
  • Oracle Database Resource Manager
  • 统一备份、统一升级
  • 职权分离
  • 最适合大的数据中心项目

  • Cost reduction

By consolidating hardware and sharing database memory and files, you reduce costs for hardware, storage, availability, and labor. For example, 100 PDBs on a single server share one database instance and one set of database files, thereby requiring less hardware and fewer personnel.

  • Easier and more rapid movement of data and code

By design, you can quickly plug a PDB into a CDB, unplug the PDB from the CDB, and then plug this PDB into a different CDB. The implementation technique for plugging and unplugging is similar to the transportable tablespace technique.

  • Easier management and monitoring of the physical database

The CDB administrator can attend to one physical database (one set of files and one set of database instances) rather than split attention among dozens or hundreds of non-CDBs. Backup strategies and disaster recovery are simplified.

  • Separation of data and code

Although consolidated into a single physical database, PDBs mimic the behavior of non-CDBs. For example, if user error loses critical data, a PDB administrator can use Oracle Flashback or point-in-time recovery to retrieve the lost data without affecting other PDBs.

  • Secure separation of administrative duties

A user account is common, which means that it can connect to any container on which it has privileges, or local, which means that it is restricted to a specific PDB. A CDB administrator can use a common user account to manage the CDB. A PDB administrator uses a local account to manage an individual PDB. Because a privilege is contained within the container in which it is granted, a local user on one PDB does not have privileges on other PDBs within the same CDB.

  • Ease of performance tuning

It is easier to collect performance metrics for a single database than for multiple databases. It is easier to size one SGA than 100 SGAs.

  • Support for Oracle Database Resource Manager

In a multitenant environment, one concern is contention for system resources among the PDBs running on the same computer. Another concern is limiting resource usage for more consistent, predictable performance. To address such resource contention, usage, and monitoring issues, you can use Oracle Database Resource Manager (see "Database Resource Manager").

  • Fewer database patches and upgrades

It is easier to apply a patch to one database than to 100 databases, and to upgrade one database than to upgrade 100 databases.

The multitenant architecture has benefits beyond database consolidation. These benefits derive from storing the data and data dictionary metadata specific to a PDB in the PDB itself rather than storing all dictionary metadata in one place. By storing its own dictionary metadata, a PDB becomes easier to manage as a distinct unit, even when only one PDB resides in a CDB.

Benefits of data dictionary separation include the following:

  • Easier migration of data and code

For example, instead of upgrading a CDB from one database release to another, you can unplug a PDB from the existing CDB, and then plug it into a newly created CDB from a higher release.

  • Easier testing of applications

You can develop an application on a test PDB and, when it is ready for deployment, plug this PDB into the production CDB.

四、举例

图片上展示的是一个容器数据库,其内包含4个容器:Root容器和三个可插拔式数据库。不同应用App1、App2和App3使用不同的不同PDB,每个可插拔式数据库为特定应用提供数据。通过将非容器数据库作为可插拔式数据库“插入”容器数据库,很容易实现数据集中,实现对多个数据库的合一管理,从而提高服务器的资源利用效率。三个应用所使用的数据库它们既可以被三个不同的DBA管理也能够由一个容器数据库DBA统一管理,即用户SYS。用户SYS在这种架构中是典型的“通用”用户,SYS可以登录在全部4个容器上,并且具备SYSDBA权限。经过有效的整合,这样可以减少成本、降低管理的复杂度。

在一个容器数据库内的可插拔式数据库共享后台进程、SGA和数据字典。容器数据库避免了以下结构不必要的冗余: 后台进程、内存、数据字典内的元数据

同时App1、App2和App3具备各自的数据文件。不同应用对于不同PDB数据库内容进行分别管理,可插拔式数据库也拥有各自独立的数据字典以及各自独立的用户(应用)数据,又保障了应用之间所需的独立性与安全性。

参考:

Introduction to the Multitenant Architecture

verview of Container Databases (CDB) and Pluggable Databases (PDB)

Oracle 12c多租户架构总结

Multitenant Architecture---PDB与CDB的更多相关文章

  1. oracle 12c 创建PDB用户即Local User (PDB与CDB)

    Oracle 12C用户创建与表空间分配  数据库安装完成后,首先用系统用户链接数据库容器(CDB), 在数据库容器(CDB)中创建表空间‘imei’ SQL>create tablespace ...

  2. jdbc-connect-oracle12c-pdb/cdb(jdbc连接oracle12c的pdb和cdb)

      1       本文简介: 通过特意引发问题,聚焦问题,解决问题,并循序渐进 最后总结jdbc连接oracle12c中cdb和pdb的条件. 软件环境:Redhat7.1+orcacle12c 2 ...

  3. Oracle 12C -- plug unplugged PDB into CDB

    connetct to CDB as a common user and verify that pdb_test is closed SQL> select con_id,dbid,name, ...

  4. Oracle12c多租户如何连接到CDB或PDB、CDB与PDB容器切换

    Oracle 数据库 12 c 多租户选项允许单个容器数据库 (CDB) 来承载多个单独的可插拔数据库 (PDB).那么我们如何连接到容器数据库 (CDB) 和可插拔数据库 (PDB). 1. V$S ...

  5. Oracle 12c PDB和CDB全局用户权限问题

    Oracle12c版本中引入了新的CDB和PDB 默认登陆CDB后创建的用户为全局用户必须以c##开头 如果要访问CDB中的表,可以用GRANT命令赋权 但是上面的赋权并不会再PDB中生效 如果要这个 ...

  6. Upgrade a Non-CDB To a PDB on CDB

    .Stop the cluster database and start database on one node with read noly [oracle@raca1 admin]$ srvct ...

  7. Oracle12cr1新特性之容器数据库(CDB)和可插拔数据库(PDB) 的启动和关闭

    Oracle12c中引入的多宿主选项(multitenant option)允许一个容器数据库容纳多个独立的可插拔数据库(PDB).本文将说明如何启动和关闭容器数据库(CDB)和可插拔数据库(PDB) ...

  8. Oracle Multitenant Environment (五) Create PDB

    Creating and Removing PDBs with SQL*Plus This chapter contains the following topics: About Creating ...

  9. CDB中plug PDB

    CDB中plug PDB 先决条件: ·CDB要能够访问之前被unplugged 的pdb的xml文件.如果不能访问,需要使用dbms_pdb.recover创建一个xml文件 ·CDB要能够访问到该 ...

随机推荐

  1. 实用ExtJS教程100例-004:等待对话框Ext.MessageBox.wait

    在前面两节中,我们分别演示了ExtJS三种常用的对话框和ExtJS带有进度条的对话框.在本节内容中,我们来看看ExtJS中的等待对话框. 首先来看一个简单的例子[查看在线示例]: 这种对话框会一直滚动 ...

  2. 无需SherlockActionbar的SlidingMenu使用详解(二)——向Fragment中添加ViewPager和Tab

    之前我们对大体框架有了一定的认识,现在我们来做Fragment界面,其实这里面和这个框架的关系就不大了,但因为有些同学对于在SlidingMenu中切换fragment还是有问题,所以我就在本篇进行详 ...

  3. COPY ORCHARD GET 404: System.UnauthorizedAccessException: mappings.bin的访问被拒绝

    COPY ORCHARD 得到 404 错误,结果翻看Logs,得到的错误是: 014-07-31 17:36:46,217 [16] Orchard.Environment.DefaultOrcha ...

  4. REST构架风格介绍之一:状态表述转移

    转载自:Todd Wei   http://www.cnblogs.com/weidagang2046/archive/2009/05/08/1452322.html REST(Representat ...

  5. 【deep learning学习笔记】注释yusugomori的DA代码 --- dA.h

    DA就是“Denoising Autoencoders”的缩写.继续给yusugomori做注释,边注释边学习.看了一些DA的材料,基本上都在前面“转载”了.学习中间总有个疑问:DA和RBM到底啥区别 ...

  6. 关于UI设计中的交互软件Axure7.0运用

    Axure RP是一个专业的快速原型设计工具.让负责定义需求和规格.设计功能和界面的人员能够快速创建应用软件或Web网站的线框图.流程图.原型和规格说明文档. 作为专业的原型设计工具,它能快速.高效的 ...

  7. MFC中onmouseover与onmousemove的区别

    onmouseover与onmousemove的区别是:当鼠标移过当前对象时就产生了onmouseover事件,当鼠标在当前对象上移动时就产生了onmousemove事件,只要是在对象上移动而且没有移 ...

  8. Android -- AudioPlayer

    AudioPlayer 主要是实现边录边播(AudioRecord+AudioTrack)以及对音频的实时处理(如会说话的汤姆猫.语音) 优点:语音的实时处理,可以用代码实现各种音频的封装 缺点:输出 ...

  9. WordPress 获取指定分类ID的分类信息

    get_term:直接从数据库中获取分类信息get_the_category:使用post_id作为参数,先根据post_id查询对应的文章然后再返回对应的分类信息,如果没有文章信息则返回Null 之 ...

  10. Python防止sql注入

    看了网上文章,说的都挺好的,给cursor.execute传递格式串和参数,就能防止注入,但是我写了代码,却死活跑不通,怀疑自己用了一个假的python 最后,发现原因可能是不同的数据库,对于字符串的 ...