大页内存的设置
不管是AIX平台还是在Linux平台使用大页内存(Large Page Memory)都是依赖于操作系统的特性。Linux平台和AIX平台默认的页面大小都是4K,Linux平台的HugePage特性通常每个页面可以调整为2M;AIX平台的Large Page Memory使得单个页面最大可以调整为16M;下面详细讨论在AIX平台下,Oracle数据库实例使用64K和16M两种规格的内存页面,主要讨论的是16M的内存页面。
1、 aix支持页面的大小
# pagesize -a
4096
65536
16777216
17179869184
查看是否使用了大页内存
# vmo -L lgpg_size
NAME CUR DEF BOOT MIN MAX UNIT TYPE DEPENDENCIES
--------------------------------------------------------------------------------
lgpg_size 0 0 0 0 16M bytes D
lgpg_regions
--------------------------------------------------------------------------------
2、ORACLE启用大页的前提
ORACLE有下面三种类型的内存支持大页SGA,.DATA,.TEXT,这里只介绍SGA,因为正常情况下我们也只配置SGA的。
如果ORACLE要启用大页,那么ORACLE的user需要具有 CAP_BYPASS_RAC_VMM and CAP_PROPAGATE属性,如果是在RAC环境中,ROOT,GRID(11G)用户也要有CAP_BYPASS_RAC_VMM and CAP_PROPAGATE属性使用如下命令查看与修改
#lsuser -a capabilities oracle
oracle
#chuser capabilities=CAP_BYPASS_RAC_VMM,CAP_PROPAGATE oracle
#set -o vi
# lsuser -a capabilities oracle
oracle capabilities=CAP_NUMA_ATTACH,CAP_BYPASS_RAC_VMM,CAP_PROPAGATE
3 、AIX大页内存的参数查看
lgpg_regions控制大页的个数lgpg_size控制页的大小,使用如下命令查看与修改
查看大页内存的个数,一个大页的大小
# vmo -L lgpg_regions -L lgpg_size
NAME CUR DEF BOOT MIN MAX UNIT TYPE DEPENDENCIES
--------------------------------------------------------------------------------
lgpg_regions 0 0 0 0 8E-1 D
lgpg_size
--------------------------------------------------------------------------------
lgpg_size 0 0 0 0 16M bytes D
lgpg_regions
ps -efZ | grep ora
# ps -efZ | grep ora
oracle 5439502 1 0 20:04:26 - 0:00 4K 4K 4K 4K ora_diag_NEWBOSDB
oracle 5570570 1 0 20:04:26 - 0:00 4K 4K 4K 4K ora_vktm_NEWBOSDB
oracle 5636348 7667750 0 20:04:39 - 0:00 4K 4K 4K 4K oracleNEWBOSDB (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle 5832958 1 0 20:04:26 - 0:00 4K 4K 4K 4K ora_pmon_NEWBOSDB
oracle 7012394 1 0 20:04:26 - 0:00 4K 4K 4K 4K ora_gen0_NEWBOSDB
oracle 7274524 8650812 0 20:03:50 pts/3 0:00 4K 4K 4K 4K -ksh
oracle 7340202 1 0 20:04:26 - 0:00 4K 4K 4K 4K ora_dbrm_NEWBOSDB
oracle 7667750 7274524 0 20:04:04 pts/3 0:00 4K 4K 4K 4K sqlplus
oracle 7864540 1 0 20:04:26 - 0:01 4K 4K 4K 4K ora_mman_NEWBOSDB
oracle 8192140 1 0 20:04:26 - 0:00 4K 4K 4K 4K ora_dia0_NEWBOSDB
oracle 8257682 1 0 20:04:26 - 0:00 4K 4K 4K 4K ora_dbw0_NEWBOSDB
oracle 8388738 1 0 20:04:26 - 0:00 4K 4K 4K 4K ora_dbw1_NEWBOSDB
oracle 8454270 1 0 20:04:27 - 0:00 4K 4K 4K 4K ora_ckpt_NEWBOSDB
oracle 8519798 1 0 20:04:26 - 0:00 4K 4K 4K 4K ora_dbw2_NEWBOSDB
oracle 8716304 1 0 20:04:27 - 0:00 4K 4K 4K 4K ora_lgwr_NEWBOSDB
oracle 8847572 1 0 20:04:26 - 0:00 4K 4K 4K 4K ora_psp0_NEWBOSDB
oracle 8913046 1 0 20:04:27 - 0:00 4K 4K 4K 4K ora_dbw3_NEWBOSDB
oracle 8978452 1 0 20:04:27 - 0:00 4K 4K 4K 4K ora_smon_NEWBOSDB
oracle 9043990 1 0 20:04:27 - 0:00 4K 4K 4K 4K ora_reco_NEWBOSDB
oracle 9109526 1 0 20:04:27 - 0:00 4K 4K 4K 4K ora_mmon_NEWBOSDB
oracle 9175064 1 0 20:04:27 - 0:00 4K 4K 4K 4K ora_mmnl_NEWBOSDB
oracle 9240602 1 0 20:04:27 - 0:00 4K 4K 4K 4K ora_d000_NEWBOSDB
oracle 9306140 1 0 20:04:27 - 0:00 4K 4K 4K 4K ora_s000_NEWBOSDB
root 9764920 6815998 0 20:07:26 pts/2 0:00 4K 4K 4K 4K grep ora
4、确定大页内存的个数:
num_of_large_pages = INT((total_SGA_size-1)/16MB)+1
QL> show parameter sga
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
lock_sga boolean TRUE
pre_page_sga boolean FALSE
sga_max_size big integer 15840M
sga_target big integer 0
经过计算:num_of_large_pages=991
SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
5、设置大页内存:
#vmo -p -o lgpg_regions=num_of_large_pages -o lgpg_size=16777216
# vmo -p -o lgpg_regions=991 -o lgpg_size=16777216
Setting lgpg_size to 16777216 in nextboot file
Setting lgpg_regions to 991 in nextboot file
Warning: although the change concerns a dynamic tunable, bosboot should be run to optimally restore these settings at reboot
Setting lgpg_size to 16777216
Setting lgpg_regions to 991
设置完大页内存后需要修改参数 lru_file_repage
Change lru_file_repage, the default is 1:
#vmo -o lru_file_repage=0
Note: If a reboot is required on the system, because of changing the large page configuration, this will be
indicated in the output of the vmo command.
查看lru_file_repage 参数当前值
# vmo -L minperm% -L maxperm% -L maxclient% -L lru_file_repage
NAME CUR DEF BOOT MIN MAX UNIT TYPE DEPENDENCIES
--------------------------------------------------------------------------------
lru_file_repage 0 0 0 0 1 boolean D
--------------------------------------------------------------------------------
maxclient% 90 90 90 1 100 % memory D
maxperm%
minperm%
--------------------------------------------------------------------------------
maxperm% 90 90 90 1 100 % memory D
minperm%
maxclient%
--------------------------------------------------------------------------------
minperm% 3 3 3 1 100 % memory D
--------------------------------------------------------------------------------
运行下面的命令可以去除16M的页面设置:
#vmo -po lgpg_size=0 -o lgpg_regions=0
# svmo
size inuse free pin virtual mmode
memory 8060928 4928017 3132911 4530471 779488 Ded
pg space 6291456 3106
work pers clnt other
pin 234391 0 0 236944
in use 779488 0 89393
PageSize PoolSize inuse pgsp pin virtual
s 4 KB - 469265 3106 311079 379872
m 64 KB - 24976 0 10016 24976
L 16 MB 991 0 0 991 0
6、查看oracle sga是否使用了large page
su - oracle
startup
ps vg|grep ora_smon*
svmon -p PID
# ps vg|grep ora_sm*
10485826 - A 0:00 0 9704 67700 xx 162240 57996 0.0 0.0 ora_s0
21561512 - A 0:00 0 9652 67648 xx 162240 57996 0.0 0.0 ora_sm
# svmon -P 21561512
Pid Command Inuse Pin Pgsp Virtual 64-bit Mthrd 16MB
21561512 oracle 4090872 4067296 0 4076334 Y N Y
PageSize Inuse Pin Pgsp Virtual
s 4 KB 19720 0 0 5182
m 64 KB 751 510 0 751
L 16 MB 991 991 0 991
Vsid Esid Type Description PSize Inuse Pin Pgsp Virtual
9b115b 7000001b work default shmat/mmap L 16 16 0 16
8e0fce 70000017 work default shmat/mmap L 16 16 0 16
b50cb5 7000002f work default shmat/mmap L 16 16 0 16
b60cf6 70000029 work default shmat/mmap L 16 16 0 16
b50cf5 70000013 work default shmat/mmap L 16 16 0 16
bd0e3d 7000000b work default shmat/mmap L 16 16 0 16
991159 70000037 work default shmat/mmap L 16 16 0 16
ba0e3a 7000002d work default shmat/mmap L 16 16 0 16
b80e38 7000003a work default shmat/mmap L 16 16 0 16
b20d72 70000023 work default shmat/mmap L 16 16 0 16
b70eb7 7000002e work default shmat/mmap L 16 16 0 16
b00e70 7000003b work default shmat/mmap L 16 16 0 16
961156 7000001f work default shmat/mmap L 16 16 0 16
b40fb4 70000034 work default shmat/mmap L 16 16 0 16
aa0f2a 70000033 work default shmat/mmap L 16 16 0 16
ba117a 7000001a work default shmat/mmap L 16 16 0 16
951155 70000010 work default shmat/mmap L 16 16 0 16
850f85 7000001c work default shmat/mmap L 16 16 0 16
b71177 7000000e work default shmat/mmap L 16 16 0 16
a60f26 70000028 work default shmat/mmap L 16 16 0 16
b51135 70000031 work default shmat/mmap L 16 16 0 16
a40ee4 70000030 work default shmat/mmap L 16 16 0 16
a90fa9 70000024 work default shmat/mmap L 16 16 0 16
921152 70000039 work default shmat/mmap L 16 16 0 16
a10ea1 70000015 work default shmat/mmap L 16 16 0 16
911151 70000009 work default shmat/mmap L 16 16 0 16
b41174 70000014 work default shmat/mmap L 16 16 0 16
8b114b 7000000a work default shmat/mmap L 16 16 0 16
a60fa6 70000035 work default shmat/mmap L 16 16 0 16
a40f64 7000003c work default shmat/mmap L 16 16 0 16
ad10ad 7000001d work default shmat/mmap L 16 16 0 16
901150 70000003 work default shmat/mmap L 16 16 0 16
a50fe5 70000025 work default shmat/mmap L 16 16 0 16
b01170 70000016 work default shmat/mmap L 16 16 0 16
900d10 70000012 work default shmat/mmap L 16 16 0 16
8e114e 70000011 work default shmat/mmap L 16 16 0 16
970e57 7000002a work default shmat/mmap L 16 16 0 16
810fc1 7000002c work default shmat/mmap L 16 16 0 16
ad116d 70000002 work default shmat/mmap L 16 16 0 16
841144 7000002b work default shmat/mmap L 16 16 0 16
ac116c 7000000d work default shmat/mmap L 16 16 0 16
851145 70000006 work default shmat/mmap L 16 16 0 16
9d0f9d 70000021 work default shmat/mmap L 16 16 0 16
aa116a 70000000 work default shmat/mmap L 16 16 0 16
8d0d8d 70000018 work default shmat/mmap L 16 16 0 16
a91169 70000019 work default shmat/mmap L 16 16 0 16
990f99 70000022 work default shmat/mmap L 16 16 0 16
a61166 70000007 work default shmat/mmap L 16 16 0 16
a51165 70000004 work default shmat/mmap L 16 16 0 16
a31163 70000005 work default shmat/mmap L 16 16 0 16
881148 70000008 work default shmat/mmap L 16 16 0 16
a21162 7000000c work default shmat/mmap L 16 16 0 16
8a114a 7000000f work default shmat/mmap L 16 16 0 16
a11161 70000001 work default shmat/mmap L 16 16 0 16
8e0ece 70000020 work default shmat/mmap L 16 16 0 16
950fd5 70000036 work default shmat/mmap L 16 16 0 16
9f115f 7000001e work default shmat/mmap L 16 16 0 16
8e0f0e 70000027 work default shmat/mmap L 16 16 0 16
910f91 70000026 work default shmat/mmap L 16 16 0 16
9e115e 70000038 work default shmat/mmap L 16 16 0 16
920fd2 70000032 work default shmat/mmap L 16 16 0 16
810d01 7000003d work default shmat/mmap L 15 15 0 15
930893 10 clnt text data BSS heap, s 14499 0 - -
/dev/data_lv:43952
20002 0 work kernel segment m 556 507 0 556
970017 90000000 work shared library text m 190 0 0 190
50005 9ffffffd work shared library sm 2443 0 0 2443
b410f4 80020014 work USLA heap sm 1576 0 0 1576
b010f0 11 work text data BSS heap sm 631 0 0 631
990019 90020014 work shared library s 391 0 0 391
be10fe 9001000a work shared library data sm 101 0 0 101
aa10ea f00000002 work process private m 5 3 0 5
810cc1 - clnt /dev/data_lv:34674 s 17 0 - -
8a00ca 9fffffff clnt USLA text,/dev/hd2:4241 s 15 0 - -
e000e 9ffffffe work shared library sm 15 0 0 15
811101 8fffffff work private load data s 11 0 0 11
ad10ed ffffffff work application stack sm 11 0 0 11
8f110f - clnt /dev/data_lv:52152 s 4 0 - -
b110f1 8001000a work private load data sm 3 0 0 3
8e0d8e - clnt /dev/data_lv:52153 s 1 0 - -
a10e21 - clnt /dev/data_lv:44016 s 1 0 - -
951015 - clnt /dev/data_lv:52151 s 1 0 - -
b210f2 7000003e mmap maps 1 source(s) sm 0 0 - -
a91129 - clnt /dev/data_lv:44025 s 0 0 - -
vmstat -l
# vmstat -l 1 10
System configuration: lcpu=32 mem=31488MB
kthr memory page faults cpu large-page
----- ----------- ------------------------ ------------ ----------- -----------
r b avm fre re pi po fr sr cy in sy cs us sy id wa alp flp
0 0 4896761 3074708 0 0 0 0 0 0 5 430 483 0 0 99 0 991 0
0 0 4896761 3074708 0 0 0 0 0 0 3 132 464 0 0 99 0 991 0
0 0 4896761 3074708 0 0 0 0 0 0 6 160 482 0 0 99 0 991 0
0 0 4896761 3074708 0 0 0 0 0 0 4 218 482 0 0 99 0 991 0
0 0 4896761 3074708 0 0 0 0 0 0 4 2105 517 0 0 99 0 991 0
0 0 4896761 3074708 0 0 0 0 0 0 5 146 477 0 0 99 0 991 0
0 0 4896761 3074708 0 0 0 0 0 0 5 222 551 0 0 99 0 991 0
0 0 4896761 3074708 0 0 0 0 0 0 4 139 462 0 0 99 0 991 0
0 0 4896761 3074708 0 0 0 0 0 0 6 157 479 0 0 99 0 991 0
0 0 4896761 3074708 0 0 0 0 0 0 5 214 473 0 0 99 0 991 0
ps -efZ | grep ora
参考
http://www.eygle.com/digest/2009/04/minperm_maxperm_lru_file.html
http://luoping.blog.51cto.com/534596/1168873
http://wenku.baidu.com/link?url=ERFy1cZev2QhXHihKTGwcz9t0im-U6bncWoXz4gbhu-SvfdAY8dsEJAfKxiIogQkHbZQ1eNCFPqUTHk2vwEyL1qGrJCoVvN3jem5_Rld96y