HugePage是Oracle在Linux版本下一种性能优化手段。对于共享内存区域(SGA)的数据库系统,Oracle通常都推荐在操作系统层面配置上HugePage,为Oracle实例准备更大的可用共享内存和整块的内存。

本文主要介绍在Oracle 11gR2版本上,进行HugePage配置全过程。记录下来,共需要的朋友待查。

1、环境介绍

笔者使用Oracle 11gR2系统,具体版本为11.2.0.4。

SQL> select * from v$version;

BANNER

--------------------------------------------------------------------------------

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

PL/SQL Release 11.2.0.4.0 - Production

CORE     11.2.0.4.0     Production

TNS for Linux: Version 11.2.0.4.0 - Production

NLSRTL Version 11.2.0.4.0 – Production

当前数据库配置内存策略为ASMM,也就是分别设置PGA和SGA的大小范围。Oracle根据负载情况动态自己调节内部各个子池的空间。注意:在当前版本中,AMM(Automatic Memory Management)和HugePage之间还是不能兼容。所以,如果要求配置HugePage,就只能退而求其次选择ASMM。

数据库设置的SGA空间如下:

SQL> show parameter sga;

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

lock_sga                             boolean     FALSE

pre_page_sga                         boolean     FALSE

sga_max_size                         big integer 12G

sga_target                           big integer 12G

12G的SGA,Oracle在启动过程中,针对大内存情况给出了提示在alert log中。

ue Jan 12 11:31:33 2016

Starting ORACLE instance (normal)

************************ Large Pages Information *******************

Per process system memlock (soft) limit = 64 KB

Total Shared Global Region in Large Pages = 0 KB (0%)

Large Pages used by this instance: 0 (0 KB)

Large Pages unused system wide = 0 (0 KB)

Large Pages configured system wide = 0 (0 KB)

Large Page size = 2048 KB

RECOMMENDATION:

Total System Global Area size is 12 GB. For optimal performance,

prior to the next instance restart:

1. Increase the number of unused large pages by

at least 6145 (page size 2048 KB, total size 12 GB) system wide to

get 100% of the System Global Area allocated with large pages

2. Large pages are automatically locked into physical memory.

Increase the per process memlock (soft) limit to at least 12 GB to lock

100% System Global Area's large pages into physical memory

首先Oracle发现当前系统并没有设置HugePage,只有默认的2M大小的Page可选。于是,从建议的角度,给出了提示意见,建议开启HugePage选项在操作系统层面。此时,操作系统层面也没有专门的设置。

[oracle@PROD_PC-DB trace]$ grep Huge /proc/meminfo

AnonHugePages:     36864 kB

HugePages_Total:       0

HugePages_Free:        0

HugePages_Rsvd:        0

HugePages_Surp:        0

Hugepagesize:       2048 kB

2、配置HugePage

在11.2的小版本中,HugePage处理的行为其实是在变化的。在11.2.0.2中,Oracle推出了一个参数use_large_page,作为从实例层面控制Oracle使用Huge Page的开关。

SQL> show parameter large_pages

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

use_large_pages                      string      TRUE

该参数默认取值为true,是一种向上最优策略。如果设置为true,Oracle实例会去检查是否操作系统开启了HugePage,如果有就采用,如果没有就不用。另外两个取值分别为false和only,如果选择为false,表示Oracle实例不管操作系统设置,都不会使用HugePage。如果选择为only,就表示Oracle实例只会选择HugePage上运行。

此外,在行为上也有一些变化。在11.2.0.2版本中,如果操作系统没有足够的HugePage使用,SGA内存就只有使用系统剩下的小页(Small Pages)。如果余下的小页small page不够用,或者内核使用的比较多,系统会报错ora-4030错误。

这个情况在11.2.0.3版本中有一些变化。Oracle首先会使用可用的HugePage,如果使用尽了,同样会采用剩下的small pages作为SGA使用。变化在于对使用HugePage的方式上,根据官方的说法:

With this new behavior additional shared memory segments are an expected side effect. Part of the change is to ensure that each shared memory segment making up the SGA only contains sub-areas with an identical alignment requirement - hence the SGA will spread over more separate SHM segments. In this supported mixed page mode the database will exhaust the available hugepages, before switching to regular sized pages.

新版本的操作方式可以更好的使用可用的大页资源。当前操作系统版本为Linux 2.6内核版本。

[oracle@PROD_PC-DB trace]$ uname -r

2.6.32-431.el6.x86_64

这个过程中涉及到不同操作系统环境、不同Oracle配置下的推荐HugePage数量问题。Oracle在MOS上发布出一个Shell脚本hugepages_settings.sh,可以动态计算出推荐的HugePage数量。

具体脚本内容可以从MOS Doc ID 401749.1上进行下载,在笔者之前关于HugePage的文章中也有所涉及。执行脚本后结果如下:

[oracle@PROD_PC-DB trace]$ ls -l | grep hugepag

-rw-r--r--. 1 oracle oinstall    3129 Jan 12 13:32 hugepages_settings.sh

[oracle@PROD_PC-DB trace]$ chmod +x hugepages_settings.sh

[oracle@PROD_PC-DB trace]$ ls -l | grep hugepag

-rwxr-xr-x. 1 oracle oinstall    3129 Jan 12 13:32 hugepages_settings.sh

[oracle@PROD_PC-DB trace]$ uname -r

2.6.32-431.el6.x86_64

[oracle@PROD_PC-DB trace]$ ./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 = 6148

操作系统层面配置HugePage,需要在两个层面进行配置。事先是limits.conf文件,开启对用户的内存限制。

[root@PROD_PC-DB security]# vi limits.conf

# /etc/security/limits.conf

#

#Each line describes a limit for a user in the form:

#

(篇幅原因,有省略……)

oracle soft nproc 2047

oracle hard nproc 16384

oracle soft nofile 1024

oracle hard nofile 65536

oracle soft memlock 32879476  --对应内存总量

oracle hard memlock 32879476

确认修改。

[oracle@PROD_PC-DB ~]$ ulimit -l

32879476

将脚本计算出的结果,修改入/etc/sysctl.conf文件。

net.ipv4.ip_local_port_range = 9000 65500

net.core.rmem_default = 262144

net.core.rmem_max = 4194304

net.core.wmem_default = 262144

net.core.wmem_max = 1048576

fs.aio-max-nr = 1048576

fs.file-max = 6815744

vm.nr_hugepages = 6148

"/etc/sysctl.conf" 67L, 1631C written

执行sysctl –p落实修改。

[root@PROD_PC-DB security]# sysctl -p

net.ipv4.ip_forward = 0

net.ipv4.conf.default.rp_filter = 1

(篇幅原因,有省略……)

fs.file-max = 6815744

vm.nr_hugepages = 6148

重新启动实例数据库。

SQL> conn / as sysdba

Connected.

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup

ORACLE instance started.

Total System Global Area 1.2827E+10 bytes

Fixed Size                  2265224 bytes

Variable Size            2214596472 bytes

Database Buffers         1.0603E+10 bytes

Redo Buffers                7307264 bytes

Database mounted.

Database opened.

SQL>

在操作系统层面上,可以看到HugePage使用情况。

[oracle@PROD_PC-DB ~]$ ipcs -m

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

key        shmid      owner      perms      bytes      nattch     status

0x00000000 786435     oracle     640        67108864   22

0x00000000 819204     oracle     640        12817793024 22

0x617ab988 851973     oracle     640        2097152    22

[oracle@PROD_PC-DB ~]$ grep Huge /proc/meminfo

AnonHugePages:     20480 kB

HugePages_Total:    6148

HugePages_Free:     5531

HugePages_Rsvd:     5528

HugePages_Surp:        0

Hugepagesize:       2048 kB

同时,启动过程中的推荐提示信息消失。

Tue Jan 12 14:26:30 2016

Starting ORACLE instance (normal)

************************ Large Pages Information *******************

Per process system memlock (soft) limit = 31 GB

Total Shared Global Region in Large Pages = 12 GB (100%)

Large Pages used by this instance: 6145 (12 GB)

Large Pages unused system wide = 3 (6144 KB)

Large Pages configured system wide = 6148 (12 GB)

Large Page size = 2048 KB

********************************************************************

LICENSE_MAX_SESSION = 0

LICENSE_SESSIONS_WARNING = 0

Initial number of CPU is 8

Number of processor cores in the system is 8

Number of processor sockets in the system is 1

Picked latch-free SCN scheme 3

Using LOG_ARCHIVE_DEST_1 parameter default value as USE_DB_RECOVERY_FILE_DEST

Autotune of undo retention is turned on.

IMODE=BR

3、结论

对于投产在Linux版本下的Oracle共享内存系统而言,配置HugePage还是有现实意义的。

转:http://blog.itpub.net/17203031/viewspace-1975653/

为Linux版本Oracle 11gR2配置HugePage的更多相关文章

  1. Linux平台 Oracle 11gR2 RAC安装Part1:准备工作

    一.实施前期准备工作 1.1 服务器安装操作系统 1.2 Oracle安装介质 1.3 共享存储规划 1.4 网络规范分配 二.安装前期准备工作 2.1 各节点系统时间校对 2.2 各节点关闭防火墙和 ...

  2. Linux平台 Oracle 11gR2 RAC安装Part2:GI安装

    三.GI(Grid Infrastructure)安装 3.1 解压GI的安装包 3.2 安装配置Xmanager软件 3.3 共享存储LUN的赋权 3.4 使用Xmanager图形化界面安装GI 3 ...

  3. Linux平台 Oracle 11gR2 RAC安装Part3:DB安装

    四.DB(Database)安装 4.1 解压DB的安装包 4.2 DB软件安装 4.3 ASMCA创建磁盘组 4.4 DBCA建库 4.5 验证crsctl的状态 Linux平台 Oracle 11 ...

  4. linux版本neo4j安装配置教程

    https://blog.csdn.net/weixin_44293236/article/details/89467489

  5. Oracle 11gR2 RAC 安装配置

    1. 简介   Oracle RAC,全称real application clusters,译为"实时应用集群", 是Oracle新版数据库中采用的一项新技术,是高可用性的一种, ...

  6. 【云和恩墨】性能优化:Linux环境下合理配置大内存页(HugePage)

    原创 2016-09-12 熊军 [云和恩墨]性能优化:Linux环境下合理配置大内存页(HugePage)   熊军(老熊) 云和恩墨西区总经理 Oracle ACED,ACOUG核心会员 PC S ...

  7. Oracle 11gR2 RAC网络配置,更改public ip、vip和scanip

    Oracle 11gR2 RAC网络配置,更改public ip.vip和scanip 转载黑裤子 发布于2018-10-30 01:08:02 阅读数 2898  收藏 展开 转载. https:/ ...

  8. Red Hat Enterprise Linux x86-64 上安装 oracle 11gR2

    一.以root用户登录 二.安装依赖包 #rpm -qa | grep 包名    ----查看包 binutils-2.20.51.0.2-5.11.el6 (x86_64)            ...

  9. Oracle 11gR2 客户端windows 10安装后PL/SQL配置

    操作系统:windows 10 软件:Oracle 11gR2 客户端 (64 bit) PLSQL Developer 13 (64 bit) 注意:PLSQL与oracle客户端版本要一致 1. ...

随机推荐

  1. 最大 / 小的K个数

    在<剑指offer>上看到的,而且Qunar去年的校招笔试也考了这题,今天晚上去西电腾讯的宣讲会,来宣讲的学长也说他当时一面的时候面试官问了“一亿个数据的最大的十个数”的面试题.今晚就写写 ...

  2. 【XJOI-NOIP16提高模拟训练9】题解。

    http://www.hzxjhs.com:83/contest/55 说实话这次比赛真的很水..然而我只拿了140分,面壁反思. 第一题: 发现数位和sum最大就是9*18,k最大1000,那么su ...

  3. 矩阵快速幂 POJ 3070 Fibonacci

    题目传送门 /* 矩阵快速幂:求第n项的Fibonacci数,转置矩阵都给出,套个模板就可以了.效率很高啊 */ #include <cstdio> #include <algori ...

  4. lintcode:二叉树的路径和

    题目 给定一个二叉树,找出所有路径中各节点相加总和等于给定 目标值 的路径. 一个有效的路径,指的是从根节点到叶节点的路径. 解题 下面有个小bug 最后比较的时候是叶子节点为空,左右都有叶子结点,所 ...

  5. 计算机学院2014年“新生杯”ACM程序设计大赛

    1440: 棋盘摆车问题 对于输入n,k: 1.当n<k时,无满足的摆法 2.否则 第一个车可以排n*n个位置(即整个棋盘),第二个可排(n-1)*(n-1)个位置,…… 正如排列组合一样,车与 ...

  6. JavaWeb项目开发案例精粹-第6章报价管理系统-05Action层

    0. <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC &quo ...

  7. 创业者拿到融资别高兴太早,当心TS中的优先清算权

    最近创投圈的新闻读起来真是让人有些绝望啊,一家家创业公司接连宣告倒闭,其中不乏一些走在比较后面的“明星企业”,冷不丁冒出点消息,却是创始人发的公告,宣布公司资金链断裂,进入破产清算程序,或被低价并购. ...

  8. PHP使用CURL详解

    CURL是一个非常强大的开源库,支持很多协议,包括HTTP.FTP.TELNET等,我们使用它来发送HTTP请求.它给我 们带来的好处是可以通过灵活的选项设置不同的HTTP协议参数,并且支持HTTPS ...

  9. 设置 Firewalld 防火墙控制对系统的访问

    1.检查 server101 的网卡,记住第二个网卡的名称 [root@server101 ~]# nmcli device DEVICE TYPE STATE CONNECTION br0 brid ...

  10. Index & Statistics ->> Rebuild Index会不会覆盖原先Index的WITH选项设置

    昨天因为工作中遇到要对某个数据库的表通通启用data_compression,突然有个念头,就是如果我当初用"ALTER INDEX XXX ON YYY REBUILD WITH (DAT ...