返璞归真:实例会话RAC条件下的笛卡尔积种参数可能性
从实例级别和会话级别,再加上多个实例,我们获得的初始化参数可能是一个笛卡尔积,如果没有清晰的思路,极有可能迷惑不已。...
杨廷琨(yangtingkun)
我们知道:使用 SHOW PARAMETER 查询,看到的是当前会话可以看到的初始化参数,那么这个参数导致是全局设置还是当前实例设置的,是从这个命令中看不到的。
虽然 Oracle 提供了 GV$ 开头的初始化参数,可以用来查询两个实例上的设置,但是情况并不是这么简单的。我们可以初步思考一下:从实例级别和会话级别,再加上多个实例,这是一个笛卡尔积的可能性,如果没有清晰的思路,极有可能被输出搞得迷惑不已。。
我们通过一个简单的例子来分析一下:
SQL> show parameter open_cursors
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
open_cursors integer 300
SQL> alter system set open_cursors = 500 scope = both sid = 'test1';
系统已更改。
SQL> disc
从 Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options 断开
SQL> set instance test2
Oracle Database 11g Release 11.1.0.0.0 - Production
SQL> conn sys as sysdba
输入口令:
已连接。
SQL> alter system set open_cursors = 400 scope = both sid = 'test2';
系统已更改。
SQL> disc
从 Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options 断开
SQL> set instance local
Oracle Database 11g Release 11.1.0.0.0 - Production
SQL> conn / as sysdba
已连接。
现在来看看不同的查询方法得到的结果:
SQL> select name, value
2 from v$parameter
3 where name = 'open_cursors';
NAME VALUE
------------------------------ --------------------------------
open_cursors 500
SQL> select inst_id, name, value
2 from gv$parameter
3 where name = 'open_cursors';
INST_ID NAME VALUE
---------- ------------------------------ ---------------------------
1 open_cursors 500
2 open_cursors 400
SQL> show parameter open_cursors
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
open_cursors integer 500
SQL> select sid, name, value
2 from v$spparameter
3 where name = 'open_cursors';
SID NAME VALUE
---------- ------------------------------ ---------------------------
* open_cursors 300
test1 open_cursors 500
test2 open_cursors 400
SQL> show spparameter open_cursors
SID NAME TYPE VALUE
-------- ----------------------------- ----------- ---------------
* open_cursors integer 300
test2 open_cursors integer 400
test1 open_cursors integer 500
似乎除了看不到全局设置外,GV$PARAMETER 参数和 V$SPPARAMETER 没有什么不同,其实不然,如果 alter system set 的时候只修改了 spfile 或只修改了 memory 参数,结果就会不同:
SQL> alter system set open_cursors = 600 scope = memory sid = 'test1';
系统已更改。
SQL> alter system set open_cursors = 700 scope = spfile sid = 'test2';
系统已更改。
SQL> select name, value
2 from v$parameter
3 where name = 'open_cursors';
NAME VALUE
------------------------------ --------------------------------------------------
open_cursors 600
SQL> select inst_id, name, value
2 from gv$parameter
3 where name = 'open_cursors';
INST_ID NAME VALUE
---------- ------------------------------ --------------------------------------------------
1 open_cursors 600
2 open_cursors 400
SQL> select sid, name, value
2 from v$spparameter
3 where name = 'open_cursors';
SID NAME VALUE
---------- ------------------------------ --------------------------------------------------
* open_cursors 300
test1 open_cursors 500
test2 open_cursors 700
从上面的对比就可以看出,通过 GV$ 视图访问的结果和 SPFILE 中包含的信息其实是两回事。
除了上面介绍的几种视图之外,CREATE PFILE 其实也是一个不错的选择,在10g 以前只能 CREATE PFILE FROM SPFILE,得到的结果类似于对 VSPPARAMETER 视图的查询,而11g增加了 CREATE PFILE FROM MEMORY 选项,这个得到的结果类似于从 GV$SYSTEM_PARAMETER 视图获取的查询。
诗和远方:云和恩墨大讲堂期刊第四期
删繁就简-云和恩墨的一道面试题解析
用SQL解一道数学题:Gauss和Poincare
新年贺礼:云和恩墨大讲堂期刊发行
2015 Oracle 十大热门文章精选
Oracle 12c ASM 防火防盗新特性揭秘
DBA入门之路:学习与进阶之经验谈
DBA入门之路:关于日常工作的建议
2016YHEMSZ,云和恩墨大讲堂2016深圳交流会PPT;
2016GOPSZ,2016深圳全球运维大会PPT;
DBALife,"DBA的一天"精品海报大图;
12cArch,“Oracle 12c体系结构”精品海报大图;
DBA01,《Oracle DBA手记》第一本图书下载;
YunHe,“云和恩墨大讲堂”案例文档下载地址;
关注 Oracle
微信扫一扫关注公众号