Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2767053
  • 博文数量: 389
  • 博客积分: 4177
  • 博客等级: 上校
  • 技术积分: 4773
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-16 23:29
文章分类

全部博文(389)

分类: Oracle

2013-11-16 12:24:11

                                     oracle 11gR2和12C中引入AMM和hugepage的使用.

      AMM是分配内存的方式是在/dev/shm创文件的方式,每个文件大小为granule大小.这种方式和使用huge page的方式
不兼容,所以使用huge page必须要禁掉amm.而使用asmm的方式,是使用传统的共享内存方式.

The Automatic Memory Management (AMM) and HugePages are not compatible.
With AMM the entire SGA memory is allocated by creating files under /dev/shm.
When Oracle Database allocates SGA that way HugePages are not reserved.
You must disable AMM on Oracle Database 11g to use HugePages.

   在以前使用huge pages时,需要定义db_block_buffers来定义cache buffer使用huge page的数量.其他的内存组件是不能使用
huge page的

 

   现在新增加一个参数,use_large_pages,默认为true,oracle数据库在启动时,先会使用在os层面定义好的huge page数量
然后再加上其他的内存,比如现在sga_target=定义了1500M,vm.nr_hugepages=200(2MB),会先使用这个200M的huge page,
再加上其他定义的1100M,这样就避免了只有db_block_buffers使用huge page的情况.

[root@o12c dbs]# cat /etc/sysctl.conf | grep vm
vm.nr_hugepages=40


[root@o12c dbs]# cat /etc/security/limits.conf | grep memlock  --要大于hugepage的size
#        - memlock - max locked-in-memory address space (KB)
oracle soft memlock 5000000000
oracle hard memlock 5000000000


SQL> show parameter use_large_pages;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
use_large_pages                      string      TRUE

这样实例在启动时,会用光所有可用的hugepage,不足的部分再按正常的内存去分配.


Wed Nov 13 04:01:36 2013
************************ Large Pages Information *******************
Wed Nov 13 04:01:36 2013
Per process system memlock (soft) limit = 4768 GB
Wed Nov 13 04:01:36 2013
 
Total System Global Area in large pages = 78 MB (9%)
Wed Nov 13 04:01:36 2013
 
Large pages used by this instance: 39 (78 MB)
Wed Nov 13 04:01:36 2013
Large pages unused system wide = 1 (2048 KB)
Wed Nov 13 04:01:36 2013
Large pages configured system wide = 40 (80 MB)
Wed Nov 13 04:01:36 2013
Large page size = 2048 KB
Wed Nov 13 04:01:36 2013

 


In Oracle Database 11g Release 2 (11.2.0.3), Oracle allocates as much of the SGA as it can in large pages,
 and if it runs out, it will allocate the rest of the SGA using regular sized pages.
This can cause the instance to create additional shared memory segments for the SGA, but the total SGA size will be unchanged.
In this supported mixed page mode allocation, the database will exhaust the available large pages before switching to regular sized pages.


  在使用AMM的时候,尽可能的给SGA_TARGET设置一个边界,防止PGA抢占更多内存,以带来SGA不足,引发更大的问题.


  而在AMM的时候,PGA在/dev/shm中大小全为0

  
[root@test oracle]# ls -l /dev/shm | grep -i test | awk  '{print $5,$9}' | grep  ^0 | wc -l
172


SQL> select component,current_size from v$memory_dynamic_components where component='PGA Target';

COMPONENT                                                        CURRENT_SIZE
---------------------------------------------------------------- ------------
PGA Target                                                         5771362304

SQL> select 172*32*1024*1024 from dual;  --32*1024*1024为granule size

172*32*1024*1024
----------------
      5771362304

阅读(5798) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~