ORACLE--12C--创建PDB
Posted kingle66
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ORACLE--12C--创建PDB相关的知识,希望对你有一定的参考价值。
一,关于创建介绍
1,介绍
CDB支持多种创建PDB的技术。默认CBD会有一个PDB$SEED
创建的PDB自动包括完整数据字典,包括元数据和CDB根目录中系统提供的对象的内部链接。您必须从单个根定义每个PDB:CDB根或应用程序根。
创建的方式由下图体现
每个PDB都有一个全局唯一标识符(GUID)。PDB GUID主要用于为存储PDB文件的目录生成名称,包括Oracle Managed Files目录和非Oracle Managed Files目录。
hrpdb是从种子pdb创建(克隆)的新pdb。
SalesPDB是驻留在远程CDB中的PDB的克隆。
test1是名为hrpdb的本地pdb的克隆。
test2是通过插入非cdb创建的pdb。
test3是通过插入未插入的PDB而创建的PDB。
test4是一个代理pdb,它是引用不同pdb的pdb。在这种情况下,代理PDB是本地的,而引用的PDB在单独的CDB中。在test4中发出的所有语句都在远程pdb中执行。
二,通过seed生成创建PDB
1,介绍
seed 是PDB,用作创建另一个PDB的模板。从种子创建复制PDB的部分或全部内容,然后分配新的唯一标识符。
CDB seed(PDB$SEED
),它是系统提供的用于创建PDB的模板 每个CDB都有一个CDB种子,不能修改或删除。
一个application seed 这是一个用户创建的PDB为指定的应用程序根, 在应用程序容器中,您可以使用该CREATE PLUGGABLE DATABASE AS SEED
语句创建应用程序种子,然后可以使用该语句来加速新应用程序PDB的创建。
从SEED中创建一个PDB
2,操作手册
01,创建文件
创建的时候需要有pdbseed的数据文件位置创建
create pluggable database hrpdb ADMIN USER test IDENTIFIED BY 123456 FILE_NAME_CONVERT = (\'/orcl/app/oracle/oradata/orcl/pdbseed\',\'/orcl/app/oracle/oradata/orcl/hrpdb\');
指定FILE_NAME_CONVERT 第一个位默认PDBSEED的位置,第二个为创建的位置
查看系统默认的seed,默认路径再数据文件下
点击创建命令后
已经可以看见创建成功了
日志:
1 create pluggable database hrpdb ADMIN USER test IDENTIFIED BY * FILE_NAME_CONVERT = (\'/orcl/app/oracle/oradata/orcl/pdbseed\',\'/orcl/app/oracle/oradata/orcl/hrpdb\') 2 2019-04-12T04:14:57.750018-04:00 3 PDB$SEED(2): AUDSYS.AUD$UNIFIED (SQL_TEXT) - CLOB populated 4 2019-04-12T04:15:04.217160-04:00 5 HRPDB(4):Endian type of dictionary set to little 6 **************************************************************** 7 Pluggable Database HRPDB with pdb id - 4 is created as UNUSABLE. 8 If any errors are encountered before the pdb is marked as NEW, 9 then the pdb must be dropped 10 local undo-1, localundoscn-0x00000000000000e1 11 **************************************************************** 12 HRPDB(4):Autotune of undo retention is turned on. 13 HRPDB(4):[23505] Successfully onlined Undo Tablespace 2. 14 HRPDB(4):Undo initialization finished serial:0 start:867397895 end:867397934 diff:39 ms (0.0 seconds) 15 HRPDB(4):Database Characterset for HRPDB is AL32UTF8 16 HRPDB(4):JIT: pid 23505 requesting stop 17 2019-04-12T04:15:05.403748-04:00 18 Completed: create pluggable database hrpdb ADMIN USER test IDENTIFIED BY * FILE_NAME_CONVERT = (\'/orcl/app/oracle/oradata/orcl/pdbseed\',\'/orcl/app/oracle/oradata/orcl/hrpdb\') 19 2019-04-12T04:23:36.621717-04:00 20 Starting control autobackup 21 22 2019-04-12T04:23:37.668547-04:00 23 Control autobackup written to DISK device 24 25 handle \'/orcl/app/oracle/fast_recovery_area/orcl/NODE12C01/autobackup/2019_04_12/o1_mf_s_1005366216_gc0lr92c_.bkp\' 26 27 2019-04-12T04:26:16.183955-04:00 28 HRPDB(4):alter database open 29 HRPDB(4):Autotune of undo retention is turned on. 30 2019-04-12T04:26:16.263808-04:00 31 HRPDB(4):Endian type of dictionary set to little 32 HRPDB(4):[21105] Successfully onlined Undo Tablespace 2. 33 HRPDB(4):Undo initialization finished serial:0 start:868069298 end:868069348 diff:50 ms (0.1 seconds) 34 HRPDB(4):Deleting old file#5 from file$ 35 HRPDB(4):Deleting old file#6 from file$ 36 HRPDB(4):Deleting old file#8 from file$ 37 HRPDB(4):Adding new file#13 to file$(old file#5) 38 HRPDB(4):Adding new file#14 to file$(old file#6) 39 HRPDB(4):Adding new file#15 to file$(old file#8) 40 HRPDB(4):Successfully created internal service hrpdb at open 41 **************************************************************** 42 Post plug operations are now complete. 43 Pluggable database HRPDB with pdb id - 4 is now marked as NEW. 44 **************************************************************** 45 HRPDB(4):Database Characterset for HRPDB is AL32UTF8 46 HRPDB(4):Opatch validation is skipped for PDB HRPDB (con_id=0) 47 2019-04-12T04:26:18.750044-04:00 48 HRPDB(4):Opening pdb with no Resource Manager plan active 49 Pluggable database HRPDB opened read write 50 HRPDB(4):Completed: alter database open
02,链接打开hrpdb
alter session set container=hrpdb;
show pdbs alter database open; show pdbs; show con_name
03 关闭hrpdb
alter pluggable database hrpdb close immediate; 关闭 alter pluggable database hrpdb open; 开启
三,通过克隆的方式创建PDB
01,克隆
查看当前位置
注意:不再这个用户报错显示如下,
ERROR at line 1: ORA-65040: operation not allowed from within a pluggable database
克隆时保证PDB为只读模式下进行
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 ORCLPDB READ WRITE NO
4 HRPDB READ ONLY NO
创建命令:
CREATE PLUGGABLE DATABASE salespdb FROM hrpdb FILE_NAME_CONVERT = (\'/orcl/app/oracle/oradata/orcl/hrpdb\', \'/orcl/app/oracle/oradata/orcl/salespdb\') STORAGE (MAXSIZE 1G);
创建发生的日志:
CREATE PLUGGABLE DATABASE salespdb FROM hrpdb FILE_NAME_CONVERT = (\'/orcl/app/oracle/oradata/orcl/hrpdb\', \'/orcl/app/oracle/oradata/orcl/salespdb\') STORAGE (MAXSIZE 1G) 2019-04-12T04:50:33.236510-04:00 HRPDB(4): AUDSYS.AUD$UNIFIED (SQL_TEXT) - CLOB populated 2019-04-12T04:50:37.334873-04:00 SALESPDB(5):Endian type of dictionary set to little **************************************************************** Pluggable Database SALESPDB with pdb id - 5 is created as UNUSABLE. If any errors are encountered before the pdb is marked as NEW, then the pdb must be dropped local undo-1, localundoscn-0x00000000000000e1 **************************************************************** SALESPDB(5):Autotune of undo retention is turned on. SALESPDB(5):[24804] Successfully onlined Undo Tablespace 2. SALESPDB(5):Undo initialization finished serial:0 start:869530424 end:869530448 diff:24 ms (0.0 seconds) SALESPDB(5):Database Characterset for SALESPDB is AL32UTF8 SALESPDB(5):JIT: pid 24804 requesting stop Completed: CREATE PLUGGABLE DATABASE salespdb FROM hrpdb FILE_NAME_CONVERT = (\'/orcl/app/oracle/oradata/orcl/hrpdb\', \'/orcl/app/oracle/oradata/orcl/salespdb\') STORAGE (MAXSIZE 1G)
启动:
alter pluggable database salespdb open;
查看
四,克隆不包括数据的PDB
1 SQL> alter session set container= SALESPDB; 2 3 Session altered. 4 5 SQL> show pdbs 6 7 CON_ID CON_NAME OPEN MODE RESTRICTED 8 ---------- ------------------------------ ---------- ---------- 9 5 SALESPDB READ WRITE NO 10 SQL> show con_name 11 12 CON_NAME 13 ------------------------------ 14 SALESPDB 15 SQL> create table t(id number); 16 17 Table created. 18 19 SQL> 20 SQL> insert into t values(1); 21 22 1 row created. 23 24 SQL> commit; 25 26 Commit complete. 27 28 SQL> select count(*) from t; 29 30 COUNT(*) 31 ---------- 32 1
SQL> alter session set container=CDB$ROOT 2 ; Session altered. SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 ORCLPDB READ WRITE NO 4 HRPDB READ ONLY NO 5 SALESPDB READ WRITE NO 必须为只读模式下创建 SQL> alter pluggable database SALESPDB close immediate 2 ; Pluggable database altered. SQL> alter pluggable database SALESPDB open READ ONLY; Pluggable database altered. SQL> CREATE PLUGGABLE DATABASE testq FROM SALESPDB FILE_NAME_CONVERT = (\'/orcl/app/oracle/oradata/orcl/SALESPDB\', \'/orcl/app/oracle/oradata/orcl/testq \') NO DATA;
CREATE PLUGGABLE DATABASE testq FROM SALESPDB FILE_NAME_CONVERT = (\'/orcl/app/oracle/oradata/orcl/SALESPDB\', \'/orcl/app/oracle/oradata/orcl/testq \') NO DATA;
五,通过插入创建PDB
续写敬请期待
以上是关于ORACLE--12C--创建PDB的主要内容,如果未能解决你的问题,请参考以下文章
Oracle 12C -- 使用seed PDB创建新的pdb