Oracle 12C 中CDB和PDB的参数文件管理

0    65    1

👉 本文共约28334个字,系统预计阅读时间或需107分钟。

Oracle 12C 中CDB和PDB的参数文件管理

img

每个 CDB 有一个 SPFILE 用于存储参数。参数值与根相关联,应用于根,并且可用作所有其他容器的默认值。可以在 PDB 中为参数设置不同的值,前提是 V$PARAMETER 中的列 ISPDB_MODIFIABLE 为 TRUE 。这些值全部在 PDB 作用域内设置,在 PDB 关闭再打开后以及在 CDB 实例关闭又启动后都会相应地保留。执行克隆和移走 / 插入操作后,也会保留。其他初始化参数只能针对根设置。

SQL> select PDB_UID, NAME, VALUE$ from pdb_spfile$;

PDB_UID NAME VALUE$


3100074415 optimizer_use_sql_plan_baselines FALSE

2862146267 optimizer_use_sql_plan_baselines FALSE

2862146267 ddl_lock_timeout 10

PDB 的参数存储在 CDB 的 PDB_SPFILE$ 字典表中以 con_id 区别,所以, PDB 的 PDB_SPFILE$ 表是空的。

col NAME format a25

col value$ format a30

select a.pdb_uid , b.NAME , a.name , a.value$

from pdb_spfile$ a , v$pdbs b

where a.pdb_uid = b.CON_UID

order by b.NAME ;

SELECT * FROM V$SYSTEM_PARAMETER d where d.NAME='db_create_file_dest';

SELECT * FROM cdb_tables d where d.TABLE_NAME='PDB_SPFILE$';

http://blog.itpub.net/26736162/viewspace-2213348/

修改 PDB 中的初始化参数,事实:

l PDB 从根 CDB 继承参数值,除非它们在 PDB 级别被重写。

l 普通的 “ ALTER System ”命令用于修改 PDB 级别的参数,但持久性机制不同。

l PDB 级别的初始化参数不是存储在 SPFILE 中,而是存储在 C DB 的数据字典 PDB_SPFILE$ 内部表中。

l 对于整个 CDB 及其所有 PDBs ,只有一个 物理 spfile 。打开根 CDB 时读取此 spfile 。

l 与 PDB 的 spfile 等价的是 CDB 的 PDB_SPFILE$ 表。

l 每个容器都有一个 PDB_SPFILE$ 表 (CDB$root 和所有 PDB) 。但是,只有 CDB 的 PDB_SPFILE$ 表包含为 PDB 专门设置的参数。

l 只要根的 CDB 是打开的, PDBs 中的 SPFILE 总是被启用的。即使 CDB 不使用 SPFILE , Oracle 也允许 PDB 使用 SPFILE ,因为 PDB 没有任何其他方法用于持久参数 (PDB 不支持 Pfile 或 init.ora 文件 ) 。

l 在 PDB 中只能在本地修改整个 Oracle DB 初始化参数的一个子集。使用 V$PARAMETER.ISPDB_AUDIBE= ‘ YES ’查找这些参数。

l PDB 级别的参数在数据库重新启动的过程中持续存在,在拔出 / 插件甚至克隆操作中也是如此。

l 根的 PDB_SPFILE$ 表是内部查询的,在打开可插拔数据库 / 实例时会相应地设置参数。

l 当以特权用户的身份连接到根容器 DB 时,默认情况下,任何 ALTER System 命令都只指向根容器。

l 传统的查看 SPFILE 甚至警报日志的方法只对 CDB 数据库有用。这是因为 CDB 是控制 CDB 和 PDB 之间共享的许多项的根级别。

l 要查看 CDB 和所有 PDB 的参数 (PDB$SEED 除外 ) ,可以查询 V$System_Parameter 。但是,除非安装了 bug#20700587 的修复程序,否则不会列出隐藏参数或下划线参数。

l V$SPPARAMETER 视图也可以被查询以在从 PDB 内部查询时显示 PDB 的 SPFILE 参数。

l 在非 CDB 中, V$SPPARAMETER 视图读取 spfile 并将参数显示为查询结果。 CDB 中的相同视图读取根中的 PDB_SPFILE$ 表,并在 PDB 中显示 PDB 的 SPFILE 参数。

l 为了在 PDB 级别修改参数,您需要连接到要对其进行修改的 PDB 容器。如果在根容器中连接,参数修改将对整个 CDB 进行。

l 每次打开 PDB 时,如果特定的 PDB 对于某些 init 参数有自己的值,那么 CDB 的 SPFILE 的值将被 PDB_SPFILE$ 的值覆盖。

l 可以为根 CDB DB 设置所有初始化参数。对于没有为 PDB 显式设置的任何初始化参数, PDB 继承根的参数值。

l 就像正常的初始化参数一样,有些下划线参数不能在系统级别修改,或者不能在 PDB 级别上修改,或者参数 - 隐藏的或不隐藏的 - 需要在所有 RAC 实例中具有相同的值。

l 每个 PDB 中的 PDB_SPFILE$ 表都是截断 / 空的,每个 PDB 的所有初始化参数都存储在根的 PDB_SPFILE$ 表中。

l 当 PDB 插入到新的 CDB 中时,参数及其值将被恢复。

l 当一个 PDB 被拔出时,它自己的初始化参数也会被复制到 PDB 自己的 PDB_SPFILE$ 表中,这样做是为了防止 XML 丢失。

l 将 PDB 插入到 CDB 并导入其所有参数后,本地 PDB 的 PDB_SPFILE$ 表将被截断。

l 由于 PDB 的 spfile 参数存储在根 CDB 中的字典表中,所以“ ALTER System Reset ”命令只是从根中的 PDB_SPFILE$ 表中删除 PDB 参数的行。这相当于从非 CDB 中的常规 spfile 中删除参数。

l 当前不支持为常规的非多租户数据库重置内存中的参数,因此 PDB 也不支持这一点。

l 当 PDB 关闭时,用于设置 / 重置参数的 PDB ‘ Alter System Set/Reset. ’命令不能用作用域 = 内存执行。当读取封闭 PDB 的参数时,我们需要提供参数的根值,因为 PDB 是从根继承的。

img

在本例中, pdb2 中为 DDL_LOCK_TIMEOUT 参数设置了不同的值。 PDB 关闭再打开后,更改的值会保留。 V$SYSTEM_PARAMETER 视图中的新列 CON_ID 显示每个容器(即根、 pdb1 和 pdb2 )中的 DDL_LOCK_TIMEOUT 值。

一、 Oracle12c多租户CDB 与 PDB 参数文件位置

CDB的参数文件依然使用12c以前的SPIFLE,pdb的参数文件不会出现在SPFILE中,而是直接从CDB中继承,如果PDB中有privete Local parameter 会存在 CDB 的 PDB_SPFILE$字典表 中以con_id区别,当PDB UN-Plug时,PDB参数会写入PDB的XML文件中,当drop pluggable database后,pdb信息和PDB_SPFILE$记录也会被清除。再当PDB重新Plug-in到CDB时会重新加载回PDB, 但是由于一些PDB特殊参数在plug-in时会被遗弃。

实验验证:

SQL> show con_name

CON_NAME
------------------------------
CDB$ROOT
SQL> show parameter spfile

NAME TYPE VALUE


spfile string /home/oracle/app/oracle/produc
t/12.2.0/dbhome_1/dbs/spfilean
dycdb.ora
SQL> alter session set container=pdb01;

Session altered.

SQL> show parameter spfile

NAME TYPE VALUE


spfile string /home/oracle/app/oracle/produc
t/12.2.0/dbhome_1/dbs/spfilean
dycdb.ora
到这一步验证了:CDB的参数文件依然使用12c以前的SPIFLE,pdb的参数文件不会出现在SPFILE中,而是直接从CDB中继承。

SQL> show parameter undo_retention

NAME TYPE VALUE


undo_retention integer 900
SQL> alter system set undo_retention=901;

System altered.

SQL> show parameter undo_reten

NAME TYPE VALUE


undo_retention integer 901

SQL> select pdb_uid,name,value$ from PDB_SPFILE$;

no rows selected
SQL> alter session set container=cdb$root;

Session altered.

SQL> select pdb_uid,name,value$ from PDB_SPFILE$;

PDB_UID NAME VALUE$


2550500229 undo_retention 901

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

CON_ID DBID CON_UID GUID


2 2683777510 2683777510 4ECF66D93A6233B5E0531019640A6041
3 2550500229 2550500229 4ECF8621E3DA38EEE0531019640AA598

到这一步验证了:如果PDB中有privete Local parameter 会存在 CDB 的 PDB_SPFILE$字典表 中以con_id区别

SQL>alter pluggable database pdb01 close immediate;
SQL>alter pluggable database pdb01 unplug into '/home/oracle/pdb01.xml';
[oracle@12c01 ~]$ pwd
/home/oracle
[oracle@12c01 ~]$ ll pdb01.xml
-rw-r--r--. 1 oracle oinstall 7758 May 7 05:09 pdb01.xml
[oracle@12c01 ~]$ cat pdb01.xml
<?xml version="1.0" encoding="UTF-8"?>


1PDB013
1
203424000

12.2.0.1.0
12.2.0.0.012.2.0.0.00.0.0.0.24
24
8.0.0.0.0

2550500229
...省略
SQL> show pdbs

CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB01 MOUNTED
SQL> drop pluggable database pdb01 keep datafiles;

Pluggable database dropped.

SQL> show pdbs

CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
SQL> select pdb_uid,name,value$ from PDB_SPFILE$;

no rows selected
到这一步验证了:PDB un-plug后pdb parameter and spfile会先进xml文件, 当drop pluggable database后,pdb信息和PDB_SPFILE$记录也会被清除。

SQL> create pluggable database pdb01 using '/home/oracle/pdb01.xml' nocopy;

SQL> show pdbs

CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB01 MOUNTED
SQL> alter pluggable database pdb01 open;
Pluggable database altered.
SQL> select pdb_uid,name,value$ from PDB_SPFILE$;

PDB_UID NAME VALUE$
---------- ---------------------------------------- -------------------------
1196085469 undo_retention 901

到这一步验证了:当PDB重新Plug-in到CDB时会重新加载回PDB, 但是由于一些PDB参数特殊原因在plug-in时会被遗弃。这里因为没有特殊参数,所以没有丢失参数。

二、 CDB 与 PDB 不同值的相同参数

多租户环境下,如果在设定参数时,cdb中设置CONTAINER=ALL,那么PDB的参数也会继承这个值,但可以通过ALTER SYSTEM在PDB container中修改 PDB local parameter,将覆盖(优先)从CDB继承的参数。有时候,我们有中需求,需要核实对比 PDB 中哪些参数与 CDB 不同。我们该怎么办,下面我们一起探讨下。

例子: 查询 名为 pdb01 的PDB 与 CDB 不同值的相同参数有哪些
\1. 实验环境查看
SQL> show con_name

CON_NAME
\------------------------------
CDB$ROOT
SQL> show parameter undo_reten

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
undo_retention integer 900
SQL> alter session set container=pdb01;
SQL> show parameter undo_reten

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
undo_retention integer 901
\2. 查询 PDB 中哪些参数与 CDB 不同
SQL>
set lin 300;
set pages 300;
col pdb_name for a30;
col parameter for a25;
col value$ for a20;
select v.dbid,v.name pdb_name,p.name parameter,p.value$
from pdb_spfile$ p,v$pdbs v
where p.pdb_uid=v.con_uid and v.name='PDB01' ;
DBID PDB_NAME PARAMETER VALUE$
---------- ------------------------------ ------------------------- -------------
2550500229 PDB01 undo_retention 901

\------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

在ORACLE 12C中参数文件只是记录了cdb的参数信息,没有记录任何的pdb的信息,那ORACLE是如何管理使得各个pdb有自己的参数,这里通过试验的出来ORACLE 12C CDB环境中是通过参数文件结合PDB_SPFILE$来实现参数管理
数据库版本

```
SQL> ` `select ` `* ` `from ` `v$version; ` `BANNER CON_ID ` `-------------------------------------------------------------------------------- ---------- ` `Oracle ` `Database ` `12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production 0 ` `PL/SQL Release 12.1.0.1.0 - Production 0 ` `CORE 12.1.0.1.0 Production 0 ` `TNS ` `for ` `Linux: Version 12.1.0.1.0 - Production 0 ` `NLSRTL Version 12.1.0.1.0 - Production 0
```

pdb信息

```
SQL> ` `select ` `PDB_NAME,CON_UID,pdb_id,status ` `from ` `dba_pdbs; ` `PDB_NAME CON_UID PDB_ID STATUS ` `---------- ---------- ---------- ------------- ` `PDB1 3313918585 3 NORMAL ` `PDB$SEED 4048821679 2 NORMAL ` `PDB2 3872456618 4 NORMAL ` `SQL> ` `select ` `con_id,dbid, ` `NAME ` `,OPEN_MODE ` `from ` `v$pdbs; ` ` ` `CON_ID DBID ` `NAME ` `OPEN_MODE ` `---------- ---------- ------------------------------ ---------- ` ` ` `2 4048821679 PDB$SEED ` `READ ` `ONLY ` ` ` `3 3313918585 PDB1 ` `READ ` `WRITE ` ` ` `4 3872456618 PDB2 MOUNTED
```

CDB$ROOT中修改参数

```
--指定container=all ` `SQL> show con_name ` `CON_NAME ` `------------------------------ ` `CDB$ROOT ` `SQL> ` `alter ` `system ` `set ` `open_cursors=500 container= ` `all ` `; ` `System altered. ` `SQL> show parameter open_cursors; ` `NAME ` `TYPE VALUE ` `------------------------------------ ----------- ------------------------------ ` `open_cursors ` `integer ` `500 ` `SQL> ` `alter ` `session ` `set ` `container=pdb1; ` `Session altered. ` `SQL> show con_name ` `CON_NAME ` `------------------------------ ` `PDB1 ` `SQL> show parameter open_cursors; ` `NAME ` `TYPE VALUE ` `------------------------------------ ----------- ------------------------------ ` `open_cursors ` `integer ` `500 ` `--在CDB$ROOT中修改不指定container参数表示全部pdb生效 ` `SQL> ` `alter ` `session ` `set ` `container=CDB$ROOT; ` `Session altered. ` `SQL> ` `alter ` `system ` `set ` `open_cursors=100; ` `System altered. ` `SQL> show parameter open_cursors; ` `NAME ` `TYPE VALUE ` `------------------------------------ ----------- ------------------------------ ` `open_cursors ` `integer ` `100 ` `SQL> ` `alter ` `session ` `set ` `container=pdb1; ` `Session altered. ` `SQL> show parameter open_cursors; ` `NAME ` `TYPE VALUE ` `------------------------------------ ----------- ------------------------------ ` `open_cursors ` `integer ` `100 ` `--指定container=current ` `SQL> ` `alter ` `system ` `set ` `open_cursors=120 container= ` `current ` `; ` `System altered. ` `SQL> show parameter open_cursors; ` `NAME ` `TYPE VALUE ` `------------------------------------ ----------- ------------------------------ ` `open_cursors ` `integer ` `120 ` `SQL> ` `alter ` `session ` `set ` `container=pdb2 ; ` `Session altered. ` `SQL> show parameter open_cursors; ` `NAME ` `TYPE VALUE ` `------------------------------------ ----------- ------------------------------ ` `open_cursors ` `integer ` `120
```

这里可以看出来,在ROOT中修改参数,默认情况和指定container=all/current均是所有open的pdb都生效.
这里有个疑问ORACLE的参数文件只是记录的cdb的sid的参数,并未记录各个pdb的参数,那是如何实现cdb中各个pdb参数不一致的呢?继续分析

修改pdb参数做10046

```
SQL> show con_name; ` `CON_NAME ` `------------------------------ ` `PDB1 ` `SQL> oradebug setmypid ` `Statement processed. ` `SQL> oradebug EVENT 10046 TRACE ` `NAME ` `CONTEXT FOREVER, ` `LEVEL ` `12 ` `Statement processed. ` `SQL> oradebug TRACEFILE_NAME ` `/u01/app/oracle/diag/rdbms/cdb/cdb/trace/cdb_ora_18377.trc ` `SQL> ` `alter ` `system ` `set ` `sessions=100; ` `System altered. ` `SQL> oradebug EVENT 10046 trace ` `name ` `context ` `off ` `Statement processed. ` `--继续修改pdb参数 ` `SQL> ` `alter ` `session ` `set ` `container=pdb1; ` `Session altered. ` `SQL> oradebug setmypid ` `Statement processed. ` `SQL> oradebug EVENT 10046 TRACE ` `NAME ` `CONTEXT FOREVER, ` `LEVEL ` `12 ` `Statement processed. ` `SQL> oradebug TRACEFILE_NAME ` `/u01/app/oracle/diag/rdbms/cdb/cdb/trace/cdb_ora_20275.trc ` `SQL> ` `alter ` `system ` `set ` `sessions=101; ` `System altered. ` `SQL> oradebug EVENT 10046 trace ` `name ` `context ` `off ` `Statement processed.
```

分析trace文件

```
--第一次修改pdb参数值 ` `insert into pdb_spfile$(db_uniq_name, pdb_uid, sid, name, value$, comment$) values(:1,:2,:3,:4,:5,:6) ` `END OF STMT ` `PARSE ` `#140085118752824:c=3999,e=3397,p=0,cr=0,cu=0,mis=1,r=0,dep=1,og=4,plh=0,tim=99767937623 ` `BINDS ` `#140085118752824: ` ` ` `Bind ` `#0 ` ` ` `oacdty=01 mxl=32(03) mxlc=00 mal=00 scl=00 pre=00 ` ` ` `oacflg=10 fl2=0001 frm=01 csi=852 siz=32 off=0 ` ` ` `kxsbbbfp=7fffcfaa5842 bln=32 avl=03 flg=09 ` ` ` `value= ` `"cdb" ` ` ` `Bind ` `#1 ` ` ` `oacdty=02 mxl=22(22) mxlc=00 mal=00 scl=00 pre=00 ` ` ` `oacflg=00 fl2=1000001 frm=00 csi=00 siz=24 off=0 ` ` ` `kxsbbbfp=7f681bbb2170 bln=22 avl=06 flg=05 ` ` ` `value=3313918585 ` ` ` `Bind ` `#2 ` ` ` `oacdty=01 mxl=32(01) mxlc=00 mal=00 scl=00 pre=00 ` ` ` `oacflg=10 fl2=0001 frm=01 csi=852 siz=32 off=0 ` ` ` `kxsbbbfp=7fffcfaa46f8 bln=32 avl=01 flg=09 ` ` ` `value= ` `"*" ` ` ` `Bind ` `#3 ` ` ` `oacdty=01 mxl=32(08) mxlc=00 mal=00 scl=00 pre=00 ` ` ` `oacflg=10 fl2=0001 frm=01 csi=852 siz=32 off=0 ` ` ` `kxsbbbfp=0bc220d8 bln=32 avl=08 flg=09 ` ` ` `value= ` `"sessions" ` ` ` `Bind ` `#4 ` ` ` `oacdty=01 mxl=32(03) mxlc=00 mal=00 scl=00 pre=00 ` ` ` `oacflg=10 fl2=0001 frm=01 csi=852 siz=32 off=0 ` ` ` `kxsbbbfp=7fffcfaa474c bln=32 avl=03 flg=09 ` ` ` `value= ` `"100" ` ` ` `Bind ` `#5 ` ` ` `oacdty=01 mxl=32(00) mxlc=00 mal=00 scl=00 pre=00 ` ` ` `oacflg=10 fl2=0001 frm=01 csi=852 siz=32 off=0 ` ` ` `kxsbbbfp=00000000 bln=32 avl=00 flg=09 ` `--第二次修改pdb参数值(相同参数) ` `update pdb_spfile$ ` `set ` `value$=:5, comment$=:6 where name=:1 and pdb_uid=:2 and db_uniq_name=:3 and sid=:4 ` `BINDS ` `#140603847818408: ` ` ` `Bind ` `#0 ` ` ` `oacdty=01 mxl=32(03) mxlc=00 mal=00 scl=00 pre=00 ` ` ` `oacflg=10 fl2=0001 frm=01 csi=852 siz=32 off=0 ` ` ` `kxsbbbfp=7ffff6477dcc bln=32 avl=03 flg=09 ` ` ` `value= ` `"101" ` ` ` `Bind ` `#1 ` ` ` `oacdty=01 mxl=32(00) mxlc=00 mal=00 scl=00 pre=00 ` ` ` `oacflg=10 fl2=0001 frm=01 csi=852 siz=32 off=0 ` ` ` `kxsbbbfp=00000000 bln=32 avl=00 flg=09 ` ` ` `Bind ` `#2 ` ` ` `oacdty=01 mxl=32(08) mxlc=00 mal=00 scl=00 pre=00 ` ` ` `oacflg=10 fl2=0001 frm=01 csi=852 siz=32 off=0 ` ` ` `kxsbbbfp=0bc220d8 bln=32 avl=08 flg=09 ` ` ` `value= ` `"sessions" ` ` ` `Bind ` `#3 ` ` ` `oacdty=02 mxl=22(22) mxlc=00 mal=00 scl=00 pre=00 ` ` ` `oacflg=00 fl2=1000001 frm=00 csi=00 siz=24 off=0 ` ` ` `kxsbbbfp=7fe0e2638320 bln=22 avl=06 flg=05 ` ` ` `value=3313918585 ` ` ` `Bind ` `#4 ` ` ` `oacdty=01 mxl=32(03) mxlc=00 mal=00 scl=00 pre=00 ` ` ` `oacflg=10 fl2=0001 frm=01 csi=852 siz=32 off=0 ` ` ` `kxsbbbfp=7ffff6478ec2 bln=32 avl=03 flg=09 ` ` ` `value= ` `"cdb" ` ` ` `Bind ` `#5 ` ` ` `oacdty=01 mxl=32(01) mxlc=00 mal=00 scl=00 pre=00 ` ` ` `oacflg=10 fl2=0001 frm=01 csi=852 siz=32 off=0 ` ` ` `kxsbbbfp=7ffff6477d78 bln=32 avl=01 flg=09 ` ` ` `value= ` `"*"
```

通过这里我们发现在独立修改pdb参数之时,其本质是在pdb_spfile$基表中插入或者修改相关记录(第一次修改插入,后续修改是更新)

关于pdb_spfile$基表分析

```
SQL> SHOW CON_NAME; ` `CON_NAME ` `------------------------------ ` `CDB$ROOT ` `SQL> COL OWNER ` `FOR ` `A10 ` `SQL> ` `select ` `con_id,owner,object_type ` `from ` `cdb_objects ` `where ` `object_name= ` `&#039;PDB_SPFILE$&#039; ` `; ` ` ` `CON_ID OWNER OBJECT_TYPE ` `---------- ---------- ----------------------- ` ` ` `2 SYS ` `TABLE ` ` ` `1 SYS ` `TABLE ` ` ` `3 SYS ` `TABLE ` `SQL> COL DB_UNIQ_NAME ` `FOR ` `A10 ` `SQL> COL ` `NAME ` `FOR ` `A15 ` `SQL> COL VALUE$ ` `FOR ` `A10 ` `SQL> ` `SELECT ` `DB_UNIQ_NAME,PDB_UID, ` `NAME ` `,VALUE$ ` `FROM ` `PDB_SPFILE$; ` `DB_UNIQ_NA PDB_UID ` `NAME ` `VALUE$ ` `---------- ---------- --------------- ---------- ` `cdb 3313918585 sessions 101 ` `SQL> ` `ALTER ` `SESSION ` `SET ` `CONTAINER=pdb1; ` `Session altered. ` `SQL> ` `SELECT ` `DB_UNIQ_NAME,PDB_UID, ` `NAME ` `,VALUE$ ` `FROM ` `PDB_SPFILE$; ` `no ` `rows ` `selected
```

证明pdb中不同于root的参数是记录在root的PDB_SPFILE$基表中.
整个CDB的工作原理是如果在PDB_SPFILE$中无相关参数记录,则继承cdb的参数文件中值,如果PDB_SPFILE$中有记录则使用该值覆盖cdb参数文件值.

删除PDB_SPFILE$验证

```
SQL> SHOW CON_NAME; ` `CON_NAME ` `------------------------------ ` `CDB$ROOT ` `SQL> show parameter open_cursors; ` `NAME ` `TYPE VALUE ` `------------------------------------ ----------- ------------------------------ ` `open_cursors ` `integer ` `100 ` `SQL> ` `select ` `con_id,dbid, ` `NAME ` `,OPEN_MODE ` `from ` `v$pdbs; ` ` ` `CON_ID DBID ` `NAME ` `OPEN_MODE ` `---------- ---------- ------------------------------ ---------- ` ` ` `2 4048821679 PDB$SEED ` `READ ` `ONLY ` ` ` `3 3313918585 PDB1 MOUNTED ` ` ` `4 3872456618 PDB2 ` `READ ` `WRITE ` `SQL> ` `alter ` `session ` `set ` `container=pdb2; ` `Session altered. ` `SQL> show parameter open_cursors; ` `NAME ` `TYPE VALUE ` `------------------------------------ ----------- ------------------------------ ` `open_cursors ` `integer ` `100 ` `SQL> ` `alter ` `system ` `set ` `open_cursors=110; ` `System altered. ` `SQL> show parameter open_cursors; ` `NAME ` `TYPE VALUE ` `------------------------------------ ----------- ------------------------------ ` `open_cursors ` `integer ` `110 ` `SQL> conn / ` `as ` `sysdba ` `Connected. ` `SQL> ` `select ` `value$ ` `from ` `pdb_spfile$ ` `where ` `name ` `= ` `&#039;open_cursors&#039; ` `; ` `VALUE$ ` `-------------------------------------------------------------------------------- ` `110 ` `SQL> ` `delete ` `from ` `pdb_spfile$ ` `where ` `name ` `= ` `&#039;open_cursors&#039; ` `; ` `1 row deleted. ` `SQL> ` `commit ` `; ` `Commit ` `complete. ` `SQL> startup ` `ORACLE instance started. ` `Total System ` `Global ` `Area 597098496 bytes ` `Fixed ` `Size ` `2291072 bytes ` `Variable ` `Size ` `272632448 bytes ` `Database ` `Buffers 314572800 bytes ` `Redo Buffers 7602176 bytes ` `Database ` `mounted. ` `Database ` `opened. ` `SQL> ` `select ` `value$ ` `from ` `pdb_spfile$ ` `where ` `name ` `= ` `&#039;open_cursors&#039; ` `; ` `no ` `rows ` `selected ` `SQL> show parameter open_cursors; ` `NAME ` `TYPE VALUE ` `------------------------------------ ----------- ------------------------------ ` `open_cursors ` `integer ` `100 ` `SQL> ` `alter ` `session ` `set ` `container=pdb2 ; ` `Session altered. ` `SQL> ` `alter ` `database ` `open ` `; ` `Database ` `altered. ` `SQL> show parameter open_cursors; ` `NAME ` `TYPE VALUE ` `------------------------------------ ----------- ------------------------------ ` `open_cursors ` `integer ` `100
```

删除PDB_SPFILE$中相关记录,pdb的参数值会自动继续继承cdb中参数值
总结说明: 通过上述的一些列试验证明cdb中参数关系,在cdb中修改,会默认所有pdb均自动继承;如果在pdb中修改值会覆盖cdb参数,而且只对当前pdb生效,并记录在PDB_SPFILE$

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

**多租户数据库中的初始化参数-常见问题和示例(文档ID 2101638.1)**

**
**

**在本文件中**

| | [目的](https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=527601576916689&id=2101638.1&displayIndex=3&_afrWindowMode=0&_adf.ctrl-state=uxdi0f0ii_167#PURPOSE) |
| ---- | ------------------------------------------------------------ |
| | |

| | [问答](https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=527601576916689&id=2101638.1&displayIndex=3&_afrWindowMode=0&_adf.ctrl-state=uxdi0f0ii_167#FAQ) |
| ---- | ------------------------------------------------------------ |
| | |

| | [-PDB数据库的SPFILE在哪里?](https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=527601576916689&id=2101638.1&displayIndex=3&_afrWindowMode=0&_adf.ctrl-state=uxdi0f0ii_167#aref_section21) |
| ---- | ------------------------------------------------------------ |
| | |

| | [-如何查看PDB中参数的当前值?](https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=527601576916689&id=2101638.1&displayIndex=3&_afrWindowMode=0&_adf.ctrl-state=uxdi0f0ii_167#aref_section22) |
| ---- | ------------------------------------------------------------ |
| | |

| | [-我只想更改PDB参数的值,但它失败了,为什么?](https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=527601576916689&id=2101638.1&displayIndex=3&_afrWindowMode=0&_adf.ctrl-state=uxdi0f0ii_167#aref_section23) |
| ---- | ------------------------------------------------------------ |
| | |

| | [-我如何才能为我的RAC PDB实例中的一个设置参数?](https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=527601576916689&id=2101638.1&displayIndex=3&_afrWindowMode=0&_adf.ctrl-state=uxdi0f0ii_167#aref_section24) |
| ---- | ------------------------------------------------------------ |
| | |

| | [-更改备用PDB的参数失败,如何将参数设置为备用数据库?](https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=527601576916689&id=2101638.1&displayIndex=3&_afrWindowMode=0&_adf.ctrl-state=uxdi0f0ii_167#aref_section25) |
| ---- | ------------------------------------------------------------ |
| | |

| | [参考文献](https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=527601576916689&id=2101638.1&displayIndex=3&_afrWindowMode=0&_adf.ctrl-state=uxdi0f0ii_167#REF) |
| ---- | ------------------------------------------------------------ |
| | |

------

## 适用于:

Oracle数据库-企业版-12.1.0.1及更高版本
本文档中的信息适用于任何平台。
*在2017年7月21日-2017年7月21日*

## 目的

这样做的目的是在多租户数据库环境中提供“ALTERSystemSet/Reset.”命令的正确语法和有效示例。

对于接下来的问题/答案或示例,请考虑以下环境:

2节点RAC主群集和2节点RAC备用群集。

1 RAC容器DB(CDB_PRD)具有2个不同的RAC可插件PDB(PDBP 1和PDBP 2),根的CDB有2个RAC实例,每个RAC节点上有一个实例,“逻辑”上每个PDB也有2个实例。

主群组:

| 节点1 | 节点2 |
| ------------------------------- | ------------------------------- |
| CBD_PRD 1(PDBP 1_I1)(PDBP 2_I1) | CBD_PRD 2(PDBP 1_I2)(PDBP 2_I2) |

待机组:

| 节点1 | 节点2 |
| -------------------------------- | -------------------------------- |
| CBD_STBY 1(PDBP 1_I1)(PDBP 2_I1) | CBD_STBY 2(PDBP 1_I2)(PDBP 2_I2) |

请注意,PDB的“逻辑”RAC实例的概念并不真正存在,为了便于理解这些概念,上面对它们进行了稀释,在OS级别上,每个多租户数据库只会找到一个实例(对于CDB)。

上面的每个多租户数据库都有自己的DB_UNIQUE_NAME,对应于根的CDB、主数据库的CBD_PRD和备用数据库的CBD_stby。

For detailed explanation of how initialization parameters work on a multitenant database please read Doc ID 2101596.1

## 问答

#### -PDB数据库的SPFILE在哪里?

PDBs没有init.ora文件或SPFILE,只有根的CDB有一个。PDB的参数存储在DB的字典中,存储在PDB_SPFILE$表中。

-我在查询PDB的PDB_SPFILE$表,它是空的,为什么?

这是应该的,PDB修改后的参数的所有信息都存储在根CDB中的PDB_SPFILE$表中。
参数被复制到PDB自己的PDB_spfile$表中的唯一时间是在PDB拔出插件期间,如果XML丢失,这将作为后盾。
当PDB插入另一个CDB后,PDB的PDB_SPFILE$表被截断。

#### -如何查看PDB中参数的当前值?

为了向后兼容,在使用多租户数据库时,检查参数的当前值不会改变。
在连接到PDB时显示参数应该仍然有效。
可以查询V$参数或V$System_Parameter。但是,除非安装了bug#20700587的修复程序,否则不会列出隐藏参数或下划线参数。
作为另一种选择,如果没有安装bug#20700587的修复程序,您可以查询CDB的PDB_SPFILE$TABLE。V$SPPARAMETER视图也可以被查询以在从PDB内部查询时显示PDB的SPFILE参数。

#### -我只想更改PDB参数的值,但它失败了,为什么?

并非所有参数都是可修改的。要确定可以为PDB修改哪些参数,必须为V$System_Parameters或V$参数视图中的ISPDB可修改列。

#### -我如何才能为我的RAC PDB实例中的一个设置参数?

如果要将相同参数的不同值设置到RAC实例中,则需要添加SID子句,就像在普通而非互斥DB中所做的那样,唯一的区别是所提供的SID是多租户DB的SID:
ALTERSession SET容器=PDBP 1;
从PDBP 1‘Scope=spfile sid=’cbd_prd 1‘更改系统设置OPEN_游标为RAC实例1=’CBD_PRD 1‘;
从PDBP 1‘Scope=spfile sid=’bbd_prd 2‘更改系统设置OPEN_游标=250个注释=’将OPEN_游标设置为RAC实例2;

请注意,在连接到PDBP 1容器时,我们正在执行该命令。

#### -更改备用PDB的参数失败,如何将参数设置为备用数据库?

由于PDB的参数存储在数据库的字典中,因此任何更改都将被取消,因为备用DB不是在读写模式下打开的。
从12.1.0.2开始,可以使用DB_UNIQUE_NAME子句执行ALTERSystemSet语句的语法增强。
此子句提供了一种修改系统参数的方法,其作用域=SPFILE在主数据库的PDB中,但指定备用数据库的db_UNIQUE_NAME,其中参数值应该真正生效。这种方法确保在主服务器上执行DML,以便在备用服务器上生效。
从主容器连接到正确的容器PDB执行:
ALTERSession SET容器=PDBP 1;
更改系统设置OPEN_游标=150注释=‘将OPEN_游标设置为PDBP 1备用’Scope=spfile db_UNIQUE_NAME=‘cdb_stby’;
请注意上面语法中的“.db_UNIQUE_NAME=‘CDB_stby’.”,它指定备用数据库的db_UNIQUE_NAME。

如果要将相同参数的不同值设置为需要添加SID子句的实例,如下所示:
更改系统设置OPEN_游标=150个注释=‘将OPEN_游标设置为实例1(PDBP 1备用)范围=spfile db_UNIQUE_NAME=’CDB_stby‘sid=’CBD_STBY 1‘;
更改系统设置OPEN_游标=250个注释=‘将OPEN_游标设置为实例2从PDBP 1备用’SCOPE=spfile db_UNIQUE_NAME=‘CDB_stby’sid=‘CBD_STBY 2’;

请注意,在连接到PDBP 1容器DB时,我们正在执行来自主DB的命令,我们需要同时指定db_UNIQUE_NAME和SID。
还请注意,SID是多租户备用DB的SID。

## 参考文献

本人提供Oracle、MySQL、PG等数据库的培训和考证业务,私聊QQ646634621或微信db_bao,谢谢!

[NOTE:2101596.1 ](https://support.oracle.com/epmos/faces/DocumentDisplay?parent=DOCUMENT&sourceId=2101638.1&id=2101596.1)-多租户数据库中的初始化参数-事实和附加信息
[NOTE:1511619.1 ](https://support.oracle.com/epmos/faces/DocumentDisplay?parent=DOCUMENT&sourceId=2101638.1&id=1511619.1)-Oracle多租户选项-12c:常见问题

**
**

**---------------------- \**----------------------\** \**----------------------\** \**----------------------\** \**----------------------\** \**----------------------\** \**----------------------\** \**----------------------\** \**----------------------\** \**----------------------\** \**----------------------\** \**----------------------\** \**----------------------\** \**----------------------\****

***\*ALTER SYSTEM RESET DOESN'T UPDATE PARAM VALUE IN PDB_SPFILE$ (文档 ID 2287601.1)\****

**
**

**In this Document**

| | [Symptoms](https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=527598459661456&id=2287601.1&displayIndex=1&_afrWindowMode=0&_adf.ctrl-state=uxdi0f0ii_85#SYMPTOM) |
| ---- | ------------------------------------------------------------ |
| | |

| | [Cause](https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=527598459661456&id=2287601.1&displayIndex=1&_afrWindowMode=0&_adf.ctrl-state=uxdi0f0ii_85#CAUSE) |
| ---- | ------------------------------------------------------------ |
| | |

| | [Solution](https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=527598459661456&id=2287601.1&displayIndex=1&_afrWindowMode=0&_adf.ctrl-state=uxdi0f0ii_85#FIX) |
| ---- | ------------------------------------------------------------ |
| | |

| | [References](https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=527598459661456&id=2287601.1&displayIndex=1&_afrWindowMode=0&_adf.ctrl-state=uxdi0f0ii_85#REF) |
| ---- | ------------------------------------------------------------ |
| | |

------

## APPLIES TO:

Oracle Database - Version 12.2.0.1 to 12.2.0.1 [Release 12.2]
Information in this document applies to any platform.

## SYMPTOMS

pdb_spfile$ not updated when alter system reset is issued for a parameter.

## CAUSE

This issue is investigated in

bug 24423308 - SV12.2DBSA: ALTER SYSTEM RESET DOESN'T UPDATE PARAM VALUE IN PDB_SPFILE$@ROOT

Which is closed as not a bug.

pdb_spfile$ is an internal dictionary table, it should not be used to query the initialization parameters. To elaborate on the technical details, the row exists in pdb_spfile$ but it is marked as DELETED parameter. So existence of the row is internal implementation and not impact for the user.

## SOLUTION

Check v$parameter, v$system_parameter, v$spparameter views

\------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

**
**

**Initialization parameters in a Multitenant database - Facts and additional information (文档 ID 2101596.1)**

**
**

**In this Document**

| | [Purpose](https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=527600133279709&id=2101596.1&displayIndex=2&_afrWindowMode=0&_adf.ctrl-state=uxdi0f0ii_126#PURPOSE) |
| ---- | ------------------------------------------------------------ |
| | |

| | [Scope](https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=527600133279709&id=2101596.1&displayIndex=2&_afrWindowMode=0&_adf.ctrl-state=uxdi0f0ii_126#SCOPE) |
| ---- | ------------------------------------------------------------ |
| | |

| | [Details](https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=527600133279709&id=2101596.1&displayIndex=2&_afrWindowMode=0&_adf.ctrl-state=uxdi0f0ii_126#BODYTEXT) |
| ---- | ------------------------------------------------------------ |
| | |

| | [References](https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=527600133279709&id=2101596.1&displayIndex=2&_afrWindowMode=0&_adf.ctrl-state=uxdi0f0ii_126#REF) |
| ---- | ------------------------------------------------------------ |
| | |

------

## APPLIES TO:

Oracle Database - Enterprise Edition - Version 12.1.0.1 and later
Information in this document applies to any platform.

## PURPOSE

Provides a clear understanding of how we can set initialization parameters in a multitenant Oracle database and what to expect.

## SCOPE

This document is intended for database administrators which are using the new 12c feature Mutitenant databases.

## DETAILS

Things to know when changing parameters in a plugable database.

Modifying Initialization Parameters in PDB, facts :

- PDBs inherit parameter values from the root CDB unless they are overridden at PDB level.
- The normal 'ALTER SYSTEM' command is used to modify PDB level parameters except that persistence mechanism is different.
- PDB level initialization parameters are not stored in the SPFILE, instead they are stored in the data dictionary for the PDB. PDB's spfile parameters are stored in the PDB_SPFILE$ internal table.
- There is only one phisical spfile for the entire CBD and all its PDBs. This spfile is read when the root CDB is opened.
- The equivalent of an spfile for a PDB is the CDB's PDB_SPFILE$ table.
- There is a PDB_SPFILE$ table for each one of the containers (cdb$root and all PDBs). However only the CDB's PDB_SPFILE$ table contains those parameters which have been specifically set for the PDBs.
- SPFILE in PDBs is always enabled, as long as the root's CDB is open. This is true even if the CDB is not using a SPFILE, Oracle allows PDB to use SPFILE because PDBs do not have any other means for persistent parameters, (PDBs do not support PFILE or init.ora file).
- Only a subset of the overall Oracle DB initialization parameters can be modified locally in the PDB. Look for those parameters with V$PARAMETER.ISPDB_MODIFIABLE = 'YES'.
- PDB level parameters persist across database restarts and also across unplug/plug and even clone operations.
- The root's PDB_SPFILE$ table is internally queried and the parameters are set accordingly when the pluggable database/instance is opened.
- When connected as a privileged user to the root container DB, any ALTER SYSTEM command will, by default, be directed at just the root container.
- The traditional ways of looking at an SPFILE or even the alert.log will only be useful for a CDB database. This is because the CDB is the root level that controls many of the items which are shared among the CDB and PDBs.
- To see parameters for the CDB and all the PDB’s (except PDB$SEED), V$SYSTEM_PARAMETER can be queried. Hidden or underscore parameters are not listed there though unless fix for bug#20700587 is installed.
- As an alternative for the above bullet you can query CDB's PDB_SPFILE$ table instead. V$SPPARAMETER view can also be queried to show PDB's SPFILE parameters when queried from inside the PDB.
- In a non-CDB DB, the V$SPPARAMETER view reads the spfile and shows the parameters as a query result. The same view in a CDB reads the PDB_SPFILE$ table in ROOT and show the PDB's SPFILE parameters when inside a PDB.
- In order to modify parameters at PDB level you need to be connected to the PDB container for which you want to make the modification. If you are connected at ROOT container the parameter modification will take place for entire CDB.
- Every time when you open a PDB, if that particular PDB has its own values for some of the init parameters the values from the CDB's SPFILE are overwritten with the values from PDB_SPFILE$.
- All initialization parameters can be set for the root CDB DB. For any initialization parameter that is not set explicitly for a PDB, the PDB inherits the root's parameter value.
- Just like normal initialization parameters there are underscore parameters that cannot be modified at system level, or cannot be modified at PDB level, or parameters -hidden or not- that need to have the same value across all RAC instances.
- The PDB_SPFILE$ table in each one of the PDB is truncated/empty, all the initialization parameters for each PDB are stored in the root's PDB_SPFILE$ table instead.
- Parameters and their values are restored for the PDB when it is plugged into a new CDB.
- When a PDB is unplugged its own initialization parameters will also be copied into the PDB's own PDB_SPFILE$ table, this is done as a fallback in case the XML is lost.
- Once a PDB is plugged back into a CDB and all its parameters imported then the local PDB's PDB_SPFILE$ table is truncated.
- Since the PDB's spfile parameters are stored in a dictionary table in the ROOT CDB, the 'ALTER SYSTEM RESET' command just deletes the row for the PDB's parameter from the PDB_SPFILE$ table in the ROOT. This is equivalent to removing the parameter from the regular spfile in a non CDB.
- There is no current support for resetting in-memory parameters for regular non-multitenant database, and hence that is not supported for PDB either.
- A PDB's 'ALTER SYSTEM SET/RESET ...' command to set/reset a parameter cannot be executed with scope=memory when the PDB is closed. When reading parameters for a closed PDB, we are expected to provide ROOT's values of the parameters, since the PDB inherits from ROOT.

Understanding the concept of parameter inheritance within the Oracle Database 12c:

Parameter Inheritance in Oracle Database 12c means that the value of a particular parameter in the root (CDB) is inherited by one or more PDBs. There are parameters that can be changed at the PDB level and override what is being inherited from the CDB. To identify which parameters can be modified for a PDB, the ISPDB_MODIFIABLE column in the V$SYSTEM_PARAMETER or V$PARAMETER views must be TRUE. If the ISPDB_MODIFIABLE column for that parameter is TRUE then the parameter inherits the value from the CDB until it is changed with an ALTER SYSTEM SET command at the PDB.

From documentation:

When the current container is a PDB, run the ALTER SYSTEM SET initialization_parameter statement to modify the PDB. The statement does not affect the root or other PDBs.
The following table describes the behavior of the SCOPE clause when you use a server parameter file (SPFILE) and run the ALTER SYSTEM SET statement on a PDB.

MEMORY :
The initialization parameter setting is changed in memory and takes effect immediately in the PDB. The new setting affects only the PDB.
The setting reverts to the value set in the root in the any of the following cases:
\- An ALTER SYSTEM SET statement sets the value of the parameter in the root with SCOPE equal to BOTH or MEMORY, and the PDB is closed and re-opened. The parameter value in the PDB is not changed if SCOPE is equal to SPFILE, and the PDB is closed and re-opened.
\- The CDB is shut down and re-opened.

SPFILE :
The initialization parameter setting is changed for the PDB in the SPFILE. The new setting takes effect in any of the following cases:
\- The PDB is closed and re-opened.
\- The CDB is shut down and re-opened.
In these cases, the new setting affects only the PDB.

BOTH :
The initialization parameter setting is changed in memory, and it is changed for the PDB in the SPFILE. The new setting takes effect immediately in the PDB and persists after the PDB is closed and re-opened or the CDB is shut down and re-opened. The new setting affects only the PDB.

\- Note that in absence of the SCOPE clause in the alter system command. It should be determined on execute time based on the context of the current container. Default value of SCOPE clause in Alter System is SCOPE=BOTH.

Setting parameters for a PDB Data Guard Standby:

- In 12.1.0.1, the ALTER SYSTEM SCOPE=SPFILE is disallowed on standby database because the standby DB is not opened in read-write mode and as such changes to the root's PDB_SPFILE$ table are not allowed.
- In order to provide a way to solve the above limitation, there is a syntax enhancement in 12.1.0.2 to execute an ALTER SYSTEM SET statement with a DB_UNIQUE_NAME clause.
- ER bug#16270497 implements the PDB SPFILE limitation on ADG above.
- The DB_UNIQUE_NAME clause in the "ALTER SYSTEM SET/RESET ..." command will not be documented in 12.1. This clause provides a way to modify the system parameter with SCOPE=SPFILE inside the PDB on the primary database, but specify the db_unique_name of the standby database where the parameter value should really take effect. This approach ensures that the DML gets performed on the primary with the intention to take effect on the standby.

Setting parameters for a RAC PDB :

- Setting parameters for a RAC PDB is the same as setting parameters for a non-Multitenant database, the only difference, and this is important, is that if you want to set a parameter to an specific instance of a RAC PDB database the SID provided needs to be from the CDB's instance name.

Review this Doc Id 2101638.1 for specific examples and correct syntax to use when changing parameters in a multitenant database.

## REFERENCES

[NOTE:2101638.1 ](https://support.oracle.com/epmos/faces/DocumentDisplay?parent=DOCUMENT&sourceId=2101596.1&id=2101638.1) - Initialization parameters in a Multitenant database - FAQ and Examples

\---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

**Multitenant best Practice and Known issues (文档 ID 1604135.1)**

**
**

**In this Document**

| | [Purpose](https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=527604960279994&id=1604135.1&displayIndex=4&_afrWindowMode=0&_adf.ctrl-state=uxdi0f0ii_224#PURPOSE) |
| ---- | ------------------------------------------------------------ |
| | |

| | [Details](https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=527604960279994&id=1604135.1&displayIndex=4&_afrWindowMode=0&_adf.ctrl-state=uxdi0f0ii_224#BODYTEXT) |
| ---- | ------------------------------------------------------------ |
| | |

| | [References](https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=527604960279994&id=1604135.1&displayIndex=4&_afrWindowMode=0&_adf.ctrl-state=uxdi0f0ii_224#REF) |
| ---- | ------------------------------------------------------------ |
| | |

------

## APPLIES TO:

Oracle Database - Enterprise Edition - Version 12.1.0.1 to 12.1.0.1 [Release 12.1]
Information in this document applies to any platform.
***Checked for relevance on 04-Feb-2016***

## PURPOSE

Best Practices for Multiteenant option and general known issues and problems

## DETAILS

**1.Tnsnames when connecting to either Container or Pluggable instance**

The tnsnames.ora should be configured , for eg to add a tns entry for pluggable database PDB_OMF_1

PDB_OMF_1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = MFarag-OEL)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = pdb_omf_1)
)
)

Alternatively the easy connect syntax could be used as follow :

SYS@mfarag-oel/PDB_OMF_1>CONN A/A@mfarag-oel/PDB_OMF_1
Connected.
A@mfarag-oel/PDB_OMF_1>conn xx/xx@mfarag-oel/XX
Connected.
XX@mfarag-oel/XX>

Add the following entry to the glogin.sql script under $ORACLE_HOME/sqlplus/admin

set sqlprompt "_USER'@'_CONNECT_IDENTIFIER'>'"

**2.Always use OMF pluggable Database when the Container is Pluggable :**

SYS@CDB>create pluggable database pdbomf admin user a identified by a ;

CREATE PLUGGABLE DATABASE pdb2 ADMIN USER pdb_adm IDENTIFIED BY Password1 FILE_NAME_CONVERT=('/u01/app/oracle/oradata/cdb1/pdbseed/','/u01/app/oracle/oradata/cdb1/pdb2/');

Please note FILE_NAME_CONVERT( *filename_pattern ,replacement_filename_pattern* ) clause is required if you are not using OMF. If you omit this clause, then the database first attempts to use Oracle Managed Files to generate file names. If you are not using Oracle Managed Files, then the database uses the PDB_FILE_NAME_CONVERT initialization parameter to generate file names. If this parameter is not set, then an error occurs.

SYS@CDB>select CON_ID,DBID,GUID,NAME,OPEN_MODE
from V_$CONTAINERS ;

CON_ID DBID GUID
---------- ---------- --------------------------------
NAME OPEN_MODE
------------------------------ ----------
1 1949193435 DD7C48AA5A4504A2E04325AAE80A403C
CDB$ROOT READ WRITE

​ 2 4075234582 EC25D0EC10347332E043CC8DAB0A7AE1
PDB$SEED READ ONLY

​ 3 3255612964 EC25E0FB670B76A8E043CC8DAB0A08D8
PDB READ WRITE

CON_ID DBID GUID
---------- ---------- --------------------------------
NAME OPEN_MODE
------------------------------ ----------
4 3244820336 EC276A999A790163E043CC8DAB0AD357
PDBOMF MOUNTED

.
.
SYS@CDB>alter session set container=pdbomf ;

Session altered.

SYS@CDB>alter pluggable database open ;

Pluggable database altered.

**3.Open the Pluggable Database in Restricted m ode before Renaming it**

SYS@CDB>conn sys@pdb_omf_1 as sysdba
Enter password:
Connected.

SYS@pdb_omf_1>alter pluggable database close ;

SYS@pdb_omf_1>alter pluggable database open restricted;

SYS@pdb_omf_1>alter pluggable database pdbomf rename global_name to pdb_omf_1 ;

**4.unplug and Plug a Database :**

SYS@CDB1>alter pluggable database y close immediate ;

SYS@CDB1>alter pluggable database y unplug into '/home/oracle/XDESC.xml' ;

SYS@CDB1>drop pluggable database y ;

SYS@CDB1>create pluggable database y using '/home/oracle/XDESC.xml' nocopy ;

**5. startup the Pluggable database in single step :**

SYS@CDB>select CON_ID,GUID,NAME,OPEN_MODE
from V$containers;

CON_ID GUID NAME
---------- -------------------------------- ------------------------------
OPEN_MODE
\----------
1 DD7C48AA5A4504A2E04325AAE80A403C CDB$ROOT
READ WRITE

​ 2 EC25D0EC10347332E043CC8DAB0A7AE1 PDB$SEED
READ ONLY

​ 3 EC2B4C003E221F09E0438636AF0AA57B X
MOUNTED

CON_ID GUID NAME
---------- -------------------------------- ------------------------------
OPEN_MODE
\----------
4 EC276A999A790163E043CC8DAB0AD357 PDB_OMF_1
MOUNTED

SYS@CDB>alter pluggable database all open ;

SYS@CDB>select CON_ID,GUID,NAME,OPEN_MODE
from V$containers

CON_ID GUID NAME
---------- -------------------------------- ------------------------------
OPEN_MODE
\----------
1 DD7C48AA5A4504A2E04325AAE80A403C CDB$ROOT
READ WRITE

​ 2 EC25D0EC10347332E043CC8DAB0A7AE1 PDB$SEED
READ ONLY

​ 3 EC2B4C003E221F09E0438636AF0AA57B X
READ WRITE

CON_ID GUID NAME
---------- -------------------------------- ------------------------------
OPEN_MODE
\----------
4 EC276A999A790163E043CC8DAB0AD357 PDB_OMF_1
READ WRITE

Note : the startup of the Container CDB will place all the pdb in mount status by Defualt

**6.Use catcon perl script to run scripts for selective or all pluggable and container database :**

E.g Run the awrinfo script to have information about the awr usage under sysaux for all the databases :

$cd $ORACLE_HOME/rdbms/admin

$ perl catcon.pl -u SYS -U SYS -d $ORACLE_HOME/rdbms/admin -l '/home/oracle' -b catblock_output awrinfo.sql

--Confirm that the script run against all the databases :

$cd /home/oracle
$ grep -i "CURRENT CONTAINER" *
catblock_output0.log:==== Current Container = CDB$ROOT ====
catblock_output0.log:==== Current Container = PDB$SEED ====
catblock_output1.log:==== Current Container = XX ====
catblock_output2.log:==== Current Container = PDB_OMF_1 ====

Note : use the -c option tpo specify certain databases to have this script run against

**7.How to use non-seed template to create CDB + Pluggable database :**

$ dbca -silent -createDatabase -templateName Custom_DB_.dbt -gdbName FOFO -sid FOFO -createAsContainerDatabase true -numberOfPDBs 1 -pdbName pdb_silent -sysPassword -systemPassword -listeners listener
Enter PDBADMIN

Note : the above command used the non-seed Custome_DB_ template to create CDB names FOFO with a PDB database named pdb_silent in silent mode .

**
\8. Modify the Value "_datafile_write_errors_crash_instance" to be FALSE**

SQL>alter system set "_datafile_write_errors_crash_instance"=FALSE

***\*This has to be set at CDB level. This is to allow the Container CDB to continue running if one of its Pdb lost one of the datafiles for any reason**

**NOTE**

**9.How To check if a parameter have been modified within the PDB?**

SYS@CDB>column PDB_NAME format a20
SYS@CDB>column NAME format a20
SYS@CDB>column VALUE$ format a20
SYS@CDB>select p.PDB_NAME,s.name,s.value$
from cdb_pdbs p , pdb_spfile$ s
where p.CON_UID=s.PDB_UID

PDB_NAME NAME VALUE$
-------------------- -------------------- --------------------
XX cursor_sharing 'SIMILAR'
YY_NEW cursor_sharing 'SIMILAR'

***\*Note This could never be checked for non default pdb init parameters valunes using alertlog .**

## REFERENCES

[NOTE:1516202.1 ](https://support.oracle.com/epmos/faces/DocumentDisplay?parent=DOCUMENT&sourceId=1604135.1&id=1516202.1) - How to Monitor Process Memory Usage on Pluggable Databases
[NOTE:1575186.1 ](https://support.oracle.com/epmos/faces/DocumentDisplay?parent=DOCUMENT&sourceId=1604135.1&id=1575186.1) - Syntax Error Encountered During The Creation Of A Pluggable Database
[NOTE:1511619.1 ](https://support.oracle.com/epmos/faces/DocumentDisplay?parent=DOCUMENT&sourceId=1604135.1&id=1511619.1) - Oracle Multitenant Option - 12c : Frequently Asked Questions

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

**
**

**
**

**多租户数据库中的初始化参数-事实和附加信息(文档ID 2101596.1)**

**
**

**
**

**在本文件中**

| | [目的](https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=527653607731744&id=2101596.1&displayIndex=2&_afrWindowMode=0&_adf.ctrl-state=uxdi0f0ii_281#PURPOSE) |
| ---- | ------------------------------------------------------------ |
| | |

| | [范围](https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=527653607731744&id=2101596.1&displayIndex=2&_afrWindowMode=0&_adf.ctrl-state=uxdi0f0ii_281#SCOPE) |
| ---- | ------------------------------------------------------------ |
| | |

| | [细节](https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=527653607731744&id=2101596.1&displayIndex=2&_afrWindowMode=0&_adf.ctrl-state=uxdi0f0ii_281#BODYTEXT) |
| ---- | ------------------------------------------------------------ |
| | |

| | [参考文献](https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=527653607731744&id=2101596.1&displayIndex=2&_afrWindowMode=0&_adf.ctrl-state=uxdi0f0ii_281#REF) |
| ---- | ------------------------------------------------------------ |
| | |

------

## 适用于:

Oracle数据库-企业版-12.1.0.1及更高版本
本文档中的信息适用于任何平台。

## 目的

清楚地了解如何在多租户Oracle数据库中设置初始化参数以及预期的内容。

## 范围

此文档用于使用新的12c特性的数据库管理员。

## 细节

在插件数据库中更改参数时要知道的事情。

修改PDB中的初始化参数,事实:

- PDB从根CDB继承参数值,除非它们在PDB级别被重写。
- 普通的“ALTERSystem”命令用于修改PDB级别的参数,但持久性机制不同。
- PDB级别的初始化参数不是存储在SPFILE中,而是存储在PDB的数据字典中。PDB的spfile参数存储在PDB_SPFILE$内部表中。
- 对于整个CBD及其所有PDBs,只有一个phisical spfile。打开根CDB时读取此spfile。
- 与PDB的spfile等价的是CDB的PDB_SPFILE$表。
- 每个容器都有一个PDB_SPFILE$表(CDB$root和所有PDB)。但是,只有CDB的PDB_SPFILE$表包含为PDB专门设置的参数。
- 只要根的CDB是打开的,PDBs中的SPFILE总是被启用的。即使CDB不使用SPFILE,Oracle也允许PDB使用SPFILE,因为PDB没有任何其他方法用于持久参数(PDB不支持Pfile或init.ora文件)。
- 在PDB中只能在本地修改整个Oracle DB初始化参数的一个子集。使用V$PARAMETER.ISPDB_AUDIBE=‘YES’查找这些参数。
- PDB级别的参数在数据库重新启动的过程中持续存在,在拔出/插件甚至克隆操作中也是如此。
- 根的PDB_SPFILE$表是内部查询的,在打开可插拔数据库/实例时会相应地设置参数。
- 当以特权用户的身份连接到根容器DB时,默认情况下,任何ALTERSystem命令都只指向根容器。
- 传统的查看SPFILE甚至警报日志的方法只对CDB数据库有用。这是因为CDB是控制CDB和PDB之间共享的许多项的根级别。
- 要查看CDB和所有PDB的参数(PDB$SEED除外),可以查询V$System_Parameters。但是,除非安装了bug#20700587的修复程序,否则不会列出隐藏参数或下划线参数。
- 作为上述项目的替代方案,您可以查询CDB的PDB_SPFILE$table。V$SPPARAMETER视图也可以被查询以在从PDB内部查询时显示PDB的SPFILE参数。
- 在非CDBDB中,V$SPPARAMETER视图读取spfile并将参数显示为查询结果。CDB中的相同视图读取根中的PDB_SPFILE$表,并在PDB中显示PDB的SPFILE参数。
- 为了在PDB级别修改参数,您需要连接到要对其进行修改的PDB容器。如果在根容器中连接,参数修改将对整个CDB进行。
- 每次打开PDB时,如果特定的PDB对于某些init参数有自己的值,那么CDB的SPFILE的值将被PDB_SPFILE$的值覆盖。
- 可以为根CDB DB设置所有初始化参数。对于没有为PDB显式设置的任何初始化参数,PDB继承根的参数值。
- 就像正常的初始化参数一样,有些下划线参数不能在系统级别修改,或者不能在PDB级别上修改,或者参数-隐藏的或不隐藏的-需要在所有RAC实例中具有相同的值。
- 每个PDB中的PDB_SPFILE$表都是截断/空的,每个PDB的所有初始化参数都存储在根的PDB_SPFILE$表中。
- 当PDB插入到新的CDB中时,参数及其值将被恢复。
- 当一个PDB被拔出时,它自己的初始化参数也会被复制到PDB自己的PDB_SPFILE$表中,这样做是为了防止XML丢失。
- 将PDB插入到CDB并导入其所有参数后,本地PDB的PDB_SPFILE$表将被截断。
- 由于PDB的spfile参数存储在根CDB中的字典表中,所以“ALTERSystemReset”命令只是从根中的PDB_SPFILE$表中删除PDB参数的行。这相当于从非CDB中的常规spfile中删除参数。
- 当前不支持为常规的非多租户数据库重置内存中的参数,因此PDB也不支持这一点。
- 当PDB关闭时,用于设置/重置参数的PDB‘AlterSystemSet/Reset.’命令不能用作用域=内存执行。当读取封闭PDB的参数时,我们需要提供参数的根值,因为PDB是从根继承的。

理解Oracle数据库12c中参数继承的概念:

Oracle数据库12c中的参数继承意味着根中特定参数(CDB)的值由一个或多个PDB继承。有些参数可以在PDB级别上更改,并覆盖从CDB继承的内容。要确定可以为PDB修改哪些参数,必须为V$System_Parameters或V$参数视图中的ISPDB可修改列。如果该参数的ISPDB_Modiable列为true,则该参数将继承来自CDB的值,直到在PDB上使用ALTERSystemSet命令对其进行更改。

来自文件:

当当前容器是PDB时,运行ALTERSystemSet初始化参数语句来修改PDB。该语句不影响根或其他PDB。
下表描述在使用服务器参数文件(SPFILE)并在PDB上运行ALTERSystemSet语句时Scope子句的行为。

记忆:
初始化参数设置在内存中更改,并在PDB中立即生效。新设置只影响PDB。
在下列任何一种情况下,该设置返回到根中的值集:
-ALTERSystemSet语句设置根中参数的值,其作用域等于两者或内存,PDB被关闭并重新打开。如果范围等于SPFILE,并且PDB关闭并重新打开,则PDB中的参数值不会更改。
-国开行被关闭并重新开业。

SPFILE:
为SPFILE中的PDB更改初始化参数设置。新设置在下列任何情况下都生效:
-PDB已关闭,并重新开放。
-国开行被关闭并重新开业。
在这些情况下,新设置只影响PDB。

两者均:
初始化参数设置在内存中更改,对SPFILE中的PDB进行更改。新设置在PDB中立即生效,并在PDB关闭并重新打开或CDB关闭并重新打开之后继续存在。新设置只影响PDB。

-请注意,在ALTERSystem命令中没有Scope子句的情况下。它应该根据当前容器的上下文根据执行时间来确定。ALTERSystem中Scope子句的默认值为Scope=二者。

设置PDB数据保护待机参数:

- 在12.1.0.1中,在备用数据库中不允许使用ALTERSystemScope=SPFILE,因为备用DB不是在读写模式下打开的,因此不允许对root的PDB_SPFILE$表进行更改。
- 为了提供解决上述限制的方法,12.1.0.2中有一个语法增强,可以使用DB_UNIQUE_NAME子句执行ALTERSystemSet语句。
- Erbug#16270497在上面的ADG上实现了PDBSPFILE限制。
- 在12.1中不会记录“ALTERSystemSet/Reset.”命令中的DB_UNIQUE_NAME子句。此子句提供了一种修改系统参数的方法,其作用域=SPFILE在主数据库的PDB中,但指定备用数据库的db_UNIQUE_NAME,其中参数值应该真正生效。这种方法确保在主服务器上执行DML,以便在备用服务器上生效。

设置RAC PDB的参数:

- 为RAC PDB设置参数与为非多租户数据库设置参数相同,唯一的区别是,如果要将参数设置为RAC PDB数据库的特定实例,则SID提供的参数需要从CDB的实例名称中设置。

检查此DocID 2101638.1以获得在多租户数据库中更改参数时要使用的特定示例和正确语法。

## 参考文献

[NOTE:2101638.1 ](https://support.oracle.com/epmos/faces/DocumentDisplay?parent=DOCUMENT&sourceId=2101596.1&id=2101638.1)-多租户数据库中的初始化参数-常见问题和示例

标签:

头像

小麦苗

学习或考证,均可联系麦老师,请加微信db_bao或QQ646634621

您可能还喜欢...

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

1 + 17 =

 

嘿,我是小麦,需要帮助随时找我哦
  • 18509239930
  • 个人微信

  • 麦老师QQ聊天
  • 个人邮箱
  • 点击加入QQ群
  • 个人微店

  • 回到顶部
返回顶部