ITPub博客

首页 > 数据库 > Oracle > 12c中CDB和PDB初识

12c中CDB和PDB初识

原创 Oracle 作者:hooca 时间:2016-05-11 12:08:30 0 删除 编辑
一个CDB对应多个PDB;
CDB拥有供多个PDB共用的SGA, 控制文件,redo日志,undo表空间;
CDB会自动创建一个SEED PDB,当要创建多个PDB时可以用它来复制;
PDB拥有自己的SYSTEM和SYSAUX表空间;
PDB可以共享CDB的临时表空间(组),也可以拥有自己的临时表空间(组);
CDB和PDB必须同时为归档或非归档模式。

1. 创建(DBCA)


上例中,创建了名为cdb1的CDB,在它之下又创建了一个名为pdb1的PDB。

2. 为PDB创建本地服务名

DBCA会自动为CDB创建本地服务名,但不会为PDB创建。因此需要自行创建。
创建什么服务名前需先看监听器的状态输出

点击(此处)折叠或打开

  1. lsnrctl status
  2. LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 11-MAY-2016 11:40:00

    Copyright (c) 1991, 2014, Oracle.  All rights reserved.

    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=may.demo.com)(PORT=1521)))
    STATUS of the LISTENER
    ------------------------
    Alias                     LISTENER
    Version                   TNSLSNR for Linux: Version 12.1.0.2.0 - Production
    Start Date                11-MAY-2016 10:36:33
    Uptime                    0 days 1 hr. 3 min. 27 sec
    Trace Level               off
    Security                  ON: Local OS Authentication
    SNMP                      OFF
    Listener Parameter File   /u01/app/oracle/product/12.1.0/db_1/network/admin/listener.ora
    Listener Log File         /u01/app/oracle/diag/tnslsnr/may/listener/alert/log.xml
    Listening Endpoints Summary...
      (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=may.demo.com)(PORT=1521)))
      (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
      (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=may.demo.com)(PORT=5500))(Security=(my_wallet_directory=/u01/app/oracle/admin/cdb1/xdb_wallet))(Presentation=HTTP)(Session=RAW))
    Services Summary...
    Service "cdb1.demo.com" has 1 instance(s).
      Instance "cdb1", status READY, has 1 handler(s) for this service...
    Service "cdb1XDB.demo.com" has 1 instance(s).
      Instance "cdb1", status READY, has 1 handler(s) for this service...
    Service "pdb1.demo.com" has 1 instance(s).
      Instance "cdb1", status READY, has 1 handler(s) for this service...
    The command completed successfully

上例中注册到监听器的服务名为pdb1.demo.com(当初创建时加了域名),因此创建本地服务名时需以此输入。

3. 通过sqlplus访问

点击(此处)折叠或打开

  1. #访问CDB,ORACLE_SID为cdb1
  2. sqlplus / as sysdba
  3. SQL> select * from cdb_pdbs;
  4.     PDB_ID
    ----------
    PDB_NAME
    --------------------------------------------------------------------------------
          DBID    CON_UID GUID                             STATUS    CREATION_SCN
    ---------- ---------- -------------------------------- --------- ------------
           VSN LOGGING   FOR FOR     CON_ID
    ---------- --------- --- --- ----------
             3
    PDB1
     791810194  791810194 3289542D519744A7E05305E2A8C09552 NORMAL         1749576
     202375680 LOGGING   NO  NO           3


        PDB_ID
    ----------
    PDB_NAME
    --------------------------------------------------------------------------------
          DBID    CON_UID GUID                             STATUS    CREATION_SCN
    ---------- ---------- -------------------------------- --------- ------------
           VSN LOGGING   FOR FOR     CON_ID
    ---------- --------- --- --- ----------
             2
    PDB$SEED
    1676147930 1676147930 32892164997F3FB9E05305E2A8C0606B NORMAL         1594410
     202375680 LOGGING   NO  NO           2

    #CDB有完整的表空间

    SQL> select tablespace_name from cdb_tablespaces;

    TABLESPACE_NAME
    ------------------------------
    SYSTEM
    SYSAUX
    UNDOTBS1
    TEMP
    USERS
    SYSTEM
    SYSAUX
    TEMP
    USERS


再访问PDB

点击(此处)折叠或打开

  1. sqlplus sys@pdb1 as sysdba
  2. #实例名仍然是CDB1
  3. SQL> select instance_name,status from v$instance;

    INSTANCE_NAME    STATUS
    ---------------- ------------
    cdb1             OPEN

    #V$DATABASE视图和CDB相同

    SQL> select dbid,name,cdb from v$database;

          DBID NAME      CDB
    ---------- --------- ---
     885276504 CDB1      YES

    #只显示自身(PDB1),没有了SEED PDB

    SQL> select * from cdb_pdbs;

        PDB_ID
    ----------
    PDB_NAME
    --------------------------------------------------------------------------------
          DBID    CON_UID GUID                             STATUS    CREATION_SCN
    ---------- ---------- -------------------------------- --------- ------------
           VSN LOGGING   FOR FOR     CON_ID
    ---------- --------- --- --- ----------
             3
    PDB1
     791810194  791810194 3289542D519744A7E05305E2A8C09552 NORMAL         1749576
     202375680 LOGGING   NO  NO           3



    #表空间“减少”了


    SQL> select tablespace_name from cdb_tablespaces;

    TABLESPACE_NAME
    ------------------------------
    SYSTEM
    SYSAUX
    TEMP
    USERS


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/22621861/viewspace-2097722/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2009-09-29

  • 博文量
    225
  • 访问量
    433697