linux7.4开启hugepages

环境检查

数据库内存超过4G时,使用dbca建库默认选项AMM是关闭的,内存超过8G时,oracle推荐使用hugepages,它可以将部分数据锁定在内存中,处理效率比较高、性能好。

确认服务器物理内存已经超过8G,是大内存

确认数据库实例没有使用AMM,hugepages与AMM不同时使用

Memlock

如果/etc/security/limits.d/*.conf中没有关于memlock参数的设置,那么

memlock的值介于SGA与物理内存之间,比SGA大,比物理内存小

推荐值SGA+PGA为物理内存80%,memlock为物理内存90%

Memlock = 物理内存*90%*1024*1024

vim /etc/security/limits.conf

oracle soft memlock 237363200

oracle hard memlock 237363200

# su - oracle

$ ulimit -l

237363200

脚本获取推荐值

chmod +x hugepages_settings.sh

[[email protected] scripts]# ./hugepages_settings.sh

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 on Oracle Linux. 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...

Recommended setting: vm.nr_hugepages = 72708

[[email protected] scripts]# ipcs -m

------ Shared Memory Segments --------

key        shmid      owner      perms      bytes      nattch     status

0x00000000 1245184    grid       600        4096       0

0x00000000 1277953    grid       600        4096       0

0x4dfc72ac 1310722    grid       600        24576      48

0x00000000 1343491    grid       600        8802304    124

0x00000000 1376260    grid       600        1056964608 62

0x00000000 1409029    grid       600        7974912    62

0xef940690 1441798    grid       600        20480      62

0x00000000 2129927    oracle     600        30035968   614

0x00000000 2162696    oracle     600        150860726272 307

0x00000000 2195465    oracle     600        506834944  307

0x51c60604 2228234    oracle     600        24576      307

设置hugepages

# vim /etc/sysctl.conf

vm.nr_hugepages = 72708

# sysctl -p

# grep HugePages /proc/meminfo

AnonHugePages:   1093632 kB

HugePages_Total:   61313

HugePages_Free:    61313

HugePages_Rsvd:        0

HugePages_Surp:        0

附件

hugepages_settings.sh


#!/bin/bash

#

# hugepages_settings.sh

#

# Linux bash script to compute values for the

# recommended HugePages/HugeTLB configuration

# on Oracle Linux

#

# 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 on Oracle Linux. 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); }‘`

...skipping...

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.2‘) echo "Kernel version $KERN is not supported. Exiting." ;;

‘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" ;;

‘3.8‘) echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;

‘3.10‘) echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;

‘4.1‘) echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;

esac

# End

参考

  1. HugePages on Oracle Linux 64-bit (文档 ID 361468.1)
  2. Oracle Linux: Shell Script to Calculate Values Recommended Linux HugePages / HugeTLB Configuration (文档 ID 401749.1)

原文地址:https://www.cnblogs.com/automng/p/8890430.html

时间: 2024-07-30 15:21:07

linux7.4开启hugepages的相关文章

未开启HugePages ORACLE session剧增时引起的一次悲剧

故障简单描述一下:LINUX系统未开启HugePages,主机内存将近300G,SWAP是32G.ORACLE 的 SGA_MAX_SIZE设置是主机内存的将近80%,SGA_TARGET设置是主机内在的将近60%,正常情况下数据库session大约在将近500.故障当天业务有变化,session数增加了一倍,达到上1000个,内存紧张,用到了SWAP空间. 解决:找时间关数据库,重新配置HugePages,重启数据库后观察,内存消耗较少,与未开启HugePages之前是数量级对比.Hugepa

x86开启 HUGEPAGES

HugePage,就是指的大页内存管理方式,在操作系统Linux环境中,内存是以页Page的方式进行分配,默认大小为4K,HugePage是传统4K Page的替代方案.顾名思义,是用HugePage可以让我们有更大的内存分页大小,HugePage为管理大内存(8GB以上)更为高效.PageTable具有了额外的属性,就是判断该页记录是HugePage还是Regular Page 内核hugepages支持make menuconfigProcessor type and features  -

THP Transparent HugePages 相关知识与关闭【转】

最近遇到个LINUX系统内存比较大,未开 HugePages,业务有变化导致ORACLE连接数剧增至上千个,PageTables达到上百G,导致内存不足系统HANG住的案例. 因此需要开启 HugePages,操作系统是OEL6以上的.LINUX的以下版本:Red Hat Enterprise Linux 6, SUSE Linux Enterprise Server 11, and Oracle Linux 6 with earlier releases of Oracle Linux Unb

PHP 7安装使用体验,升级PHP要谨慎

一.发挥PHP 7高性能的几个要点 PHP 7相对于之前的PHP版本来说可以说性能有了质的飞跃,但是所谓“好马配好鞍,好车配风帆”,想要发挥PHP 7的性能优势,还需要从以下几个方面做准备:(此部分引自PHP7核心开发者, Yaf, Yar, Yac等项目作者:Laruence). 1. 记得启用Zend Opcache,启用Opcache非常简单, 在php.ini配置文件中加入: ? 1 2 3 zend_extension=opcache.so opcache.enable=1 opcac

Linux内核工程导论——UIO

要开启hugepages文件系统,这个文件系统要使用mmap来映射页,可以显著的减少缺页中断. UIO介绍 UIO是一个在用户端实现内核驱动的机制.其在内核中有一个模块支持uio模块.现在这个模块只支持字符设备.用户可以添加多个uio设备(用户端的设备驱动),每个设备在/dev/uioX,X为数字,第一个为0,依次类推.我们知道设备都是靠中断来响应的,响应uio设备中断的方法是读取/dev/uioX文件,没有中断的时候读取会阻塞,来中断的时候会读取到整数值,代表已经发生的中断的次数. 但是这只是

PHP网站部署

知乎看到   有时间验证一下,觉厉 作者:eechen链接:https://www.zhihu.com/question/60609134/answer/178175522来源:知乎著作权归作者所有,转载请联系作者获得授权. 1.如果可以,系统迁移到Linux,PHP升级到PHP7(稳妥起见,建议使用7.0而非最新的7.1). 2.PHP开启OPcache缓存,把PHP脚本解析后生成的OPcode缓存在共享内存中,避免每次请求重复解析. 3.Linux开启HugePages,OPcache开启h

[20190409]pre_page_sga=true与连接缓慢的问题.txt

--//曾经遇到11g下设置pre_page_sga=true启动缓慢的问题(没有使用hugepages).--//链接:http://blog.itpub.net/267265/viewspace-2295412/--//实际上这样系统也会遇到连接缓慢的情况,通过测试说明问题. 1.建立pfile:$ cat initxxxx.oradb_name=xxxxinstance_name=xxxxsga_target=20G#sga_target=0sga_max_size=20Gpre_page

Red Hat Enterprise Linux7 配置Tomcat

笔者是Java前端的一个萌新,电脑刚刚经历了一番脱胎换骨,然后重新装了Win10Pro,所有的开发工具都要重新安装,纠结了一番以后决定还是把一些开发工具从Windows上转移到Linux上,首先考虑了一下Ubuntu17.04,据说这个是桌面版的经典Linux了,但是可能自己有些奇葩,然后安装上Ubuntu以后觉得不是很过瘾,然后就将主要的阵地转移到了RedHat上来了. 首先RedHat笔者选择的是RedHat Enterprise Linux7,这是目前服务器用的比较多的一种Linux,这样

Red Hat Enterprise Linux7防火墙配置详细说明

Red Hat Enterprise Linux7 防火墙配置详细说明 目录 一. 防火墙介绍 ............................................................................................................. 3 1. RHEL7默认防火墙 ............................................................................