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. BANNER
  3. --------------------------------------------------------------------------------
  4. 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. File created.

  7. SYS@proc> startup;
  8. ORACLE instance started.

  9. 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. NAME                                 TYPE        VALUE
  3. ------------------------------------ ----------- ------------------------------
  4. memory_max_target                    big integer 12M
  5. memory_target                        big integer 0
  6. SYS@proc> show parameter sga

  7. NAME                                 TYPE        VALUE
  8. ------------------------------------ ----------- ------------------------------
  9. ...省略部分内容...
  10. sga_max_size                         big integer 168M
  11. sga_target                           big integer 0
  12. SYS@proc> show parameter pga

  13. NAME                                 TYPE        VALUE
  14. ------------------------------------ ----------- ------------------------------
  15. pga_aggregate_target                 big integer 0
  16. 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. COMPONENT                                                        CURRENT_SIZE
  3. ---------------------------------------------------------------- ------------
  4. shared pool                                                         159383552
  5. large pool                                                                  0
  6. java pool                                                             4194304
  7. streams pool                                                                0
  8. DEFAULT buffer cache                                                  4194304
  9. ...省略部分内容...

  10. 14 rows selected.

  11. SYS@proc> show sga

  12. Total System Global Area 175403008 bytes
  13. Fixed Size                 2251416 bytes
  14. Variable Size            163579240 bytes
  15. Database Buffers           4194304 bytes
  16. 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. NAME                                     VALUE                          DESCRIB
  8. ---------------------------------------- ------------------------------ ------------------------------------------------------------------------------------------
  9. sga_target                               0                              Target size of SGA
  10. __sga_target                             0                              Actual size of SGA         --该值在AMM或者ASMM下真实反映数据库刚启动时候分配的sga大小
  11. memory_target                            0                              Target size of Oracle SGA and PGA memory
  12. memory_max_target                        12582912                       Max size for Memory Target
  13. __db_cache_size                          4194304                        Actual size of DEFAULT buffer pool for standard block size buffers
  14. db_cache_size                            4194304                        Size of DEFAULT buffer pool for standard block size buffers
  15. pga_aggregate_target                     0                              Target size for the aggregate PGA memory consumed by the instance
  16. __pga_aggregate_target                   0                              Current target size for the aggregate PGA memory consumed

  17. 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. System altered.

  3. SYS@proc> startup force;
  4. ORACLE instance started.

  5. Total System Global Area 175403008 bytes
  6. Fixed Size                 2251416 bytes
  7. Variable Size            163579240 bytes
  8. Database Buffers           4194304 bytes
  9. Redo Buffers               5378048 bytes
  10. Database mounted.
  11. Database opened.

  12. SYS@proc> alter system set memory_target=1g;
  13. alter system set memory_target=1g
  14.                        *
  15. ERROR at line 1:
  16. ORA-03113: end-of-file on communication channel
  17. Process ID: 4862
  18. Session ID: 16 Serial number: 3

  19. SYS@proc> select status from v$instance;
  20. ERROR:
  21. ORA-03114: not connected to ORACLE


  22. SYS@proc> startup;
  23. ORA-24324: service handle not initialized
  24. 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. Total System Global Area 175403008 bytes
  4. Fixed Size                 2251416 bytes
  5. Variable Size            163579240 bytes
  6. Database Buffers           4194304 bytes
  7. Redo Buffers               5378048 bytes
  8. Database mounted.
  9. Database opened.
  10. SYS@proc> alter system set memory_target=1g scope=spfile;

  11. System altered.

  12. SYS@proc> startup force;
  13. ORACLE instance started.

  14. Total System Global Area 638889984 bytes       --对比下边查出来的__sga_target可知从这里看大小并不真实。有机会做个10046(验证show sga的不准确)
  15. Fixed Size 2255872 bytes
  16. Variable Size 184550400 bytes
  17. Database Buffers 448790528 bytes
  18. Redo Buffers 3293184 bytes
  19. Database mounted.
  20. Database opened.
  21. SYS@proc> show parameter memory%target

  22. NAME                                 TYPE        VALUE
  23. ------------------------------------ ----------- ------------------------------
  24. memory_max_target                    big integer 1G
  25. memory_target                        big integer 1G
  26. SYS@proc>
  27. SYS@proc> col name for a40
  28. SYS@proc> col value for a30
  29. SYS@proc> col DESCRIB for a90
  30. SYS@proc> select x.ksppinm name,y.ksppstvl value,x.ksppdesc describ
  31.           from sys.x$ksppi x,sys.x$ksppcv y
  32.           where x.inst_id=userenv('Instance')
  33.           and y.inst_id=userenv('Instance')
  34.           and x.indx=y.indx
  35.           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%');

  36. NAME                                     VALUE                          DESCRIB
  37. ---------------------------------------- ------------------------------ ------------------------------------------------------------------------------------------
  38. sga_target                               0                              Target size of SGA
  39. __sga_target                             641728512                      Actual size of SGA
  40. memory_target                            1073741824                     Target size of Oracle SGA and PGA memory
  41. memory_max_target                        1073741824                     Max size for Memory Target
  42. __db_cache_size                          448790528                      Actual size of DEFAULT buffer pool for standard block size buffers
  43. db_cache_size                            0                              Size of DEFAULT buffer pool for standard block size buffers
  44. pga_aggregate_target                     0                              Target size for the aggregate PGA memory consumed by the instance
  45. __pga_aggregate_target                   432013312                      Current target size for the aggregate PGA memory consumed

  46. 8 rows selected.
2.sga_target和pga_aggregate_target同时设置大小
  1. SYS@proc> alter system set sga_max_size=500m scope=spfile;

  2. System altered.

  3. SYS@proc> alter system set sga_target=500m;

  4. System altered.

  5. SYS@proc> alter system set pga_aggregate_target=525m;        --1024-500=524,由于设置了sga_target=500m,可知pga_aggregate_target设置不能超过524
  6. 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"
  7. *
  8. ERROR at line 1:
  9. ORA-02097: parameter cannot be modified because specified value is invalid
  10. ORA-00840: PGA_AGGREGATE_TARGET cannot be modified to the specified value


  11. SYS@proc> alter system set pga_aggregate_target=400m;

  12. System altered.

  13. SYS@proc> startup force;
  14. ...省略部分内容...
  15. Database opened.
  16. SYS@proc> show parameter pga

  17. NAME                                 TYPE        VALUE
  18. ------------------------------------ ----------- ------------------------------
  19. pga_aggregate_target                 big integer 400M
  20. SYS@proc> show parameter sga

  21. NAME                                 TYPE        VALUE
  22. ------------------------------------ ----------- ------------------------------
  23. ...省略部分内容...
  24. sga_max_size                         big integer 500M
  25. sga_target                           big integer 500M
  26. SYS@proc> col name for a40
  27. SYS@proc> col value for a30
  28. SYS@proc> col DESCRIB for a90
  29. SYS@proc> select x.ksppinm name,y.ksppstvl value,x.ksppdesc describ
  30.           from sys.x$ksppi x,sys.x$ksppcv y
  31.           where x.inst_id=userenv('Instance')
  32.           and y.inst_id=userenv('Instance')
  33.           and x.indx=y.indx
  34.           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%');

  35. NAME                                     VALUE                          DESCRIB
  36. ---------------------------------------- ------------------------------ ------------------------------------------------------------------------------------------
  37. sga_target                               524288000                      Target size of SGA
  38. __sga_target                             524288000                      Actual size of SGA
  39. memory_target                            1073741824                     Target size of Oracle SGA and PGA memory
  40. memory_max_target                        1073741824                     Max size for Memory Target
  41. __db_cache_size                          331350016                      Actual size of DEFAULT buffer pool for standard block size buffers
  42. db_cache_size                            0                              Size of DEFAULT buffer pool for standard block size buffers
  43. pga_aggregate_target                     419430400                      Target size for the aggregate PGA memory consumed by the instance
  44. __pga_aggregate_target                   549453824                      Current target size for the aggregate PGA memory consumed

  45. 8 rows selected.

  46. SYS@proc> alter system set sga_target=400m;

  47. System altered.
  48. SYS@proc> alter system set pga_aggregate_target=400m;
  49. System altered.

  50. SYS@proc> startup force;
  51. ...省略部分内容...
  52. Database opened.
  53. SYS@proc> show parameter sga

  54. NAME                                 TYPE        VALUE
  55. ------------------------------------ ----------- ------------------------------
  56. sga_max_size                         big integer 500M
  57. sga_target                           big integer 400M
  58. SYS@proc> show parameter pga

  59. NAME                                 TYPE        VALUE
  60. ------------------------------------ ----------- ------------------------------
  61. pga_aggregate_target                 big integer 400M

  62. SYS@proc>select x.ksppinm name,y.ksppstvl value,x.ksppdesc describ
  63.          from sys.x$ksppi x,sys.x$ksppcv y
  64.          where x.inst_id=userenv('Instance')
  65.          and y.inst_id=userenv('Instance')
  66.          and x.indx=y.indx
  67.          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%');

  68. NAME                                     VALUE                          DESCRIB
  69. ---------------------------------------- ------------------------------ ------------------------------------------------------------------------------------------
  70. sga_target                               419430400                      Target size of SGA
  71. __sga_target                             524288000                      Actual size of SGA
  72. memory_target                            1073741824                     Target size of Oracle SGA and PGA memory
  73. memory_max_target                        1073741824                     Max size for Memory Target
  74. __db_cache_size                          331350016                      Actual size of DEFAULT buffer pool for standard block size buffers
  75. db_cache_size                            0                              Size of DEFAULT buffer pool for standard block size buffers
  76. pga_aggregate_target                     419430400                      Target size for the aggregate PGA memory consumed by the instance
  77. __pga_aggregate_target                   549453824                      Current target size for the aggregate PGA memory consumed

  78. 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不能自动调整。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30174570/viewspace-2139954/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/30174570/viewspace-2139954/

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值