linux huge模式设置,Linux 下 Hugepages的配置

2.实践配置

A. Oracle10g配置

平台:

hw:x86_64

os:RHEL5.4

kernel: 2.6.18-164.el5

db:oracle10.2

1). 用root用户配置文件“/etc/security/limits.conf”,添加memlock,他的大小略小于总内存,例如:64GB,配置如下:

[root@skatedb ~]# vi /etc/security/limits.conf

##skate add

*   soft   memlock    60397977

*   hard   memlock    60397977

##skate add

2).用oracle重新登录,检查memlock的设置是否生效[oracle@skatedb ~]$ ulimit -l

60397977

3).确定所有的oracle数据库实例都启动,包括asm实例,然后用如下脚本计算参数“vm.nr_hugepages"的大小

------------------hugepages_settings.sh----------------------------

#!/bin/bash

#

# hugepages_settings.sh

#

# Linux bash script to compute values for the

# recommended HugePages/HugeTLB configuration

#

# Note: This script does calculation for all shared memory

# segments available when the script is run, no matter it

# is an Oracle RDBMS shared memory segment or not.

#

# This script is provided by Doc ID 401749.1 from My Oracle Support

# http://support.oracle.com

# Welcome text

echo "

This script is provided by Doc ID 401749.1 from My Oracle Support

(http://support.oracle.com) where it is intended to compute values for

the recommended HugePages/HugeTLB configuration for the current shared

memory segments. Before proceeding with the execution please make sure

that:

* Oracle Database instance(s) are up and running

* Oracle Database 11g Automatic Memory Management (AMM) is not setup

(See Doc ID 749851.1)

* The shared memory segments can be listed by command:

# ipcs -m

Press Enter to proceed..."

read

# Check for the kernel version

KERN=`uname -r | awk -F. '{ printf("%d.%d\n",$1,$2); }'`

# Find out the HugePage size

HPG_SZ=`grep Hugepagesize /proc/meminfo | awk '{print $2}'`

# Initialize the counter

NUM_PG=0

# Cumulative number of pages required to handle the running shared memory segments

for SEG_BYTES in `ipcs -m | awk '{print $5}' | grep "[0-9][0-9]*"`

do

MIN_PG=`echo "$SEG_BYTES/($HPG_SZ*1024)" | bc -q`

if [ $MIN_PG -gt 0 ]; then

NUM_PG=`echo "$NUM_PG+$MIN_PG+1" | bc -q`

fi

done

RES_BYTES=`echo "$NUM_PG * $HPG_SZ * 1024" | bc -q`

# An SGA less than 100MB does not make sense

# Bail out if that is the case

if [ $RES_BYTES -lt 100000000 ]; then

echo "***********"

echo "** ERROR **"

echo "***********"

echo "Sorry! There are not enough total of shared memory segments allocated for

HugePages configuration. HugePages can only be used for shared memory segments

that you can list by command:

# ipcs -m

of a size that can match an Oracle Database SGA. Please make sure that:

* Oracle Database instance is up and running

* Oracle Database 11g Automatic Memory Management (AMM) is not configured"

exit 1

fi

# Finish with results

case $KERN in

'2.4') HUGETLB_POOL=`echo "$NUM_PG*$HPG_SZ/1024" | bc -q`;

echo "Recommended setting: vm.hugetlb_pool = $HUGETLB_POOL" ;;

'2.6') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;

*) echo "Unrecognized kernel version $KERN. Exiting." ;;

esac

# End

-----------------------hugepages_settings.sh-----------------------

也可以手工计算nr_hugepages>=SGA_Target/Hugepagesize

然后把nr_hugepages追加写入文件“/etc/sysctl.conf”,假如这里计算的nr_hugepages=15000

[root@skatedb ~]# vi /etc/sysctl.conf

##skate add

vm.nr_hugepages=15000

##skate add

使其修改生效

[root@skatedb ~]# sysctl -p

4).停止oracle数据库,reboot服务器

5).检查hugepage是否生效

[root@skatedb ~]# grep HugePages /proc/meminfo

HugePages_Total: 15000

HugePages_Free:   4779

HugePages_Rsvd:   4676

如果HugePages_Total=HugePages_Free,说明HugePages配置没起作用。

B. oracle11g配置

平台:

hw:x86_64

os:RHEL5 (Taroon)

kernel: 2.6.18-194.el5

db:oracle 11.2.0.2.0

oracle11g的新特性是通过启用参数MEMORY_TARGET/MEMORY_MAX_TARGET,启用AMM的oracle11g的所有SGA内存的分配方式都是通过在/dev/shm下创建文件,而已这种方式分配的sga是不启用hugepage的,AMM和hugepage是不兼容的,因为/dev/shm是tmpfs文件系统,而tmpfs文件系统是不支持AMM动态调整sga大小的,所以要想使用hugepage的特性就要关闭AMM特性。两个如何取舍就看你了。

停止oracle11g的AMM直接把MEMORY_MAX_TARGET和MEMORY_TARGET设置为‘0’,就抱如下的错误

ORA-00843: Parameter not taking MEMORY_MAX_TARGET into account

ORA-00849: SGA_TARGET 35433480192 cannot be set to more than MEMORY_MAX_TARGET 0.

ORA-01078: failure in processing system parameters

如果只设置MEMORY_TARGET=0,hugepage是不起作用的。所以采用不设置这两个参数,就可以关闭oracle11g的AMM了。创建pfile.ora文件,然后在文件里删除两个参数"MEMORY_TARGET/MEMORY_MAX_TARGET"。就是因为这个关闭AMM的地方测试了半天,才通过。

停止了oracle11g的AMM后,在按着oracle10g的配置方法就可以启动hugepage了。0b1331709591d260c1c78e86d0c51c18.png

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值