sitemap

RSS地图

收藏本站

设为首页

Oracle研究中心

当前位置:Oracle研究中心 > 运维DBA >

学习笔记:Oracle 12C 新特性PDB部分功能详细测试

时间:2016-06-16 22:32   来源:Oracle研究中心   作者:惜分飞   点击:

天萃荷净 记录一下关于Oracle数据库最新版本12C新特性的PDB的部分功能,通过案例进行测试学习

ORACLE 12C中提出来CDB和PDB的概念,对于ORACLE的数据库来说,确实是一个新东西,他们可以分别理解为容器和插件(PDB插入在CDB中),CDB的管理和传统数据库区别不大,本篇文章对PDB的部分操作进行了简单说明(创建PDB,OPEN PDB,DROP PDB,Plug PDB,Unplugging PDB)

1.新建立create pdb

SQL> SELECT NAME,CDB FROM  V$DATABASE;

NAME      CDB
--------- ---
oracleplus  YES

SQL> select pdb_id,pdb_name,dbid,STATUS,CREATION_SCN  from dba_pdbs;

    PDB_ID PDB_NAME                             DBID STATUS        CREATION_SCN
---------- ------------------------------ ---------- ------------- ------------
         2 PDB$SEED                       4044122081 NORMAL             1661281
         3 FF                             1565322182 NORMAL             1720654


SQL> CREATE PLUGGABLE DATABASE oracle_db ADMIN USER oracle IDENTIFIED BY oracleplus
  2  STORAGE (MAXSIZE 2G MAX_SHARED_TEMP_SIZE 100M)
  3  DEFAULT TABLESPACE oracleplus
  4  DATAFILE '/u01/app/oracle/oradata/oracleplus/oracle/oracleplus01.dbf' SIZE 25M AUTOEXTEND ON
  5  PATH_PREFIX = '/u01/app/oracle/oradata/oracleplus/oracle/'
  6  FILE_NAME_CONVERT = ('/u01/app/oracle/oradata/oracleplus/pdbseed/', 
  7  '/u01/app/oracle/oradata/oracleplus/oracle/');

Pluggable database created.

SQL> select pdb_id,pdb_name,dbid,STATUS,CREATION_SCN  from dba_pdbs;

    PDB_ID PDB_NAME                             DBID STATUS        CREATION_SCN
---------- ------------------------------ ---------- ------------- ------------
         2 PDB$SEED                       4044122081 NORMAL             1661281
         3 FF                             1565322182 NORMAL             1720654
         4 oracle_DB                         2272981748 NEW                1771028

2.打开OPEN PDB

SQL> alter pluggable database oracle_db open;

Pluggable database altered.

SQL> select pdb_id,pdb_name,dbid,STATUS,CREATION_SCN  from dba_pdbs;

    PDB_ID PDB_NAME                             DBID STATUS        CREATION_SCN
---------- ------------------------------ ---------- ------------- ------------
         2 PDB$SEED                       4044122081 NORMAL             1661281
         3 FF                             1565322182 NORMAL             1720654
         4 oracle_DB                         2272981748 NORMAL             1771028

SQL>  alter pluggable database all close immediate;

Pluggable database altered.

SQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs;

    CON_ID       DBID NAME                           OPEN_MODE
---------- ---------- ------------------------------ ----------
         2 4044122081 PDB$SEED                       READ ONLY
         3 1565322182 FF                             MOUNTED
         4 2272981748 oracle_DB                         MOUNTED

SQL> alter pluggable database all open;

Pluggable database altered.

SQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs;

    CON_ID       DBID NAME                           OPEN_MODE
---------- ---------- ------------------------------ ----------
         2 4044122081 PDB$SEED                       READ ONLY
         3 1565322182 FF                             READ WRITE
         4 2272981748 oracle_DB                         READ WRITE

Unplugging a PDB from a CDB

SQL> alter pluggable database FF close immediate;

Pluggable database altered.

SQL> alter  pluggable database ff UNPLUG into '/tmp/ff.xml';

Pluggable database altered.

DROP PDB

SQL> DROP PLUGGABLE DATABASE oracle_db INCLUDING DATAFILES;

Pluggable database dropped.

SQL> DROP PLUGGABLE DATABASE ff INCLUDING DATAFILES;

Pluggable database dropped.

Plug Unplugged PDB into CDB

SQL> SELECT NAME,CDB FROM  V$DATABASE;

NAME      CDB
--------- ---
oracle_L     YES

SQL> create pluggable database ff using '/tmp/ff.xml'
  2  copy file_name_convert=('/u01/app/oracle/oradata/oracleplus/FF/','/u01/app/oracle/oradata/oracle_l/oracle');

Pluggable database created.

SQL> exec DBMS_PDB.SYNC_PDB();

PL/SQL procedure successfully completed.

SQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs;

    CON_ID       DBID NAME                           OPEN_MODE
---------- ---------- ------------------------------ ----------
         2 4043918109 PDB$SEED                       READ ONLY
         3 2346805300 LX1                            MOUNTED
         4 2385557792 LX2                            MOUNTED
         5 1565384817 FF                             MOUNTED

SQL> alter pluggable database all open;

Pluggable database altered.

SQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs;

    CON_ID       DBID NAME                           OPEN_MODE
---------- ---------- ------------------------------ ----------
         2 4043918109 PDB$SEED                       READ ONLY
         3 2346805300 LX1                            READ WRITE
         4 2385557792 LX2                            READ WRITE
         5 1565384817 FF                             READ WRITE

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/oracle_l/system01.dbf
/u01/app/oracle/oradata/oracle_l/pdbseed/system01.dbf
/u01/app/oracle/oradata/oracle_l/sysaux01.dbf
/u01/app/oracle/oradata/oracle_l/pdbseed/sysaux01.dbf
/u01/app/oracle/oradata/oracle_l/undotbs01.dbf
/u01/app/oracle/oradata/oracle_l/users01.dbf
/u01/app/oracle/oradata/oracle_l/LX1/system01.dbf
/u01/app/oracle/oradata/oracle_l/LX1/sysaux01.dbf
/u01/app/oracle/oradata/oracle_l/LX1/LX1_users01.dbf
/u01/app/oracle/oradata/oracle_l/LX2/system01.dbf
/u01/app/oracle/oradata/oracle_l/LX2/sysaux01.dbf
/u01/app/oracle/oradata/oracle_l/LX2/LX2_users01.dbf
/u01/app/oracle/oradata/oracle_l/oraclesystem01.dbf
/u01/app/oracle/oradata/oracle_l/oraclesysaux01.dbf
/u01/app/oracle/oradata/oracle_l/oracleSAMPLE_SCHEMA_users01.dbf
/u01/app/oracle/oradata/oracle_l/oracleexample01.dbf

16 rows selected.

补充说明:本部分内容比较多,本篇blog,只是对其中的很小一部分进行了测试,确实证明可以对pdb实现在不同的cdb中实现迁移,对于该项操作,可以在dbca和gc中实现相同操作.由于12c数据库尚未正式发布,该部分功能只是出于个人测试目的.


--------------------------------------ORACLE-DBA----------------------------------------

最权威、专业的Oracle案例资源汇总之学习笔记:Oracle 12C 新特性PDB部分功能详细测试

本文由大师惜分飞原创分享,网址:http://www.oracleplus.net/arch/400.html

Oracle研究中心

关键词:

Oracle 12C

数据库12C新特性PDB部分功能详细测试