Oracle的AMM和ASMM以及相关参数探究

实验出发点

1. 数据库刚启动时候的sga信息(show sga可查看)或者通过show parameter sga/pga/db_cache_size/memory_target等等和内存有关的参数,并不能真正反映相对应大小。
   参数存在的意义是什么,要怎么查看数据库启动之后sga,pga等真正的大小。
2.如何启用AMM和ASMM
3.存在静态参数文件中类似proc.__db_cache_size、proc.__pga_aggregate_target、*.__sga_target、proc.__shared_pool_size有什么意义

环境说明:
1.操作系统版本。

  1. [oracle@oracle ~]$ uname -a
  2. Linux oracle.example.com 2.6.32-431.el6.x86_64 #1 SMP Sun Nov 10 22:19:54 EST 2013 x86_64 x86_64 x86_64 GNU/Linux
  3. [oracle@oracle ~]$ lsb_release -a
  4. LSB Version:    :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
  5. Distributor ID:    RedHatEnterpriseServer
  6. Description:    Red Hat Enterprise Linux Server release 6.5 (Santiago)
  7. Release:    6.5
  8. Codename:    Santiago

2.数据库版本。

  1. SYS@proc> select * from v$version where rownum=1;
  2.  
  3. BANNER
  4. --------------------------------------------------------------------------------
  5. Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production


实验过程:
一、实验准备
1.通过静态参数文件将memory_max_target、memory_target、sga_max_size、sga_target、pga_aggregate_target、db_cache_size参数设置为0。

  1. [oracle@oracle dbs]$ cat initproc.ora 
  2. *._in_memory_undo=TRUE
  3. *.audit_file_dest='/u01/app/oracle/admin/proc/adump'
  4. *.audit_trail='db'
  5. *.compatible='11.2.0.4.0'
  6. *.control_files='/u01/app/oracle/oradata/proc/control01.ctl','/u01/app/oracle/oradata/proc/control02.ctl'
  7. *.db_block_size=8192
  8. *.db_domain=''
  9. *.db_file_multiblock_read_count=128
  10. *.db_name='proc'
  11. *.processes=150
  12. *.remote_login_passwordfile='EXCLUSIVE'
  13. *.undo_tablespace='UNDOTBS1'
  14. memory_target=0
  15. memory_max_target=0
  16. sga_target=0
  17. sga_max_size=0
  18. pga_aggregate_target=0
  19. db_cache_size=0

2.使用新的参数文件设置启动数据库。

  1. SYS@proc> shutdown immediate;
  2. Database closed.
  3. Database dismounted.
  4. ORACLE instance shut down.
  5. SYS@proc> create spfile from pfile;
  6.  
  7. File created.
  8.  
  9. SYS@proc> startup;
  10. ORACLE instance started.
  11.  
  12. Total System Global Area  175403008 bytes
    Fixed Size                  2251416 bytes
    Variable Size             163579240 bytes
    Database Buffers            4194304 bytes
    Redo Buffers                5378048 bytes
    Database mounted.
    Database opened.

3.使用show parameter查看指定参数的状态数值。

  1. SYS@proc> show parameter memory%target
  2.  
  3. NAME                                 TYPE        VALUE
  4. ------------------------------------ ----------- ------------------------------
  5. memory_max_target                    big integer 12M
  6. memory_target                        big integer 0
  7. SYS@proc> show parameter sga
  8.  
  9. NAME                                 TYPE        VALUE
  10. ------------------------------------ ----------- ------------------------------
  11. ...省略部分内容...
  12. sga_max_size                         big integer 168M
  13. sga_target                           big integer 0
  14. SYS@proc> show parameter pga
  15.  
  16. NAME                                 TYPE        VALUE
  17. ------------------------------------ ----------- ------------------------------
  18. pga_aggregate_target                 big integer 0
  19. SYS@proc> show parameter db_cache_size
     
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    db_cache_size                        big integer 4M

说明:由于memory_target被设置为0,所以AMM此刻是被禁用的
         由于memory_target为0的情况下,sga_target为0,所以ASMM此刻是被禁用的

二、查看数据库开启后各组件的真实大小以及依赖参数
1.动态查看sga组件大小。

  1. SYS@proc> select component,current_size from v$sga_dynamic_components;
  2.  
  3. COMPONENT                                                        CURRENT_SIZE
  4. ---------------------------------------------------------------- ------------
  5. shared pool                                                         159383552
  6. large pool                                                                  0
  7. java pool                                                             4194304
  8. streams pool                                                                0
  9. DEFAULT buffer cache                                                  4194304
  10. ...省略部分内容...
  11.  
  12. 14 rows selected.
  13.  
  14. SYS@proc> show sga
  15.  
  16. Total System Global Area 175403008 bytes
  17. Fixed Size                 2251416 bytes
  18. Variable Size            163579240 bytes
  19. Database Buffers           4194304 bytes
  20. Redo Buffers               5378048 bytes 

2.查看相对应得隐含参数数值大小。

  1. SYS@proc> select x.ksppinm name,y.ksppstvl value,x.ksppdesc describ
  2.           from sys.x$ksppi x,sys.x$ksppcv y
  3.           where x.inst_id=userenv('Instance')
  4.           and y.inst_id=userenv('Instance')
  5.           and x.indx=y.indx
  6.           and (x.ksppinm like '%sga%target%' or x.ksppinm like '%memory%target%' or x.ksppinm like '%pga%target%' or x.ksppinm like '%db_cache_size%');
  7.  
  8. NAME                                     VALUE                          DESCRIB
  9. ---------------------------------------- ------------------------------ ------------------------------------------------------------------------------------------
  10. sga_target                               0                              Target size of SGA
  11. __sga_target                             0                              Actual size of SGA         --该值在AMM或者ASMM下真实反映数据库刚启动时候分配的sga大小
  12. memory_target                            0                              Target size of Oracle SGA and PGA memory
  13. memory_max_target                        12582912                       Max size for Memory Target
  14. __db_cache_size                          4194304                        Actual size of DEFAULT buffer pool for standard block size buffers
  15. db_cache_size                            4194304                        Size of DEFAULT buffer pool for standard block size buffers
  16. pga_aggregate_target                     0                              Target size for the aggregate PGA memory consumed by the instance
  17. __pga_aggregate_target                   0                              Current target size for the aggregate PGA memory consumed
  18.  
  19. 8 rows selected.

说明:注意隐含参数的描述部分。比如“__sga_target”是Actual size of SGA

三、设置数据库为AMM模式,对比各个组件变化情况
1.准备工作
1.1设置memory_max_target和memory_target等于1G。遇到了疑似BUG的报错。

  1. SYS@proc> alter system set memory_max_target=1g scope=spfile;
  2.  
  3. System altered.
  4.  
  5. SYS@proc> startup force;
  6. ORACLE instance started.
  7.  
  8. Total System Global Area 175403008 bytes
  9. Fixed Size                 2251416 bytes
  10. Variable Size            163579240 bytes
  11. Database Buffers           4194304 bytes
  12. Redo Buffers               5378048 bytes
  13. Database mounted.
  14. Database opened.
  15.  
  16. SYS@proc> alter system set memory_target=1g;
  17. alter system set memory_target=1g
  18.                        *
  19. ERROR at line 1:
  20. ORA-03113: end-of-file on communication channel
  21. Process ID: 4862
  22. Session ID: 16 Serial number: 3
  23.  
  24. SYS@proc> select status from v$instance;
  25. ERROR:
  26. ORA-03114: not connected to ORACLE
  27.  
  28.  
  29. SYS@proc> startup;
  30. ORA-24324: service handle not initialized
  31. ORA-01041: internal error. hostdef extension doesn

1.2疑似BUG的报错对应的警告日志。

  1. Errors in file /u01/app/oracle/diag/rdbms/proc/proc/trace/proc_mman_5032.trc (incident=218646):
  2. ORA-00600: internal error code, arguments: [kmgsb_resize_memory_target_2], [43], [42], [], [], [], [], [], [], [], [], []
  3. Incident details in: /u01/app/oracle/diag/rdbms/proc/proc/incident/incdir_218646/proc_mman_5032_i218646.trc
  4. Use ADRCI or Support Workbench to package the incident.
  5. See Note 411.1 at My Oracle Support for error and packaging details.
  6. Errors in file /u01/app/oracle/diag/rdbms/proc/proc/trace/proc_mman_5032.trc:
  7. ORA-00600: internal error code, arguments: [kmgsb_resize_memory_target_2], [43], [42], [], [], [], [], [], [], [], [], []
  8. MMAN (ospid: 5032): terminating the instance due to error 822
  9. Sun Dec 11 08:00:40 2016
  10. System state dump requested by (instance=1, osid=5032 (MMAN)), summary=[abnormal instance termination].
  11. System State dumped to trace file /u01/app/oracle/diag/rdbms/proc/proc/trace/proc_diag_5026_20161211080040.trc
  12. Dumping diagnostic data in directory=[cdmp_20161211080040], requested by (instance=1, osid=5032 (MMAN)), summary=[abnormal instance termination].
  13. Instance terminated by MMAN, pid = 5032

说明:在mos上查找不到相关错误,百度有类似kmgsb_resize_sga_target_1的ora600,是一个BUG。猜测kmgsb_resize_memory_target_2也是一个BUG。
         这里做记录即可。
1.3强制性在spfile中修改,然后重启即可达到目的。

  1. SYS@proc> startup;
  2. ORACLE instance started.
  3.  
  4. Total System Global Area 175403008 bytes
  5. Fixed Size                 2251416 bytes
  6. Variable Size            163579240 bytes
  7. Database Buffers           4194304 bytes
  8. Redo Buffers               5378048 bytes
  9. Database mounted.
  10. Database opened.
  11. SYS@proc> alter system set memory_target=1g scope=spfile;
  12.  
  13. System altered.
  14.  
  15. SYS@proc> startup force;
  16. ORACLE instance started.
  17.  
  18. Total System Global Area 638889984 bytes       --对比下边查出来的__sga_target可知从这里看大小并不真实。有机会做个10046(验证show sga的不准确)
  19. Fixed Size 2255872 bytes
  20. Variable Size 184550400 bytes
  21. Database Buffers 448790528 bytes
  22. Redo Buffers 3293184 bytes
  23. Database mounted.
  24. Database opened.
  25. SYS@proc> show parameter memory%target
  26.  
  27. NAME                                 TYPE        VALUE
  28. ------------------------------------ ----------- ------------------------------
  29. memory_max_target                    big integer 1G
  30. memory_target                        big integer 1G
  31. SYS@proc>
  32. SYS@proc> col name for a40
  33. SYS@proc> col value for a30
  34. SYS@proc> col DESCRIB for a90
  35. SYS@proc> select x.ksppinm name,y.ksppstvl value,x.ksppdesc describ
  36.           from sys.x$ksppi x,sys.x$ksppcv y
  37.           where x.inst_id=userenv('Instance')
  38.           and y.inst_id=userenv('Instance')
  39.           and x.indx=y.indx
  40.           and (x.ksppinm like '%sga%target%' or x.ksppinm like '%memory%target%' or x.ksppinm like '%pga%target%' or x.ksppinm like '%db_cache_size%'); 
  41.  
  42. NAME                                     VALUE                          DESCRIB
  43. ---------------------------------------- ------------------------------ ------------------------------------------------------------------------------------------
  44. sga_target                               0                              Target size of SGA
  45. __sga_target                             641728512                      Actual size of SGA
  46. memory_target                            1073741824                     Target size of Oracle SGA and PGA memory
  47. memory_max_target                        1073741824                     Max size for Memory Target
  48. __db_cache_size                          448790528                      Actual size of DEFAULT buffer pool for standard block size buffers
  49. db_cache_size                            0                              Size of DEFAULT buffer pool for standard block size buffers
  50. pga_aggregate_target                     0                              Target size for the aggregate PGA memory consumed by the instance
  51. __pga_aggregate_target                   432013312                      Current target size for the aggregate PGA memory consumed
  52.  
  53. 8 rows selected.

2.sga_target和pga_aggregate_target同时设置大小

  1. SYS@proc> alter system set sga_max_size=500m scope=spfile;
  2.  
  3. System altered.
  4.  
  5. SYS@proc> alter system set sga_target=500m;
  6.  
  7. System altered.
  8.  
  9. SYS@proc> alter system set pga_aggregate_target=525m;        --1024-500=524,由于设置了sga_target=500m,可知pga_aggregate_target设置不能超过524 
  10. alter system set pga_aggregate_target=525m     --过来假设先设置pga_aggregate_target=500,在设置sga_target超过524是可以的,不过startup报ORA-00838:"Specified value of MEMORY_TARGET is too small, needs to be at least %sM"
  11. *
  12. ERROR at line 1:
  13. ORA-02097: parameter cannot be modified because specified value is invalid
  14. ORA-00840: PGA_AGGREGATE_TARGET cannot be modified to the specified value
  15.  
  16.  
  17. SYS@proc> alter system set pga_aggregate_target=400m;
  18.  
  19. System altered.
  20.  
  21. SYS@proc> startup force;
  22. ...省略部分内容...
  23. Database opened.
  24. SYS@proc> show parameter pga
  25.  
  26. NAME                                 TYPE        VALUE
  27. ------------------------------------ ----------- ------------------------------
  28. pga_aggregate_target                 big integer 400M
  29. SYS@proc> show parameter sga
  30.  
  31. NAME                                 TYPE        VALUE
  32. ------------------------------------ ----------- ------------------------------
  33. ...省略部分内容...
  34. sga_max_size                         big integer 500M
  35. sga_target                           big integer 500M
  36. SYS@proc> col name for a40
  37. SYS@proc> col value for a30
  38. SYS@proc> col DESCRIB for a90
  39. SYS@proc> select x.ksppinm name,y.ksppstvl value,x.ksppdesc describ
  40.           from sys.x$ksppi x,sys.x$ksppcv y
  41.           where x.inst_id=userenv('Instance')
  42.           and y.inst_id=userenv('Instance')
  43.           and x.indx=y.indx
  44.           and (x.ksppinm like 'SYS@proc> SYS@proc> SYS@proc> 2 3 4 5 6 %sga%target%' or x.ksppinm like '%memory%target%' or x.ksppinm like '%pga%target%' or x.ksppinm like '%db_cache_size%');
  45.  
  46. NAME                                     VALUE                          DESCRIB
  47. ---------------------------------------- ------------------------------ ------------------------------------------------------------------------------------------
  48. sga_target                               524288000                      Target size of SGA
  49. __sga_target                             524288000                      Actual size of SGA
  50. memory_target                            1073741824                     Target size of Oracle SGA and PGA memory
  51. memory_max_target                        1073741824                     Max size for Memory Target
  52. __db_cache_size                          331350016                      Actual size of DEFAULT buffer pool for standard block size buffers
  53. db_cache_size                            0                              Size of DEFAULT buffer pool for standard block size buffers
  54. pga_aggregate_target                     419430400                      Target size for the aggregate PGA memory consumed by the instance
  55. __pga_aggregate_target                   549453824                      Current target size for the aggregate PGA memory consumed
  56.  
  57. 8 rows selected.
  58.  
  59. SYS@proc> alter system set sga_target=400m;
  60.  
  61. System altered.
  62. SYS@proc> alter system set pga_aggregate_target=400m;
  63. System altered.
  64.  
  65. SYS@proc> startup force;
  66. ...省略部分内容...
  67. Database opened.
  68. SYS@proc> show parameter sga
  69.  
  70. NAME                                 TYPE        VALUE
  71. ------------------------------------ ----------- ------------------------------
  72. sga_max_size                         big integer 500M
  73. sga_target                           big integer 400M
  74. SYS@proc> show parameter pga
  75.  
  76. NAME                                 TYPE        VALUE
  77. ------------------------------------ ----------- ------------------------------
  78. pga_aggregate_target                 big integer 400M
  79.  
  80. SYS@proc>select x.ksppinm name,y.ksppstvl value,x.ksppdesc describ
  81.          from sys.x$ksppi x,sys.x$ksppcv y
  82.          where x.inst_id=userenv('Instance')
  83.          and y.inst_id=userenv('Instance')
  84.          and x.indx=y.indx
  85.          and (x.ksppinm like '%sga%target%' or x.ksppinm like '%memory%target%' or x.ksppinm like '%pga%target%' or x.ksppinm like '%db_cache_size%');
  86.  
  87. NAME                                     VALUE                          DESCRIB
  88. ---------------------------------------- ------------------------------ ------------------------------------------------------------------------------------------
  89. sga_target                               419430400                      Target size of SGA
  90. __sga_target                             524288000                      Actual size of SGA
  91. memory_target                            1073741824                     Target size of Oracle SGA and PGA memory
  92. memory_max_target                        1073741824                     Max size for Memory Target
  93. __db_cache_size                          331350016                      Actual size of DEFAULT buffer pool for standard block size buffers
  94. db_cache_size                            0                              Size of DEFAULT buffer pool for standard block size buffers
  95. pga_aggregate_target                     419430400                      Target size for the aggregate PGA memory consumed by the instance
  96. __pga_aggregate_target                   549453824                      Current target size for the aggregate PGA memory consumed
  97.  
  98. 8 rows selected.

结论是:同时设置了sga_target和pga_aggregate_target两个值的话,
              若这是sga_target+pga_aggregate_target>memory_target是更改不成功的,若是强制性更改(即加上scope=spfile),则startup会报错。
              若sga_target+pga_aggregate_target<memory_target
                    若更改的sga_target<__sga_target,则实际sga的大小还是为原来更改之前__sga_target (__sga_target有点像高水位线)
                    若更改的sga_target>__sga_target,令__sga_target=sga_target,sga大小设置为__sga_target
              而__pga_aggregate_target的实际的值则为memory_target-__sga_target,也就是__sga_target+__sga_target=memory_target。
3.sga_target和pga_aggregate_target同时设置大小(直接结论,实验过程略去,下同)
结论是:sga_target设置大小,pga_aggregate_target没有设置大小
那么pga_aggregate_target初始化值=memory_target-sga_target
4.sga_target没有设置大小,pga_aggregate_target设置大小
结论是:sga_target初始化值=memory_target-pga_aggregate_target
5.sga_target和pga_aggregate_target都没有设置大小
结论是:Oracle将对这两个值没有最小值和默认值。Oracle将根据数据库运行状况进行分配大小。但在数据库启动是会有一个固定比例来分配:
sga_target = memory_target*60%
pga_aggregate_target = memory_target*40%

四、其它
1.如何降低“高水位线”“__sga_target”呢,经测试只能修改静态参数文件里边proc.__sga_target的值,而无法通过alter system set "__sga_target"=500m scope=spfile;的方式修改(会同时将sga_target和sga_max_size也手动设置调小),虽然可以成功执行。
2.实验过程可得出AMM下,无论sga_target是否为0,ASMM是生效的。
    有几种情况:
        2.1 memory_target<>0也就是AMM模式下,包含ASMM
        2.2 memory_target=0也就是10G一样的情况下
              sga_target=0也就是禁用ASMM下,SGA中的各组件大小都要明确设定,不能自动调整各组件大小。
              sga_target<>0(ASMM),系统自动调整SGA各组件大小。
              PGA则依赖pga_aggregate_target的大小,因为10G模式下PGA不能自动调整。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值