Ash Buffer是SGA里的一块循环使用的内存区域,用于存放MMON捕捉到的active session信息,MMNL每隔60min将Ash buffer的内容经过过滤后dump到AWR,对应的视图是DBA_HIST_ACTIVE_SESS_HISTORY,以腾出Ash buffer空间用于之后的采集。Ash Buffer的大小在instance启动时就已经决定了,并且在instance运行期间不能被动态调整,那么Ash Buffer的大小是由哪些因素决定的?
关于ASH buffer的大小MOS 243132.1上有如下描述
Size of ASH Circular Buffer = Max [Min [ #CPUs * 2 MB, 5% of Shared Pool Size, 30MB ], 1MB ]
###看下实际环境里和ash buffer有关的参数
SQL> show parameter cpu_count
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
cpu_count integer 16
SQL> show parameter shared_pool_size
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
shared_pool_size big integer 1312M
---计算一下ash buffer应该为多少大小
Max [Min [ 16 * 2 MB, 5%*1312M, 30MB ], 1MB ]=30MB
---实际Ash buffer大小可以从v$sgastat、v$ash_info获得,均为32MB,和公式提供的稍有差别,选择32MB作为Ash Buffer
select * from v$sgastat where name='ASH buffers';
POOL NAME BYTES
------------ -------------------------- ----------
shared pool ASH buffers 33554432
select total_size,fixed_size,sampling_interval from v$ash_info;
TOTAL_SIZE FIXED_SIZE SAMPLING_INTERVAL
---------- ---------- -----------------
33554432 33554432 1000
###更改一下cpu_count
alter system set cpu_count=8 scope=spfile;
startup force
show parameter cpu_count
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
cpu_count integer 8
---按照公式Size of ASH Circular Buffer = Max [Min [ #CPUs * 2 MB, 5% of Shared Pool Size, 30MB ], 1MB ]计算
Ash buffer=Max [Min [ 8 * 2 MB, 5%*1312M, 30MB ], 1MB ]=16MB
---下面的查询结果应验了上面的计算
select total_size,fixed_size,sampling_interval from v$ash_info;
TOTAL_SIZE FIXED_SIZE SAMPLING_INTERVAL
---------- ---------- -----------------
16777216 16777216 1000
select * from v$sgastat where name='ASH buffers';
POOL NAME BYTES
------------ -------------------------- ----------
shared pool ASH buffers 16777216
###"_ash_size"隐含参数控制ash buffer的大小
公式Size of ASH Circular Buffer = Max [Min [ #CPUs * 2 MB, 5% of Shared Pool Size, 30MB ], 1MB ]里的1MB是_ash_size的默认值
---_ash_size的默认值为1MB
select ksppinm,ksppstvl from x$ksppi x, x$ksppcv y where (x.indx = y.indx) and ksppinm like '_ash_size%'
KSPPINM KSPPSTVL
------------------------------ ------------------------------
_ash_size 1048618
---我们把_ash_size改大,改成64MB
alter system set "_ash_size"=67108864 scope=spfile;
startup force
---计算一下此时的Ash buffer值
ASH Circular Buffer = Max [Min [ 8 * 2 MB, 5%*1315M, 30MB ], 64MB ]=64MB
---下面的查询结果应验了上面的计算
SQL> select total_size,fixed_size,sampling_interval from v$ash_info;
TOTAL_SIZE FIXED_SIZE SAMPLING_INTERVAL
---------- ---------- -----------------
67108864 67108864 1000
SQL> select * from v$sgastat where name='ASH buffers';
POOL NAME BYTES
------------ -------------------------- ----------
shared pool ASH buffers 67108864
因此Ash Buffer的计算公式可以修正为
Size of ASH Circular Buffer = Max [Min [ #CPUs * 2 MB, 5% of Shared Pool Size, 30MB ], _ash_size ]
如果要调整ash buffer的大小,需要修改_ash_size参数,且确保_ash_size> Min [ #CPUs * 2 MB, 5% of Shared Pool Size, 30MB ]
在CentOS 6.4下安装Oracle 11gR2(x64)
Oracle 11gR2 在VMWare虚拟机中安装步骤
Debian 下 安装 Oracle 11g XE R2
: