SPFILE in RAC environments

NeilZhang
NeilZhang
管理员
140
文章
106.8千
浏览
Oracle评论333字数 895阅读2分59秒阅读模式

Shared SPFILE is recommended strongly in RAC environment, and I want to tell you the reason in this post.

The test environment is Oracle 12c 12.1.0.2, and the installed PSU is 21948354.

  1. SQL> select PATCH_ID,PATCH_UID,BUNDLE_SERIES,BUNDLE_ID,STATUS from dba_registry_sqlpatch;
  2.  
  3. PATCH_ID PATCH_UID BUNDLE_SERIES BUNDLE_ID STATUS
  4. ---------- ---------- ------------------------------ ---------- ---------------
  5. 21948354 19553095 PSU 160119 SUCCESS

To show the difference, I used a non-shared SPFILE in the node rac12-node1 intentionally:

  1. SQL> select INSTANCE_NAME,NAME,VALUE from gv$parameter gp, gv$instance gi
  2. 2 where gp.INST_ID=gi.INST_ID and gp.name='spfile' order by instance_name;
  3.  
  4. INSTANCE_NAME NAME VALUE
  5. ---------------- -------------------- -----------------------------------
  6. rac12_1 spfile /tmp/aferpatch_ffile2.spfile
  7. rac12_2 spfile +DATA/rac12/spfilerac12.ora
  8. rac12_3 spfile +DATA/rac12/spfilerac12.ora

The parameter open_cursors is used during this test, and let me check its value in the DB and SPFILE before the test:

  1. SQL> select INSTANCE_NAME,NAME,VALUE from gv$parameter gp, gv$instance gi
  2. 2 where gp.INST_ID=gi.INST_ID and gp.name='open_cursors' order by instance_name;
  3.  
  4. INSTANCE_NAME NAME VALUE
  5. ---------------- -------------------- -----------------------------------
  6. rac12_1 open_cursors 300
  7. rac12_2 open_cursors 300
  8. rac12_3 open_cursors 300
  9.  
  10. SQL> select INSTANCE_NAME,gsp.SID, NAME,VALUE from gv$spparameter gsp, gv$instance gi
  11. 2 where gsp.INST_ID=gi.INST_ID and gsp.name='open_cursors' order by instance_name;
  12.  
  13. INSTANCE_NAME SID NAME VALUE
  14. ---------------- --------------- -------------------- ------------------------------
  15. rac12_1 * open_cursors 300
  16. rac12_2 * open_cursors 300
  17. rac12_3 * open_cursors 300

Usually we change parameter using sid='*', and what will happen in such situation?

  1. SQL> select instance_name,host_name from v$instance;
  2.  
  3. INSTANCE_NAME HOST_NAME
  4. ---------------- -----------------------------------
  5. rac12_1 rac12-node1.lunixdb.com
  6.  
  7. SQL> alter system set open_cursors=800;
  8.  
  9. System altered.
  10.  
  11. SQL> select INSTANCE_NAME,NAME,VALUE from gv$parameter gp, gv$instance gi
  12. 2 where gp.INST_ID=gi.INST_ID and gp.name='open_cursors' order by instance_name;
  13.  
  14. INSTANCE_NAME NAME VALUE
  15. ---------------- -------------------- ---------------------------------
  16. rac12_1 open_cursors 800
  17. rac12_2 open_cursors 800
  18. rac12_3 open_cursors 800
  19.  
  20. SQL> select INSTANCE_NAME,gsp.SID, NAME,VALUE from gv$spparameter gsp, gv$instance gi
  21. 2 where gsp.INST_ID=gi.INST_ID and gsp.name='open_cursors' order by instance_name;
  22.  
  23. INSTANCE_NAME SID NAME VALUE
  24. ---------------- ---------- -------------------- ---------------------------------
  25. rac12_1 * open_cursors 800
  26. rac12_2 * open_cursors 300
  27. rac12_3 * open_cursors 300
  28.  
  29. SQL> select instance_name,host_name from v$instance;
  30.  
  31. INSTANCE_NAME HOST_NAME
  32. ---------------- -----------------------------------
  33. rac12_2 rac12-node2.lunixdb.com
  34.  
  35. SQL> alter system set open_cursors=900;
  36.  
  37. System altered.
  38.  
  39. SQL> select INSTANCE_NAME,NAME,VALUE from gv$parameter gp, gv$instance gi
  40. 2 where gp.INST_ID=gi.INST_ID and gp.name='open_cursors' order by instance_name;
  41.  
  42. INSTANCE_NAME NAME VALUE
  43. ---------------- -------------------- ---------------------------------
  44. rac12_1 open_cursors 900
  45. rac12_2 open_cursors 900
  46. rac12_3 open_cursors 900
  47.  
  48. SQL> select INSTANCE_NAME,gsp.SID, NAME,VALUE from gv$spparameter gsp, gv$instance gi
  49. 2 where gsp.INST_ID=gi.INST_ID and gsp.name='open_cursors' order by instance_name;
  50.  
  51. INSTANCE_NAME SID NAME VALUE
  52. ---------------- ---------- -------------------- ---------------------------------
  53. rac12_1 * open_cursors 800
  54. rac12_2 * open_cursors 900
  55. rac12_3 * open_cursors 900

If we change one specific sid, then what we will get?

  1. SQL> select instance_name,host_name from v$instance;
  2.  
  3. INSTANCE_NAME HOST_NAME
  4. ---------------- -----------------------------------
  5. rac12_1 rac12-node1.lunixdb.com
  6.  
  7. SQL> alter system set open_cursors=700 sid='rac12_3';
  8.  
  9. System altered.
  10.  
  11. SQL> select INSTANCE_NAME,NAME,VALUE from gv$parameter gp, gv$instance gi
  12. 2 where gp.INST_ID=gi.INST_ID and gp.name='open_cursors' order by instance_name;
  13.  
  14. INSTANCE_NAME NAME VALUE
  15. ---------------- -------------------- ---------------------------------
  16. rac12_1 open_cursors 900
  17. rac12_2 open_cursors 900
  18. rac12_3 open_cursors 700
  19.  
  20. SQL> select INSTANCE_NAME,gsp.SID, NAME,VALUE from gv$spparameter gsp, gv$instance gi
  21. 2 where gsp.INST_ID=gi.INST_ID and gsp.name='open_cursors' order by instance_name;
  22.  
  23. INSTANCE_NAME SID NAME VALUE
  24. ---------------- ---------- -------------------- ---------------------------------
  25. rac12_1 rac12_3 open_cursors 700
  26. rac12_1 * open_cursors 800
  27. rac12_2 * open_cursors 900
  28. rac12_3 * open_cursors 900
  29.  
  30. SQL> select instance_name,host_name from v$instance;
  31.  
  32. INSTANCE_NAME HOST_NAME
  33. ---------------- -----------------------------------
  34. rac12_2 rac12-node2.lunixdb.com
  35.  
  36. SQL> alter system set open_cursors=600 sid='rac12_3';
  37.  
  38. System altered.
  39.  
  40. SQL> select INSTANCE_NAME,NAME,VALUE from gv$parameter gp, gv$instance gi
  41. 2 where gp.INST_ID=gi.INST_ID and gp.name='open_cursors' order by instance_name;
  42.  
  43. INSTANCE_NAME NAME VALUE
  44. ---------------- -------------------- ---------------------------------
  45. rac12_1 open_cursors 900
  46. rac12_2 open_cursors 900
  47. rac12_3 open_cursors 600
  48.  
  49. SQL> select INSTANCE_NAME,gsp.SID, NAME,VALUE from gv$spparameter gsp, gv$instance gi
  50. 2 where gsp.INST_ID=gi.INST_ID and gsp.name='open_cursors' order by instance_name;
  51.  
  52. INSTANCE_NAME SID NAME VALUE
  53. ---------------- ---------- -------------------- ---------------------------------
  54. rac12_1 rac12_3 open_cursors 700
  55. rac12_1 * open_cursors 800
  56. rac12_2 * open_cursors 900
  57. rac12_2 rac12_3 open_cursors 600
  58. rac12_3 * open_cursors 900
  59. rac12_3 rac12_3 open_cursors 600
  60.  
  61. 6 rows selected.

Do you find the difference?

Yes, seems the result is confusing, and let me summary the result as below:

  1. Try to use shared SPFILE in any conditions
  2. The value of the parameter will be changed always, whenever shared SPFILE is used or not.
  3. The change of the SPFILE will ONLY happen in the local SPFILE. So if the SPFILE is not shared, then other instances cannot find the changed value.
  4. In fact, every instance has its own SPFILE. If the SPFILE is shared, it will be read more then one time.

 
  • 本文由 NeilZhang 发表于16/04/2016 09:01:55
  • Repost please keep this link: https://www.dbcloudsvc.com/blogs/oracle/spfile-in-rac-environments/
匿名

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
确定