暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

返璞归真:RAC环境下不同实例的参数文件选择与设置

杨廷琨 2016-04-19
497


杨廷琨(yangtingkun)

云和恩墨 CTO

高级咨询顾问,Oracle ACE 总监,ITPUB Oracle 数据库管理版版主


参数文件是Oracle数据库文件中级别最低,也是最基本的文件,但是也是数据库实例启动第一个涉及的文件。如果参数文件缺失或者某些参数设置错误,数据库就无法启动。


我们思考一个问题: V$SPPARAMETER 参数本身就包含了 SID 列,SPFILE 中本身就包含了所有实例的设置,那么查询 GV$SPPARAMETER 视图是否就意义不大呢,GV$SPPARAMETER 是否有意义?


看看这样一种情形:RAC 的各个节点可以使用统一的 SPFILE 启动,同样也可以选择不同的 SPFILE 来进行启动,这时 GV$SPPARAMETER 视图中获取结果,才是真正各个实例 SPFILE 中设置的结果,其意义由此体现。


这样说比较难以理解,看一个简单的例子:

SQL> select inst_id, name, value
2  from gv$system_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

SQL> select inst_id, sid, name, value
2  from gv$spparameter
3  where name = 'open_cursors';

 INST_ID SID        NAME                           VALUE
---------- ---------- ------------------------------ ------------------------------------
       1 *          open_cursors                   300
       1 test1      open_cursors                   500
       1 test2      open_cursors                   700
       2 *          open_cursors                   300
       2 test1      open_cursors                   500
       2 test2      open_cursors                   700

已选择6行。

SQL> select inst_id, name, value
2  from gv$system_parameter
3  where name = 'spfile';

 INST_ID NAME                           VALUE
---------- ------------------------------ --------------------------------------------------
       1 spfile                         +DATA/test/spfiletest.ora
       2 spfile                         +DATA/test/spfiletest.ora


下面里面内存中参数来创建 SPFILE,并利用新建的 SPFILE 来启动当前实例:

SQL> create spfile='/export/home/oracle/spfiletest1.ora' from memory;

文件已创建。

SQL> host     
$ vi export/home/oracle/inittest1.ora
"/export/home/oracle/inittest1.ora" [New file] 
spfile=/export/home/oracle/spfiletest1.ora

"/export/home/oracle/inittest1.ora" [New file] 2 lines, 44 characters 
$ exit

SQL> shutdown immediate
数据库已经关闭。
已经卸载数据库。
ORACLE 例程已经关闭。
SQL> startup pfile=/export/home/oracle/inittest1.ora
ORACLE 例程已经启动。

Total System Global Area  776896512 bytes
Fixed Size                  2098776 bytes
Variable Size             246069672 bytes
Database Buffers          524288000 bytes
Redo Buffers                4440064 bytes
数据库装载完毕。
数据库已经打开。


下面检查 spfile 中的设置:

SQL> select inst_id, name, value             
2  from gv$system_parameter
3  where name = 'spfile';

 INST_ID NAME                           VALUE
---------- ------------------------------ --------------------------------------------------
       1 spfile                         /export/home/oracle/spfiletest1.ora
       2 spfile                         +DATA/test/spfiletest.ora

SQL> select inst_id, name, value
2  from gv$system_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
---------- ------------------------------ --------------------------------------------------
test1      open_cursors                   600
test2      open_cursors                   400

SQL> select inst_id, sid, name, value
2  from gv$spparameter
3  where name = 'open_cursors';

 INST_ID SID        NAME                           VALUE
---------- ---------- ------------------------------ --------------------------------
       2 *          open_cursors                   300
       2 test1      open_cursors                   500
       2 test2      open_cursors                   700
       1 test1      open_cursors                   600
       1 test2      open_cursors                   400


可以看到,由于两个实例采用了不同的 SPFILE,导致两个实例上设置的对方实例的初始化参数值,与对方实例上当前设置值不符


在上面的例子中,两个实例上真正的参数设置查询方式为:

SQL> select inst_id, sid, name, value
2  from gv$spparameter
3  where name = 'open_cursors'
4  and substr(sid, -1) = to_char(inst_id);

 INST_ID SID        NAME                           VALUE
---------- ---------- ------------------------------ -----------------------------------
       2 test2      open_cursors                   700
       1 test1      open_cursors                   600


由此我们可以看到,在不同场景之下,获取真实参数的过程可能是一波三折,疏为不易的。


如何加入"云和恩墨大讲堂"微信群

搜索 盖国强(Eygle) :eeygle,或者扫描下面二维码,备注:云和恩墨大讲堂,即可入群。每周与千人共享免费技术分享,与讲师在线讨论。

近期文章

诗和远方:云和恩墨大讲堂期刊第四期

删繁就简-云和恩墨的一道面试题解析

用SQL解一道数学题:Gauss和Poincare

新年贺礼:云和恩墨大讲堂期刊发行

2015 Oracle 十大热门文章精选

Oracle 12c ASM 防火防盗新特性揭秘

DBA入门之路:学习与进阶之经验谈

DBA入门之路:关于日常工作的建议

资源下载

(帐号:OraNews)回复关键字获取最新学习资源

2016YHEMSZ ,云和恩墨大讲堂2016深圳交流会PPT;

2016GOPSZ ,2016深圳全球运维大会PPT;

DBALife ,"DBA的一天"精品海报大图;

12cArch ,“Oracle 12c体系结构”精品海报大图;

DBA01 ,《Oracle DBA手记》第一本图书下载;

YunHe “云和恩墨大讲堂”案例文档下载地址;


最后修改时间:2020-05-08 00:20:49
文章转载自杨廷琨,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论