OracleLinux古板Huge Pages与Transparent Huge Pages再一次学习计算

 

 

 

 

要是Oracle 是11g以往的版本,那么暗中同意创造的实例会使用Automatic Memory Management
(AMM)的特点,该个性与HugePage不兼容。在装置HugePage在此之前要求先禁止使用AMM。设置初步化参数MEMO奥迪Q5Y_TARGET 和MEMORY_MAX_TARGET
为0即可。

 

use_large_pages
= {true/only/false/auto}

HugePages
Reservation

      进步内部存款和储蓄器访问的完整品质:利用虚拟内部存储器,每3遍对内部存款和储蓄器的访问实际上都以由四次抽象的内部存款和储蓄器操作结合。若是假若使用更少的页面,那么原来在页表访问的瓶颈也得以幸免

HugePages_Free:     3439

 

 

[oracle@DB-Server ~]$ cat /proc/sys/vm/nr_hugepages 

0

[oracle@DB-Server ~]$ grep -i HugePages_Total /proc/meminfo 

HugePages_Total:     0

 

 

  

 

b)假如OS本人的内部存款和储蓄器十分的大,那么管理/访问到大家供给的内存的进程就必要更长日子。

 

规范大页的有些基石参数。如下所示:

行业内部大页(HuagePage)英文介绍

 

 

 

 

http://www.oracle.com/technetwork/cn/articles/servers-storage-dev/hugepages-2099009-zhs.html

https://help.marklogic.com/Knowledgebase/Article/View/16/0/linux-huge-pages-and-transparent-huge-pages

 

 

小编们驾驭,x86架构使用的是虚拟内部存款和储蓄器架构,其同意寻址范围超越硬件中的可用物理内部存储器。那通过同意每种进度具有和谐可寻址的内部存款和储蓄器来贯彻。该进程认为此内部存款和储蓄器是专供自身使用的。那叫做进度的虚拟内存。实际上,此内部存款和储蓄器能够是实际驻留于RAM
芯片上的情理内部存款和储蓄器,也可以是储存在物理磁盘上被称作调换区或分页区的专用区域中。进度不亮堂虚拟内部存款和储蓄器是储存在RAM
中依然磁盘上;内部存款和储蓄器由操作系统一管理理。如若所需内部存款和储蓄器超越可用物理内部存储器,操作系统会将一些内部存款和储蓄器移出到分页区。那种活动频率极低,是致使品质问题的大规模原因。由于磁盘的存取速度远低于RAM,“分页”的长河会赶上强烈的质量难题。

 

Step
6:
关闭全部的数据库实例同等对待启服务器。

 

HugePages_Surp:        “surplus”的缩写格局,表示池中不止/proc/sys/vm/nr_hugepages 中值的 HugePages
数量。剩余
HugePages 的最大数据由 /proc/sys/vm/nr_overcommit_hugepages 控制。此值为0的意况很广泛

查阅标准大页(Huage
Pages)的页面大小:

 

 

#
echo “vm.nr_hugepages=512” >> /etc/sysctl.conf

 

Hugepagesize:         
页面大小

 

Oracle 1

·        
TLB:
A Translation Lookaside Buffer (TLB) is a buffer (or cache) in a CPU
that contains parts of the page table. This is a fixed size buffer being
used to do virtual address translation faster.

 

HugePages_Odysseysvd:        已经被分配预留但是还没有使用的page数目。在Oracle刚刚运转时,大部分内部存款和储蓄器应该都以Reserved并且Free的,随着ORACLE SGA的利用,Reserved和Free都会不断的下落

·        
Decreased
page table overhead: Each page table entry can be as large as 64 bytes
and if we are trying to handle 50GB of RAM, the pagetable will be
approximately 800MB in size which is practically will not fit in 880MB
size lowmem (in 2.4 kernels – the page table is not necessarily in
lowmem in 2.6 kernels) considering the other uses of lowmem. When 95% of
memory is accessed via 256MB hugepages, this can work with a page table
of approximately 40MB in total. See also Document 361468.1.

[root@mylnx02 ~]# ./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 = 4098

·        
Faster
overall memory performance: On virtual memory systems each memory
operation is actually two abstract memory operations. Since there are
fewer pages to work on, the possible bottleneck on page table access is
clearly avoided.

 

https://support.oracle.com/epmos/faces/DocumentDisplay?parent=DOCUMENT&sourceId=361468.1&id=401749.1

 

 

 

 

 

HugePages_Total:       分配的页面数目,和Hugepagesize相乘后拿走所分配的内部存款和储蓄器大小

 

那么大家修改/etc/security/limits.conf,设置memlock的值为1638伍仟(16077*1024)

 

*
hard memlock 16384000

 

肯定标准大页(守旧大页/大页/HuagePage)是不是配备、并在动用的艺术:

启用透明大页

自然,任何事情都以有两面性的,HugePage也有个别小缺点。第多个毛病是它必要非凡布置,不过那完全是可以忽略的。别的, 假如使用了HugePage,11g新特点 AMM(Automatic Memory
Management)就无法选取了,可是ASMM(Automatic Shared Memory
Management)照旧能够三番八次运用。

 

    裁减页表的费用:各类页表条目能够高达64字节,假如大家50GB的RAM保存在页表(page table)个中,那么页表(page
table)大小大约为800MB,实际上对于lowmem来说,考虑到lowmem的别样用途,880MB大小是不适用的(在2.4内核在那之中 ,page tabel在低于2.6的基业个中不是必须的), lowmem中通过256MB的hugepages访问95%的内部存储器时,能够行使大概40MB的页表。
另见文书档案361468.1。

o   Fewer
TLB entries for the SGA also means more for other parts of the address
space

    当使用HugePages时,TLB条目将包涵更大的地方空间,对于SGA中的全部或大部的内部存款和储蓄器映射,TLB未命大校会大大收缩。

Linux下HugePage能够消除由上述两种难点引发的属性波动。

[oracle@DB-Server ~]$ more /etc/issue

Red Hat Enterprise Linux Server release 5.7 (Tikanga)

Kernel \r on an \m

 

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

HugePages_Total:     0

HugePages_Free:      0

HugePages_Rsvd:      0

Hugepagesize:     2048 kB

 

[root@mylnx02 ~]# more /etc/issue

Red Hat Enterprise Linux Server release 6.6 (Santiago)

Kernel \r on an \m

 

[root@mylnx02 ~]#  grep Huge /proc/meminfo

AnonHugePages:     18432 kB

HugePages_Total:       0

HugePages_Free:        0

HugePages_Rsvd:        0

HugePages_Surp:        0

Hugepagesize:       2048 kB

HugePages_Rsvd
is short for “reserved,” and is the number of hugepages for which a
commitment to allocate from the pool has been made, but no allocation
has yet been made. It’s vaguely analogous to overcommit.

o   
倘使该页处于已修改境况并可备份回文件系统,则将页内容写入到磁盘.

 

 

 

Large
Page size = 2048 KB

 

HugePages_Total:    4098

在这个意况下,大家反复会境遇诸如latch/mutex/library cache
lock[pin]/row cache lock的问题.

#
grep PageTables /proc/meminfo

 

o   
要是该页处于已修改情况但尚无任何磁盘备份,则将页内容写入到swap device.

当大气内部存款和储蓄器被用来ORACLE数据库或其余应用时,操作系统将花费大量财富来管理虚拟地址到大体地址转换,其结果往往是三个相当大的页表结构(Page
Table)。由于每条页表条目包括进度正在采用的全数内部存款和储蓄器页面包车型地铁虚拟地址到大体地址的转移,由此对此丰硕大的系统全局区
(SGA),各个进度的页表条目都大概非常的大。举个例子,我们的一个测试服务器,内部存款和储蓄器为64GB,SGA_TA途达GET为32G,假设没有利用古板大页,页表结构(PageTables)大小为1573080 kB,接近1.5G大小了。您能够观望,要保管的页面数量巨大。那将招致明显的习性成本。

其余:私下认可处境下ASM instance
也是接纳AMM的,但因为ASM 实例不须要徐熙媛女士(Barbie Hsu)GA,所以对ASM 实例使用HugePages意义一点都不大。

16384000

 

手续2:重新登录安装Oracle产品的账号并证实memlock。如下所示,当前测试环境的账号为oracle

参考资料:

https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/5/html/Tuning_and_Optimizing_Red_Hat_Enterprise_Linux_for_Oracle_9i_and_10g_Databases/sect-Oracle_9i_and_10g_Tuning_Guide-Large_Memory_Optimization_Big_Pages_and_Huge_Pages-Configuring_Huge_Pages_in_Red_Hat_Enterprise_Linux_4_or_5.html

Large
Pages unused system wide = 1015 (2030 MB) (alloc incr 64 MB)

https://developers.redhat.com/blog/2014/03/10/examining-huge-pages-or-transparent-huge-pages-performance/

 

·        
hugetlbfs:This
is a new in-memory filesystem like tmpfs and is presented by 2.6 kernel.
Pages allocated on hugetlbfs type filesystem are allocated in
HugePages.

正规大页的布置查看

 

绝超过三分一操作系统选择了分支或分页的方法开始展览管理。分段是粗粒度的管理办法,而分页则是细粒度管理章程,分页格局能够幸免内部存款和储蓄器空间的荒废。相应地,也就存在内部存储器的物理地址与虚拟地址的定义。通过后边那三种办法,CPU必须把虚拟地址转换程物理内部存款和储蓄器地址才能确实访问内部存款和储蓄器。为了提升那么些转换效用,CPU会缓存近年来的虚拟内存地址和物理内存地址的映射关系,并保存在三个由CPU维护的映射表中。为了尽恐怕进步内部存款和储蓄器的访问速度,必要在映射表中保存尽量多的照耀关系。Linux的内部存款和储蓄器管理选拔的是分页存取机制,为了保证物理内部存款和储蓄器能得到充足的运用,内核会依照LRU算法在适当的时候将大体内部存储器中不常常利用的内部存款和储蓄器页自动调换来虚拟内部存款和储蓄器中,而将日常接纳的音信保存到大体内部存款和储蓄器。平日境况下,Linux暗许情形下每页是4K,那就象征一旦物理内部存款和储蓄器非常的大,则映射表的条目将会尤其多,会潜移默化CPU的摸索作用。因为内部存款和储蓄器大小是一向的,为了减小映射表的条文,可选拔的情势只有扩张页的尺寸。因而Hugepage便因此而来。相当于打破古板的小页面包车型客车内部存款和储蓄器管理方式,使用大页面2M,4M等。如此一来映射条目则明显减少。TLB
缓存命中率将大大提升。

https://oracle-base.com/articles/linux/configuring-huge-pages-for-oracle-on-linux-64

 

 

   减少页表查询的开发:PTE的数目缩小,那么使得广大页表的询问就不供给了,并且更少的PTE使得页表的查询更快。假如TLB
miss,则恐怕供给卓殊三遍内部存款和储蓄器读取操作才能将线性地址翻译为大体地址。

 

我们领略,在Linux 陆拾2人系统内部,私下认可内部存款和储蓄器是以4K的页面(Page)来保管的,当系统有拾分多的内部存款和储蓄器的时候,管理那个内部存储器的损耗就比较大;而HugePage使用2M轻重缓急的页面来减小管理支付。HugePage管理的内部存款和储蓄器并不可能被Swap,那就防止了Swap引发的数据库质量难点。所以,如若你的体系不时蒙受因为swap引发的性质难点的系统毫无疑问需求启用HugePage。其余,OS内部存款和储蓄器相当的大的连串也急需启用HugePage。可是实际多大就必将须求使用HugePage?那并不曾定论,某个文书档案曾经提到12G上述就推荐开启,大家强烈提出您在测试环境举行了充裕的测试之后,再决定是还是不是在生产环境应用HugePage。

    减轻TLB的压力

暗许值是true,借使系统装置Hugepages的话,SGA会优先利用hugepages,有微微用略带。假诺设置为false, SGA就不会动用hugepages。假诺设置为only 假如hugepages大小不够的话,数据库实例是无力回天起动的。设置为auto,那几个选项会触发oradism进程重新配置linux内核,以追加hugepages的数目。一般安装为true。

 

PageTables:      1573080
kB

[root@mylnx02 ~]# free -m

             total       used       free     shared    buffers     cached

Mem:         16077       9520       6556          0         37        766

-/+ buffers/cache:       8716       7361

Swap:        14015          0      14015

 

  

    TLB是直接缓存虚拟地址到大体地址的缓存表,用于升级质量,省去查找page
table从而减弱支出,不过假若出现的大度的TLB
miss,必然会给系统的本性带来较大的负面影响,越发对于一连的读操作。从第贰篇作品中大家明白如若应用hugepages能多量缩小PTE的数目,也就表示访问同一多的内容须要的PTE会更少,而日常TLB的槽位是零星的,一般唯有511个,所以更少的PTE也就意味着更高的TLB的命中率。

HugePages_Free:        平素没有被使用过的Hugepages数目。尽管oracle
sga已经分配了这一部分内部存款和储蓄器,不过假如没有实际写入,那么看看的依然Free的。那是很不难误解的地点(池中从不分配的 HugePages 数量。)

 

    SGA必要更少的TLB条目意味着TLB中得以有更加多的条条框框来保存其余地点空间。

 

The
sum of Hugepages_Free and HugePages_Rsvd may be smaller than your
total combined SGA as instances allocate pages dynamically and
proactively as needed.

The
HugePages reservation feature is fully implemented in 2.6.17 kernel, and
thus EL5 (based on 2.6.18) has this feature. The alloc_huge_page() is
improved for this. (See kernel source mm/hugetlb.c)

AnonHugePages:         匿名 HugePages 数量。Oracle Linux 6.5中已去除此计数器。与透明 HugePages 有关。

 

 

为了保障HugePages配置的有效性,HugePages_Free值应该小于HugePages_Total
的值,并且有自然的HugePages_Rsvd的值。

 

 

 

·        
Page
Table
:
A page table is the data structure of a virtual memory system in an
operating system to store the mapping between virtual addresses and
physical addresses. This means that on a virtual memory system, the
memory is accessed by first accessing a page table and then accessing
the actual memory location implicitly.

·        
Eliminated
page table lookup overhead: Since the pages are not subject to
replacement, page table lookups are not required.

From
/usr/share/doc/kernel-doc-2.6.18/Documentation/vm/hugetlbpage.txt:

memlock   
60397977

 

 

 

 

HugePages_Rsvd:     3438

 

而ORACLE为啥要选取正式大页(Huge
Pages)来进步质量?因为ORACLE数据库使用共享内部存款和储蓄器(SGA)来管理能够共享的局地财富;比如shared pool中蕴藏了共享的SQL语句及进行安顿,buffer
pool中储存了数据块。对那么些财富的拜访,其实正是ORACLE使用OS的API来访问内部存款和储蓄器资源的经过。内部存款和储蓄器操作理应/平常意义上都以火速的,那时候Oracle数据库能够很健康的劳作。但是有个别情况下也会产出品质难点:

[oracle@DB-Server ~]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.1.0 Production on Fri Oct 27 14:43:12 2017

 

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

 

 

Connected to:

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

With the Partitioning, OLAP, Data Mining and Real Application Testing options

 

SQL> show parameter memory_target;

 

NAME                                 TYPE        VALUE

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

memory_target                        big integer 1552M

SQL> show parameter memory_max_target;

 

NAME                                 TYPE        VALUE

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

memory_max_target                    big integer 1552M

SQL> 

 

SQL> alter system set memory_target=0 scope=both;

SQL> alter system set memory_max_target=0 scope=spfile;

[oracle@mylnx02
~]$ grep HugePages /proc/meminfo

[oracle@mylnx02
~]$ ulimit -l

o   Hugepge
uses fewer pages to cover the physical address space, so the size of
“book keeping” (mapping from the virtual to the physical address)
decreases, so it requiring fewer entries in the TLB

 

https://blogs.oracle.com/database4cn/linux-64hugepage

 

The
HugePages feature is backported to some 2.4 kernels. Kernel versions
2.4.21-* has this feature (See Note 311504.1 for the distributions with
2.4.21 kernels) but it is implemented in a different way. The feature is
completely available. The difference from 2.6 implementation is the
organization within the source code and the kernel parameters that are
used for configuring HugePages. See Parameters/Setup section
below.

·        
hugetlb:
This is an entry in the TLB that points to a HugePage (a large/big page
larger than regular 4K and predefined in size). HugePages are
implemented via hugetlb entries, i.e. we can say that a HugePage is
handled by a “hugetlb page entry”. The ‘hugetlb” term is also (and
mostly) used synonymously with a HugePage (See Note
261889.1). In this document the term “HugePage” is going
to be used but keep in mind that mostly “hugetlb” refers to the same
concept.

 

 

QX56HEL的法定文书档案对价值观大页(Huge
Pages)和透亮大页(Transparent Huge
Pages)那两者的描述如下(https://access.redhat.com/documentation/en-US/Red\_Hat\_Enterprise\_Linux/6/html/Performance\_Tuning\_Guide/s-memory-transhuge.html)

除此以外,随着硬件的火速发展,服务器的内部存储器越来越大,系统中利用的内部存款和储蓄器更加多,管理该内部存储器所需的能源也就更加多。对于Linux 操作系统,通过 Linux kswapd 进度和页表(Page
Table)内部存款和储蓄器结构(针对系统中存在的每种进程包罗一条记下)达成内部存储器管理。每条记下蕴含进度使用的每页虚拟内存及其物理地址(RAM
或磁盘)。通过使用电脑的TLB( Translation
Lookaside Buffer CPU中一小块缓存)为该进度提供帮扶。操作系统使用页表条目管理连串中经过所用的内部存款和储蓄器。在 Linux
中,执行此管理的操作系统进度被称作kswapd,可在操作系统工具中找到。TLB
缓存将缓存页表条目来增长品质。典型的 TLB 缓存可保留 4 到 409伍个条目。对于数百万竟是数十亿个页表条目,那种缓存就不够用了。

 

*
soft memlock 16384000

·        
Relief
of TLB pressure:

Step
5:在/etc/sysctl.conf文件中设置vm.nr_hugepages参数

 

The
AMM and HugePages are not compatible. One needs to disable AMM on 11g to
be able to use HugePages. See Document 749851.1 for further
information.

Linux下的大页分为两连串型:标准大页(Huge
Pages)和透亮大页(Transparent Huge Pages)。Huge
Pages有时候也翻译成大页/标准大页/古板大页,它们都是Huge
Pages的例外普通话翻译名而已,顺带提一下这么些,免得有人被这么些名词给混淆、误导了。Huge Pages是从Linux Kernel
2.6后被引入的。指标是选取更大的内部存款和储蓄器页面(memory page size)
以适应越来越大的系统内部存款和储蓄器,让操作系统可以扶助现代硬件架构的大页面容积作用。透明大页(Transparent Huge
Pages)缩写为THP,那一个是OdysseyHEL 6(其余分支版本SUSE Linux Enterprise Server 11, and Oracle
Linux 6 with earlier releases of Oracle Linux Unbreakable Enterprise
Kernel 2
(UEK2))伊始引入的3个效果。具体能够参考官方文档。那两者有甚差别吗?那两者的界别在于大页的分配机制,标准大页管理是预分配的不二法门,而透明大页管理则是动态分配的形式。相信有无数人将Huge Page和Transparent Huge
Pages混为一谈。近期透明大页与历史观HugePages联用会出现一些标题,导致品质难点和系统重启。Oracle
建议禁止使用透明大页(Transparent Huge Pages)。在 Oracle Linux 6.5
版中,已去除透明
HugePages。

上面大家来介绍一下,在六九人Linux服务器下为ORACLE数据库设置专业余大学页的骨干步骤,具体须要依照真实情形作出调整。关于什么安排标准大页,能够参考官方文书档案HugePages on Oracle Linux 64-bit
(文书档案 ID
361468.1)或文书档案(Configuring HugePages for Oracle on Linux
(x86-64)
)来演示一下怎样设置Huge Pages。

 

 

THP
hides much of the complexity in using huge pages from system
administrators and developers. As the goal of THP is improving
performance, its developers (both from the community and Red Hat) have
tested and optimized THP across a wide range of systems, configurations,
applications, and workloads. This allows the default settings of THP to
improve the performance of most system configurations. However, THP is
not recommended for database workloads.

*
 
soft 

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

 

 

 

 

 

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

Oracle
11.2.0.3以及后来版本
,可以通过检查警报日志来证实是否对数据库实例启用了大页面。运维实例时,您应在警报日志中参数列表前边看到如下内容:

 

[root@DB-Server ~]$ grep Hugepagesize /proc/meminfo

Hugepagesize:     2048 kB

 

 

 

若果那里的值当先了SGA的要求,也远非不利于的震慑。假若采用了Oracle Linux的oracle­-validated包,大概Exadata DB
compute则会自动配置那么些参数。上面来看看三个实际上测试环境,内存为16G

步骤1:在/etc/security/limits.conf文件中添加memlock的范围,注意该值略微小于实际物理内部存储器的尺寸(单位为KB)。比如物理内部存款和储蓄器是64GB,能够设置为如下:

 

 

 

 

 

    Hugepge使用较少的页面来掩盖物理地址空间,因而“保留书签”(从虚拟地址到大体地址的映照)的深浅收缩,由此在TLB中须求较少的条条框框

 

 

 

 

 

如果HugePages_Total为0,意味着正式大页(大页、守旧大页)没有设置或采取。nr_hugepages为0,意味着正式大页没有安装。

除此以外,能够通过以下参数控制数据库对HugePage的运用方法(11gr2之后):

 

上面是有个别有关名词以及Huge
Pages的性状等等。当先1/2都是昂科雷HEL官网或Mos上相关英文材质以及对应的局地翻译:

#! /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); }'`

 

# 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.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

如若地点那段解释还不够鲜明、彻底,那么看看下边那段摘抄的演说:

Huge
pages can be difficult to manage manually, and often require significant
changes to code in order to be used effectively. As such, Red Hat
Enterprise Linux 6 also implemented the use of transparent huge
pages
(THP). THP is an abstraction layer that automates most aspects of
creating, managing, and using huge pages.

a)假诺SGA内的某一片段被swap到硬盘上,那么再度走访它,就须求花那几个多的日子。

HugePages
in 2.4 Kernels

·        
Not
swappable: HugePages are not swappable. Therefore there is no
page-in/page-out mechanism overhead.HugePages are universally regarded
as pinned.

手续3: 11g中禁止使用AMM  要是ORACLE
11g要利用正式大页,就务须禁止使用AMM(Automatic
Memory Management),倘使是ORACLE
10g则能够忽略该手续。

 vi
/etc/security/limits.conf

在Linux中,
kswapd是负责基本页面沟通管理的三个医生和护师进程,它的职分是保障Linux内部存款和储蓄器管理操作的立即。当物理内部存款和储蓄器不够时,它就会变得要命aggressive,有个别景况下能占据单核CPU的百分百.  
kswapd 进度负责保障内存空间总是在被假释中,它监察和控制内核中的pages_high和pages_low阀值。若是空闲内部存储器的数值低于pages_low,则每回 kswapd
进度运营扫描并尝试释放三十7个free pages.并一贯重复那些进程,直到空闲内部存款和储蓄器的数值高于 pages_high。kswapd
进度达成以下多少个操作:

THP为系统一管理理员和开发人士减弱了累累利用守旧大页的复杂, 因为THP的目的是改良质量, 由此其余开发职员 (来自社区和红帽)
已在各个系统、配置、应用程序和负载中对 THP 实行了测试和优化。那样可让 THP
的暗中认可设置立异大部分体系布局质量。可是, 不提出对数据库工作负荷使用 THP。

    不可交换:HugePages不可交流。 由此没有页面换入/页面换出的机制开支.HugePages被普遍认为是一向在RAM中的。

注:THP
如今只能照射异步内部存款和储蓄器区域,比如堆和栈空间

 

 

 

 

 

The
values in the output will vary. To make sure that the configuration is
valid, the HugePages_Free value should be smaller than
HugePages_Total and there should be some HugePages_Rsvd.
HugePages_Rsvd counts free pages that are reserved for use (requested
for an SGA, but not touched/mapped yet).

https://support.oracle.com/epmos/faces/DocumentDisplay?\_afrLoop=500381499574891&id=361323.1&\_afrWindowMode=0&\_adf.ctrl-state=lxb6cxp3\_100

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

 

历史观大页很难手动管理,
而且平常必要对代码实行重点改观才能管用地运用。由此, 红帽公司 Linux 6
完结引入了晶莹剔透大页面 (THP)。THP 是三个抽象层,
能够自行创设、管理和选拔古板大页的绝当先百分之六十方面。

假定大家要采纳HugePage,那么就亟须先确认保障没有安装MEMOEscortY_TARGET/
MEMORY_MAX_TARGET参数。

Large
Pages configured system wide = 19680 (38 GB)

 

*
 
hard    memlock
 
   60397977

 

HugePages
and Oracle 11g Automatic Memory Management (AMM)

 

 

Advantages
of HugePages Over Normal Sharing Or AMM (see below)

何以设置标准大页(Huge
Page)的轻重缓急呢?一般都以修改内核参数nr_hugepages。在/etc/sysctl.conf配置文件中安装参数vm.nr_hugepages

https://access.redhat.com/documentation/zh-CN/Red\_Hat\_Enterprise\_Linux/6/html/Performance\_Tuning\_Guide/s-memory-transhuge.html

 

 

 

https://docs.oracle.com/cd/E11882\_01/install.112/e41961/memry.htm\#CBAFIFGJ

HugePages_Free

HugePages_Ku瓦斯vd 那有的是一贯不被选择到的内部存储器,假若没有其余的oracle
instance,那部分内存或许永远都不会被应用到,也正是被荒废了。HugePages_Total-HugePages_Free+HugePages_汉兰达svd
正是当前实例供给的页面数量.

 

 

 

o   TLB
entries will cover a larger part of the address space when use
HugePages, there will be fewer TLB misses before the entire or most of
the SGA is mapped in the SGA

那些正是价值观大页为啥会被引入的来由。
引入它能一蹴而就什么难题吧?内部存款和储蓄器是由块管理,即分明的页面。大家通晓,在Linux 六贰十二个人系统里头,私下认可内部存款和储蓄器是以4K的页面(Page)来保管的。也便是说三个页面有 4096 字节。1MB 内部存款和储蓄器等于 256 个页面。2MB内部存款和储蓄器等于5十二个页面。管理这个内部存款和储蓄器的开支就相比较大。CPU
有内嵌的内部存款和储蓄器管理单元TLB,这几个单元中带有那么些页面列表,各类页面都利用页表条目。页表(Page
Table)用来存放在虚拟内部存储器和情理内部存款和储蓄器页对应提到的内部存款和储蓄器结构。假如page
size较小,那么相应的页表内部存储器结构就会比较大。而Hugepages的私下认可值page size为2M,是4KB的500倍,所以能够大大减小Page
Table的大大小小。通过启用
HugePages使用大页面,能够用一个页表条目代表三个大页面,而不是利用过多条目代表较小的页面,从而能够管理越多内部存款和储蓄器,减少操作系统对页面状态的维护并升高 TLB
缓存命中率。注意,Hugepagesize的大小暗中同意为2M,那些也是能够调动的。区间范围为2MB
to 256MB。

 

 

 Large Pages used
by this instance: 14497 (28 GB)

 

 

 

 

 

 

启用透明大页非凡简单,能够参见那篇博客Linux
关于Transparent
Hugepages的介绍

那里不做赘述。

 

This
feature in the Linux kernel enables the Oracle Database to be able to
allocate hugepages for the sublevels of the SGA on-demand. The same
behaviour is expected for various Oracle Database versions that are
certified on EL5.

Step
7:
验证配置是或不是科学,如下所示:

o   
倘若该页处于未修改状态,则将该页放置回空闲列表中.

手续4:确认保障您持有的ORACLE数据库实例都已经起步(包涵ASM实例),然后运转hugepages_settings.sh(具体参考Mos文书档案Document
401749.1,脚本内容如下)获取基本参数vm.nr_hugepages的大小。

 

vm.nr_hugepages=4098

SQL>
alter system set use_large_pages=true scope=spfile sid=’*’;

HugePages
is a feature integrated into the Linux kernel with release 2.6. It is a
method to have larger pages where it is useful for working with very
large memory. It can be useful for both 32-bit and 64-bit
configurations. HugePage sizes vary from 2MB to 256MB, depending on the
kernel version and the hardware architecture. For Oracle Databases,
using HugePages reduces the operating system maintenance of page states,
and increases TLB (Translation Lookaside Buffer) hit ratio.

 

动用AMM的景观下,全数的SGA 内部存款和储蓄器都是在/dev/shm
下分配的,因而在分配SGA时不会利用HugePage。那也是AMM 与HugePage不包容的来由。

HugePages_Surp:        0

 

相关文章