oracle hugepage设置
2014-09-10 17:47
253 查看
HugePages是通过使用大页内存来取代传统的4kb内存页面,使得管理虚拟地址数变少,加快了从虚拟地址到物理地址的映射以及通过摒弃内存页面的换入换出以提高内存的整体性能。尤其是对于8GB以上的内存以及较大的Oracle SGA size,建议配值并使用HugePage特性。本文基于x86_64 Linux下来描述如何配值 HugePages。
有关HugePages的特性请参考:Linux HugePage 特性
1、为什么需要配值HugePages ?
2、配值HugePages
下面列出了配值HugePages的所有步骤
a、查看当前系统是否配值HugePages
下面的查询中HugePages相关的几个值都为0,表明当前未配值HugePages,其次可以看到Hugepagesize为2MB。
$ grep Huge /proc/meminfo
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
Hugepagesize: 2048 kB
b、修改用户的memlock限制
通过修改/etc/security/limits.conf 配值文件来实现
该参数的值通常配值位略小于当前的已安装系统内存,如当前你的系统内存为64GB,可以做如下设置
* soft memlock 60397977
* hard memlock 60397977
* soft memlock 5397977
* hard memlock 5397977
上述的设置单位为kb,不会降低系统性能。至少也要配值为略大于系统上所有SGA的总和。
使用ulimit -l 来校验该设置
c、禁用AMM(Oracle 11g)
如果当前的Oracle 版本为10g,可以跳过此步骤。
如果当前的Oracle 版本为11g,由于AMM(Automatic Memory Management)特性与Hugepages不兼容,需要禁用AMM。
ALTER SYSTEM RESET memory_target SCOPE=SPFILE;
ALTER SYSTEM RESET memory_max_target SCOPE=SPFILE;
ALTER SYSTEM SET sga_target=<n>g SCOPE=SPFILE;
ALTER SYSTEM SET pga_aggregate_target=<n>g SCOPE=SPFILE;
SHUTDOWN IMMEDIATE;
STARTUP;
SQL> show parameter sga
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
lock_sga boolean FALSE
pre_page_sga boolean FALSE
sga_max_size big integer 2000M
sga_target big integer 2000M
SQL>
SQL>
SQL> show parameter mem
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
hi_shared_memory_address integer 0
memory_max_target big integer 0
memory_target big integer 0
shared_memory_address integer 0
SQL>
d、计算vm.nr_hugepages 的值
使用Oracle 提供的脚本hugepages_settings.sh的脚本来计算vm.nr_hugepages的值
在执行脚本之前确保所有的Oracle 实例已启动以及ASM也启动(存在的情形下)
$ ./hugepages_settings.sh
...
Recommended setting: vm.nr_hugepages = 1496
e、 编辑/etc/sysctl.conf 来设置vm.nr_hugepages参数
$ sysctl -w vm.nr_hugepages = 1496
$ sysctl -p
-- Author : Robinson
-- Blog : http://blog.csdn.net/robinson_0612
f、停止所有的Instance并重启server
上述的所有步骤已经实现了动态修改,但对于HugePages的分配需要重新启动server才能生效。
h、验证配值
HugePages相关参数的值会随着当前服务器上的实例的停止与启动而动态发生变化
通常情况下,HugePages_Free的值应当小于HugePages_Total的值,在HugePages被使用时HugePages_Rsvd值应当为非零值。
$ grep Huge /proc/meminfo
HugePages_Total: 131
HugePages_Free: 20
HugePages_Rsvd: 20
Hugepagesize: 2048 kB
如下面的情形,当服务器上仅有的一个实例被关闭后,HugePages_Rsvd的值为零。且HugePages_Free等于HugePages_Total
$ grep Huge /proc/meminfo
HugePages_Total: 131
HugePages_Free: 131
HugePages_Rsvd: 0
Hugepagesize: 2048 kB
3、使用HugePages的注意事项
下面的三种情形应当重新配置HugePages
a、物理内存的增减或减少
b、在当前服务器上新增或移出Instance
c、Instance的SGA大小增加或减少
如果未能调整HugePages,可能会引发下面的问题
a、数据库性能地下
b、出现内存不足或者过度使用交换空间
c、数据库实例不能被启动
d、关键性系统服务故障
4、HugePages特性的常见故障处理
设置了大页,但没被Oracle使用,原因只有两个:
1,SGA_MAX_SIZE超过了大页
2,没有设置内存锁
内存:是进程活动的舞台,ORACLE数据库在startup时会自动去查找是否设置有大页。
如有,在大页中分配SGA。
如没有,则正常使用默认数据块大小启动。
5、计算vm.nr_hugepages 值的脚本
[python] view plaincopyprint?
#!/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 note following:
* For ASM instance, it needs to configure ASMM instead of AMM.
* The 'pga_aggregate_target' is outside the SGA and
you should accommodate this while calculating SGA size.
* In case you changes the DB SGA size,
as the new SGA will not fit in the previous HugePages configuration,
it had better disable the whole HugePages,
start the DB with new SGA size and run the script again.
And 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}'`
if [ -z "$HPG_SZ" ];then
echo "The hugepages may not be supported in the system where the script is being executed."
exit 1
fi
# Initialize the counter
NUM_PG=0
# Cumulative number of pages required to handle the running shared memory segments
for SEG_BYTES in `ipcs -m | cut -c44-300 | awk '{print $1}' | grep "[0-9][0-9]*"`
4000
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的特性请参考:Linux HugePage 特性
1、为什么需要配值HugePages ?
2、配值HugePages
下面列出了配值HugePages的所有步骤
a、查看当前系统是否配值HugePages
下面的查询中HugePages相关的几个值都为0,表明当前未配值HugePages,其次可以看到Hugepagesize为2MB。
$ grep Huge /proc/meminfo
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
Hugepagesize: 2048 kB
b、修改用户的memlock限制
通过修改/etc/security/limits.conf 配值文件来实现
该参数的值通常配值位略小于当前的已安装系统内存,如当前你的系统内存为64GB,可以做如下设置
* soft memlock 60397977
* hard memlock 60397977
* soft memlock 5397977
* hard memlock 5397977
上述的设置单位为kb,不会降低系统性能。至少也要配值为略大于系统上所有SGA的总和。
使用ulimit -l 来校验该设置
c、禁用AMM(Oracle 11g)
如果当前的Oracle 版本为10g,可以跳过此步骤。
如果当前的Oracle 版本为11g,由于AMM(Automatic Memory Management)特性与Hugepages不兼容,需要禁用AMM。
ALTER SYSTEM RESET memory_target SCOPE=SPFILE;
ALTER SYSTEM RESET memory_max_target SCOPE=SPFILE;
ALTER SYSTEM SET sga_target=<n>g SCOPE=SPFILE;
ALTER SYSTEM SET pga_aggregate_target=<n>g SCOPE=SPFILE;
SHUTDOWN IMMEDIATE;
STARTUP;
SQL> show parameter sga
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
lock_sga boolean FALSE
pre_page_sga boolean FALSE
sga_max_size big integer 2000M
sga_target big integer 2000M
SQL>
SQL>
SQL> show parameter mem
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
hi_shared_memory_address integer 0
memory_max_target big integer 0
memory_target big integer 0
shared_memory_address integer 0
SQL>
d、计算vm.nr_hugepages 的值
使用Oracle 提供的脚本hugepages_settings.sh的脚本来计算vm.nr_hugepages的值
在执行脚本之前确保所有的Oracle 实例已启动以及ASM也启动(存在的情形下)
$ ./hugepages_settings.sh
...
Recommended setting: vm.nr_hugepages = 1496
e、 编辑/etc/sysctl.conf 来设置vm.nr_hugepages参数
$ sysctl -w vm.nr_hugepages = 1496
$ sysctl -p
-- Author : Robinson
-- Blog : http://blog.csdn.net/robinson_0612
f、停止所有的Instance并重启server
上述的所有步骤已经实现了动态修改,但对于HugePages的分配需要重新启动server才能生效。
h、验证配值
HugePages相关参数的值会随着当前服务器上的实例的停止与启动而动态发生变化
通常情况下,HugePages_Free的值应当小于HugePages_Total的值,在HugePages被使用时HugePages_Rsvd值应当为非零值。
$ grep Huge /proc/meminfo
HugePages_Total: 131
HugePages_Free: 20
HugePages_Rsvd: 20
Hugepagesize: 2048 kB
如下面的情形,当服务器上仅有的一个实例被关闭后,HugePages_Rsvd的值为零。且HugePages_Free等于HugePages_Total
$ grep Huge /proc/meminfo
HugePages_Total: 131
HugePages_Free: 131
HugePages_Rsvd: 0
Hugepagesize: 2048 kB
3、使用HugePages的注意事项
下面的三种情形应当重新配置HugePages
a、物理内存的增减或减少
b、在当前服务器上新增或移出Instance
c、Instance的SGA大小增加或减少
如果未能调整HugePages,可能会引发下面的问题
a、数据库性能地下
b、出现内存不足或者过度使用交换空间
c、数据库实例不能被启动
d、关键性系统服务故障
4、HugePages特性的常见故障处理
设置了大页,但没被Oracle使用,原因只有两个:
1,SGA_MAX_SIZE超过了大页
2,没有设置内存锁
内存:是进程活动的舞台,ORACLE数据库在startup时会自动去查找是否设置有大页。
如有,在大页中分配SGA。
如没有,则正常使用默认数据块大小启动。
5、计算vm.nr_hugepages 值的脚本
[python] view plaincopyprint?
#!/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 note following:
* For ASM instance, it needs to configure ASMM instead of AMM.
* The 'pga_aggregate_target' is outside the SGA and
you should accommodate this while calculating SGA size.
* In case you changes the DB SGA size,
as the new SGA will not fit in the previous HugePages configuration,
it had better disable the whole HugePages,
start the DB with new SGA size and run the script again.
And 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}'`
if [ -z "$HPG_SZ" ];then
echo "The hugepages may not be supported in the system where the script is being executed."
exit 1
fi
# Initialize the counter
NUM_PG=0
# Cumulative number of pages required to handle the running shared memory segments
for SEG_BYTES in `ipcs -m | cut -c44-300 | awk '{print $1}' | grep "[0-9][0-9]*"`
4000
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是通过使用大页内存来取代传统的4kb内存页面,使得管理虚拟地址数变少,加快了从虚拟地址到物理地址的映射以及通过摒弃内存页面的换入换出以提高内存的整体性能。尤其是对于8GB以上的内存以及较大的Oracle SGA size,建议配值并使用HugePage特性。本文基于x86_64 Linux下来描述如何配值 HugePages。 有关HugePages的特性请参考:Linux HugePage 特性 1、为什么需要配值HugePages ? 2、配值HugePages 下面列出了配值HugePages的所有步骤 a、查看当前系统是否配值HugePages 下面的查询中HugePages相关的几个值都为0,表明当前未配值HugePages,其次可以看到Hugepagesize为2MB。 $ grep Huge /proc/meminfo HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 Hugepagesize: 2048 kB b、修改用户的memlock限制 通过修改/etc/security/limits.conf 配值文件来实现 该参数的值通常配值位略小于当前的已安装系统内存,如当前你的系统内存为64GB,可以做如下设置 * soft memlock 60397977 * hard memlock 60397977 * soft memlock 5397977 * hard memlock 5397977 上述的设置单位为kb,不会降低系统性能。至少也要配值为略大于系统上所有SGA的总和。 使用ulimit -l 来校验该设置 c、禁用AMM(Oracle 11g) 如果当前的Oracle 版本为10g,可以跳过此步骤。 如果当前的Oracle 版本为11g,由于AMM(Automatic Memory Management)特性与Hugepages不兼容,需要禁用AMM。 ALTER SYSTEM RESET memory_target SCOPE=SPFILE; ALTER SYSTEM RESET memory_max_target SCOPE=SPFILE; ALTER SYSTEM SET sga_target=<n>g SCOPE=SPFILE; ALTER SYSTEM SET pga_aggregate_target=<n>g SCOPE=SPFILE; SHUTDOWN IMMEDIATE; STARTUP; SQL> show parameter sga NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ lock_sga boolean FALSE pre_page_sga boolean FALSE sga_max_size big integer 2000M sga_target big integer 2000M SQL> SQL> SQL> show parameter mem NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ hi_shared_memory_address integer 0 memory_max_target big integer 0 memory_target big integer 0 shared_memory_address integer 0 SQL> d、计算vm.nr_hugepages 的值 使用Oracle 提供的脚本hugepages_settings.sh的脚本来计算vm.nr_hugepages的值 在执行脚本之前确保所有的Oracle 实例已启动以及ASM也启动(存在的情形下) $ ./hugepages_settings.sh ... Recommended setting: vm.nr_hugepages = 1496 e、 编辑/etc/sysctl.conf 来设置vm.nr_hugepages参数 $ sysctl -w vm.nr_hugepages = 1496 $ sysctl -p -- Author : Robinson -- Blog : http://blog.csdn.net/robinson_0612 f、停止所有的Instance并重启server 上述的所有步骤已经实现了动态修改,但对于HugePages的分配需要重新启动server才能生效。 h、验证配值 HugePages相关参数的值会随着当前服务器上的实例的停止与启动而动态发生变化 通常情况下,HugePages_Free的值应当小于HugePages_Total的值,在HugePages被使用时HugePages_Rsvd值应当为非零值。 $ grep Huge /proc/meminfo HugePages_Total: 131 HugePages_Free: 20 HugePages_Rsvd: 20 Hugepagesize: 2048 kB 如下面的情形,当服务器上仅有的一个实例被关闭后,HugePages_Rsvd的值为零。且HugePages_Free等于HugePages_Total $ grep Huge /proc/meminfo HugePages_Total: 131 HugePages_Free: 131 HugePages_Rsvd: 0 Hugepagesize: 2048 kB 3、使用HugePages的注意事项 下面的三种情形应当重新配置HugePages a、物理内存的增减或减少 b、在当前服务器上新增或移出Instance c、Instance的SGA大小增加或减少 如果未能调整HugePages,可能会引发下面的问题 a、数据库性能地下 b、出现内存不足或者过度使用交换空间 c、数据库实例不能被启动 d、关键性系统服务故障 4、HugePages特性的常见故障处理 设置了大页,但没被Oracle使用,原因只有两个: 1,SGA_MAX_SIZE超过了大页 2,没有设置内存锁 内存:是进程活动的舞台,ORACLE数据库在startup时会自动去查找是否设置有大页。 如有,在大页中分配SGA。 如没有,则正常使用默认数据块大小启动。 5、计算vm.nr_hugepages 值的脚本 [python] view plaincopyprint? #!/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 note following: * For ASM instance, it needs to configure ASMM instead of AMM. * The 'pga_aggregate_target' is outside the SGA and you should accommodate this while calculating SGA size. * In case you changes the DB SGA size, as the new SGA will not fit in the previous HugePages configuration, it had better disable the whole HugePages, start the DB with new SGA size and run the script again. And 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}'` if [ -z "$HPG_SZ" ];then echo "The hugepages may not be supported in the system where the script is being executed." exit 1 fi # Initialize the counter NUM_PG=0 # Cumulative number of pages required to handle the running shared memory segments for SEG_BYTES in `ipcs -m | cut -c44-300 | awk '{print $1}' | 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
相关文章推荐
- linux的hugepage的配置-优化oracle内存 .
- HugePages on Oracle Linux 64-bit (文档 ID 361468.1) 如何设置HugePages ?
- centos6.8 hugepage设置
- linux的hugepage的配置-优化oracle内存
- Oracle DB内存分配: 使用HugePage、tmpfs
- linux oracle 调优之hugepage+sga lock
- linux huge page 设置
- 在linux下为oracle开启大页(hugepage)
- oracle 大内存需要配置hugepage
- linux hugepage + oracle 11.2.0.4
- Oracle Memory Management and HugePage (连载一)
- oracle 11g 11.2.0.1 设置HuagePage导致TRC 变大 变多
- LINUX下为ORACLE数据库设置大页--hugepage
- Linux Hugepage ,AMM及 USE_LARGE_PAGES for oracle 11G(转载)
- hugepage设置
- oracle ORA-32701 hang分析(二)---hugepage优化
- CentOS7中如何让Linux在启动时就将CPU分离并将hugepage设置为初始1GB
- 在Linux 中为oracle配置hugepage的方法
- (WIP)SSD上的I/O电梯算法与HugePage设置可能导致的Crash(by quqi99)
- 在Linux 5中为oracle配置hugepage的方法