如何正确的在AIX 7上正确开启大页内存(large page)on oracle 11.2.0.4 rac 转发 https://www.modb.pro/db/1727896124915785728

发布时间 2023-11-28 14:35:18作者: Libra_bai

1、关于大页

有个客户的业务系统上要开启大页,提高系统性能,研究了一下,网上文章太多,自己做了一些测试,经过实机测试,整理了一下操作记录。

关于AIX上为什么要开启大页,借用MOS里的说明

原文:

Starting with the AIX V5.1 operating system when running on IBM POWER4 or POWER5 processors, pSeries systems support two virtual page sizes: 4 kilobytes (standard page) and 16 megabytes (large page). When using large pages to map virtual memory, the translation look aside buffer (TLB) is able to map more virtual memory with a given number of entries, resulting in a lower TLB miss rate for applications that use a large amount of virtual memory. Additionally, when using large pages, there are fewer page boundaries, which improve the performance of prefetching.

Both online transaction processing (OLTP) and data warehouse environments can benefit from using large pages.

For applications such as Oracle, which typically uses a large amount of virtual memory, using large page memory will generally result in improved performance. There are three types of memory with which Oracle can use large pages: shared memory (SGA), process data (.data), and the instruction text (.text). In most Oracle applications, the SGA dominates the virtual memory usage and, consequently, most of the benefit of using large pages is achieved by using them for the SGA. In some special Oracle applications, using large pages for .data and .text can provide some additional performance benefit. However, because of the granularity of allocation with large pages, each Oracle process might have a larger memory footprint. Large page text and data is supported on AIX and only for 64-bit processes and the 64-bit AIX kernel. For most applications, the recommendation is to use large pages only for the SGA, and not for .text or .data.

Starting with Oracle 9i, when the Oracle initialization parameter LOCK_SGA is set to TRUE, Oracle will request large pages when allocating shared memory (shmget() call has SHM_LGPAGE flag set). For the AIX operating system to use large pages when allocating shared memory, the Oracle user ID must have CAP_BYPASS_RAC_VMM and CAP_PROPAGATE capabilities. Also, the AIX large page pool must be configured (as shown in the example below). When using large pages on an Oracle Real Application Cluster (RAC) database, where the srvctl command is used to start and stop the RAC database instances, it is also necessary to set the CAP_BYPASS_RAC_VMM and CAP_PROPAGATE capabilities for the root user ID.

Large pages are always pinned, and large page memory cannot be used for standard memory. If a pool of large page memory is configured, then this memory will be unusable for allocation of standard memory even if no other application is currently using large pages.

 

译文

从 AIX V5.1 操作系统开始,在 IBM POWER4 或 POWER5 处理器上运行时,pSeries 系统支持两种虚拟页面大小:4 KB(标准页面)和 16 MB(大页面)。使用大页面映射虚拟内存时,转换后备缓冲区 (TLB) 能够使用给定数量的条目映射更多虚拟内存,从而降低使用大量虚拟内存的应用程序的 TLB 未命中率。此外,使用大页面时,页面边界较少,从而提高了预取的性能。

联机事务处理 (OLTP) 和数据仓库环境都可以从使用大页面中受益。

对于通常使用大量虚拟内存的 Oracle 等应用程序,使用大页面内存通常会提高性能。Oracle 可以使用三种类型的内存:共享内存 (SGA)、过程数据 (.data) 和指令文本 (.text)。在大多数 Oracle 应用程序中,SGA 主导着虚拟内存的使用,因此,使用大页面的大部分好处都是通过将它们用于 SGA 来实现的。在某些特殊的 Oracle 应用程序中,对 .data 和 .text 使用大页面可以提供一些额外的性能优势。但是,由于大页面的分配粒度,每个 Oracle 进程可能具有更大的内存占用。AIX 支持大页面文本和数据,并且仅支持 64 位进程和 64 位 AIX 内核。对于大多数应用程序,建议仅对 SGA 使用大页面,而不对 .text 或 .data 使用大页面

从 Oracle 9i 开始,当 Oracle 初始化参数 LOCK_SGA 设置为 TRUE 时,Oracle 将在分配共享内存时请求大页面(shmget() 调用设置了SHM_LGPAGE标志)。要使 AIX 操作系统在分配共享内存时使用大页面,Oracle 用户标识必须具有CAP_BYPASS_RAC_VMM和CAP_PROPAGATE功能。此外,还必须配置 AIX 大型页面池(如下例所示)。在 Oracle Real Application Cluster (RAC) 数据库上使用大页面时,其中 srvctl 命令用于启动和停止 RAC 数据库实例,还需要为 root 用户 ID 设置 CAP_BYPASS_RAC_VMM 和 CAP_PROPAGATE 功能

大页面始终固定,大页面内存不能用于标准内存。如果配置了大页内存池,则即使当前没有其他应用程序正在使用大页,此内存也将无法用于分配标准内存。

 

如上所述,在LINUX的环境上一般也是建议开启大页配置(linux上叫hugpage。AIX上有largepage 16M;hugpage 16G,超大页需要去HMC配置),开启大页要求数据库不能使用AMM管理(不能配置memory_target,需要配置SGA+PGA这种)。MOS里还列举了.text和.data如何调用大页,大家如有需要可以参考文档。

下面在演示环境里给大家演示一下关于AIX中大页的配置:

AIX系统环境:7200-05-05-2246

数据库版本:Oracle 11.2.0.4 RAC 数据库SGA配置65G

2、如何在AIX 7上配置大页

2.1、未开启大页之前系统状态

vmo -L lgpg_size查看

 

svmon查看

 

nmon查看内存情况

 

在未开启的节点查看oracle进程使用为4K页

 

2.2、配置开关/关闭大页

2.2.1、开启大页、计算大页分配空间:

num_of_large_pages = INT((total_SGA_size-1)/16MB)+1  //INT 这里要取整数

比如我这里测试,要给配置65GB的大页,那么65G=69793218560 16M=16777216

那么结果就是为:INT(69793218560-1/16777216)+1=4161

这里()里算出来的结果是4159.999999940395,考虑取整的话,尽量多分一点点,这里取4160。

那么需要配置的命令就是:

vmo -r -o lgpg_regions=4161 -o lgpg_size=16777216

vmo -p -o v_pinshm=1

关于v_pinshm参数的说法见4.2.3章节:

这里面还有点和O记的官方文档有点出处,ORACLE的官方文档的说明是This note applies to AIX5L and above,这个操作方法适用于AIX5L以上,显示他在AIX 6L以后就没再更新

原文里的.vmo -o lru_file_repage=0在AIX7.1里己经没有这个配置了,

官方的一些说明:

Please note that the lru_file_repage setting referenced below is not applicable to AIX 7.1 and higher.

In AIX V7, the vmo command lru_file_repage setting has been removed. AIX 7.1 will make the same decisions as AIX 6.1 with lru_file_repage at its default setting of 0.

2.2.2、取消大页配置:

执行如下命令

vmo -po lgpg_size=0 -o lgpg_regions=0

3、配置DEMO

3.1、配置过程

1、检查用户root、oracle、grid是否设置了CAP_BYPASS_RAC_VMM 和 CAP_PROPAGATE 功能

执行以下命令

lsuser -a capabilities oracle
lsuser -a capabilities grid
lsuser -a capabilities root

返回结果如下,root用户缺失该功能(装RAC的时候,oracle和Grid用户都设置过CAP_BYPASS_RAC_VMM 和 CAP_PROPAGATE 这个功能)

 

为root用户添加该功能

chuser capabilities=CAP_BYPASS_RAC_VMM,CAP_PROPAGATE root

2、修改数据库参数

alter system set lock_sga=true scope=spfile;

3、关闭数据库实例

4、开启大页

我这里多写了4162个,多出来1个。

vmo -p -o lgpg_regions=4162 -o lgpg_size=16777216
vmo -p -o v_pinshm=1

执行结果如下

 

3.2、配置检验

 

没启动数据库之前查看,大页己分配

 

 

执行命令启动数据库,开启成功后检查:

 

查看大页是否启用

 

查看剩余大页,剩余了1个。

 

svmon -P -t 100|grep -p Pid|head

 

注意上面输出的Inuse和Pin,还有Command。Command对应oracle,说明进程信息是Oracle的。Inuse代表使用中的内存页,Pin代表定在内存中的页数量,每页大小16M。

inuse和pin这两个值如果相差甚远,则说明随SGA没有定在内存里,如果相差很近,则说明定在了内存里。

4、总节

4.1、问题

 

1、如果只在系统中配置大页,不配置lock_sga,那么大页不会被引用。

2、官方说明这个是,10.2.0.4配置之后无法使用大页,需要安装 补丁7226548 After enabling large page capabilities they may not be actually used by Oracle. Large pages may be allocated at the OS level but Oracle still uses normal memory. This is due to Bug 7226548. Please apply the Patch 7226548 to avoid this issue.

3、If using Oracle 10.2.0.4, there is an oracle bug (Metalink note: 728444.1) regarding setting the page size correctly.You will need to ensure the following is set before starting a database at 10.2.0.4 only. export ORACLE_SGA_PGSZ=16m

4、SGA < 总内存*(maxpin%-10%),如果maxpin%是80%的默认值,也就是maxpin%=80%,则SGA不能超过总内存的70%,这也符合O的内存分配标准

4.2、引用参数说明

4.2.1、lock_sga作用

 

需要配合vmo -p -o v_pinshm=1使用

 

4.2.2、pre_page_sga作用

 

有些中文的配置文档里,数据库除了lock_sga改为True后,还让设置了pre_page_sga为true(19C里默认为true,11G里默认为FALSE)

开启这个参数会增加数据库的启动时间。

我的DEMO里选择没有开启,实际不开启的话,貌似也没有问题,但是没有进行实测性能,不知道生产跑起来这个怎么样,留了个坑,希望有了解的小伙伴可以给我个建议。

 

引用大佬的原文 http:/ww.dba-oracle.com/t_pre_page_sga.htm

 

4.2.3、v_pinshm参数

 

4.2.4、AIX huge page

 

AIX上:

large page 是指大页,16M大小,

huge page是指巨大的页,16G大小,huge page需要去HMC上进行配置才能使用。

 

新版本在HMC这里配置,这个只做了解,我这还没有这么牛x的场景能使用到。