自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Oracle數(shù)據(jù)庫內(nèi)存耗盡,大頁惹的禍?

數(shù)據(jù)庫 Oracle
使用HugePages時(shí),操作系統(tǒng)頁表(虛擬內(nèi)存到物理內(nèi)存的映射)變小,可以減少訪問頁表?xiàng)l目所需的系統(tǒng)資源量,從而提高系統(tǒng)性能。HugePage的大小從2MB到256MB不等,這取決于內(nèi)核版本和硬件體系結(jié)構(gòu)。

一、內(nèi)存耗盡場景

問題現(xiàn)象:

Oracle數(shù)據(jù)庫服務(wù)器內(nèi)存資源耗盡,數(shù)據(jù)庫無響應(yīng)。

問題原因:

原linux環(huán)境沒有啟用HugePages,啟用HugePages后,內(nèi)存使用率直線上漲,最終內(nèi)存資源耗盡。

啟用HugePages明明是提高性能,為什么會(huì)導(dǎo)致內(nèi)存資源耗盡呢?這和HugePages內(nèi)存分配機(jī)制有關(guān):

例如當(dāng)前配置信息如下:

數(shù)據(jù)庫服務(wù)器總內(nèi)存128GB,SGA分配75GB,PGA分配30GB,SGA+PGA占總內(nèi)存82%。

通常啟用HugePages大頁時(shí),會(huì)將HugePages設(shè)置為偏大于SGA值,例如76G。

但如果設(shè)置HugePages比SGA值小,會(huì)出現(xiàn)什么情況?

例如:將HugePages設(shè)置為70GB。

此時(shí)服務(wù)器內(nèi)存最大會(huì)分出70GB給HugePages使用,但是由于HugePages<SGA,導(dǎo)致Oracle數(shù)據(jù)庫不會(huì)完全使用HugePages中的內(nèi)存來分配給SGA,出現(xiàn)內(nèi)存資源浪費(fèi),高并發(fā)、高負(fù)載等場景下可能會(huì)導(dǎo)致內(nèi)存資源耗盡。

在官方文檔有這么一段描述:

Ensure that HugePages is configured properly as the system may run out of memory if excess HugePages is not used by the application.

確保HugePages配置正確,因?yàn)槿绻麘?yīng)用程序未使用過多的HugePage,系統(tǒng)可能會(huì)耗盡內(nèi)存。

問題重現(xiàn):

環(huán)境說明:

OS:Red Hat Enterprise Linux Server release 7.5 (Maipo)
DB:Oracle 11.2.0.4.0
內(nèi)存:3692MB

參數(shù):

sga_max_size=sga_target=1970MB
pga_aggregate_target=980MB
use_large_pages=TRUE

AMM內(nèi)存管理和HugePages不兼容,如果內(nèi)存啟用了AMM(Automatic Memory managed),需要先切換為ASMM(Automatic Shared Memory Managed)。

先備份參數(shù)文件:

SQL> show parameter spfile
SQL> ho cp /oracle/app/oracle/product/11.2/db/dbs/spfilecjc.ora /home/oracle/spfilecjc.ora.bak

將AMM轉(zhuǎn)換為ASMM:

alter system reset memory_target scope=spfile;
---alter system reset memory_max_target scope=spfile;
alter system set sga_max_size=1970M scope=spfile;
alter system set sga_target=1970M scope=spfile;
alter system set pga_aggregate_target=980M scope=spfile;

重啟數(shù)據(jù)庫:

SQL> shutdown immediate
SQL> startup

1.1 正確啟用HugePages方法:

啟動(dòng)前,檢查基本信息

[root@cjc-db-01 ~]# grep Huge /proc/meminfo
AnonHugePages: 100352 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
[root@cjc-db-01 ~]# uname -sr
Linux 4.1.12-112.16.4.el7uek.x86_64
[root@cjc-db-01 ~]# cat /proc/meminfo|grep PageTables


PageTables: 38084 kB
[root@cjc-db-01 ~]# free -h
total        used        free      shared  buff/cache   available
Mem: 3.6G        490M        2.2G        289M        918M        1.9G
Swap: 2.0G          0B        2.0G

配置memlock

在/etc/security/limits.conf文件中設(shè)置memlock值,memlock設(shè)置以KB為單位。

當(dāng)啟用HugePages內(nèi)存時(shí),最大鎖定內(nèi)存限制應(yīng)至少設(shè)置為當(dāng)前服務(wù)器內(nèi)存的90%。

禁用HugePages內(nèi)存時(shí),最大鎖定內(nèi)存限制應(yīng)設(shè)置為至少3145728 KB(3 GB)。

例如,如果安裝了64 GB RAM,則添加以下條目以增加最大鎖定內(nèi)存地址空間:

* soft   memlock    60397977
* hard   memlock    60397977

也可以將memlock值設(shè)置為高于SGA要求的值,或者設(shè)置為unlimited

oracle soft memlock unlimited
oracle hard memlock unlimited

再次以oracle用戶身份登錄并運(yùn)行ulimit-l命令以驗(yàn)證新的memlock設(shè)置

[oracle@cjc-db-01 ~]$ ulimit -l
Unlimited

檢查并啟動(dòng)實(shí)例

RAC:

檢查實(shí)例是啟動(dòng)狀態(tài)

srvctl status instance -d dbname

如果沒啟動(dòng),手動(dòng)啟動(dòng)實(shí)例

srvctl start instance -d dbname -i instance_name -o open

單機(jī):

SQL> select status from v$instance;

使用腳本為當(dāng)前共享內(nèi)存段計(jì)算hugepages配置的建議值:

root用戶下執(zhí)行:

chmod +x hugepages_settings.sh
./hugepages_settings.sh

備注:腳本內(nèi)容見末尾。

腳本來自My Oracle Support note 401749.1?。

例如:

[root@cjc-db-01 oracle]# ./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 the overall 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 = 996

最終計(jì)算出的vm.nr_hugepages建議值為996,tmd數(shù)字不吉利。

其中996乘以2MB=1992MB > sga_target(1970MB)

執(zhí)行腳本除了看vm.nr_hugepages,也要關(guān)注下其他內(nèi)容:

在執(zhí)行之前,請注意以下事項(xiàng):

(1)對(duì)于ASM實(shí)例,需要配置ASMM而不是AMM。
(2)“pga_gaggregate_target”位于SGA之外,在計(jì)算總體大小時(shí)應(yīng)考慮到這一點(diǎn)。
(3)如果更改了DB SGA的大小,因?yàn)樾碌腟GA將不適合以前的HugePage配置,因此最好禁用整個(gè)HugePage,用新SGA大小啟動(dòng)DB,然后再次運(yùn)行腳本。
并確保:
(1)數(shù)據(jù)庫實(shí)例是啟動(dòng)運(yùn)行的;
(2)HugePages and Oracle Database Automatic Memory Management (AMM) on Linux (Doc ID 749851.1)
(3)共享內(nèi)存段可以通過以下命令列出:
# ipcs -m

停止數(shù)據(jù)庫實(shí)例

RAC:
srvctl stop instance -d dbname -i instance_name -o immediate
單機(jī):
SQL> shutdown immediate

設(shè)置vm.nr_hugepages內(nèi)核參數(shù)

寫入配置文件,永久生效

vi /etc/sysctl.conf
vm.nr_hugepages=996
wq

# sysctl -w vm.nr_hugepages=<value from above> 臨時(shí)改變,重啟失效。

本次示例:996

sysctl -p

查詢:

[root@cjc-db-01 ~]# grep Huge /proc/meminfo
AnonHugePages: 98304 kB
HugePages_Total: 996
HugePages_Free: 996
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB

啟動(dòng)實(shí)例

RAC:
srvctl start instance -d dbname -i instance_name -o open
單機(jī):
SQL> startup

查看alert_cjc.log日志信息:

Starting ORACLE instance (normal)
************************ Large Pages Information *******************
Per process system memlock (soft) limit = UNLIMITED
Total Shared Global Region in Large Pages = 1986 MB (100%)
Large Pages used by this instance: 993 (1986 MB)
Large Pages unused system wide = 3 (6144 KB)
Large Pages configured system wide = 996 (1992 MB)
Large Page size = 2048 KB
********************************************************************

檢查可用的hugepages

如果配置沒生效,需要重啟服務(wù)器;

[root@cjc-db-01 ~]# grep Huge /proc/meminfo
AnonHugePages: 94208 kB
HugePages_Total: 996
HugePages_Free: 787
HugePages_Rsvd: 784
HugePages_Surp: 0
Hugepagesize: 2048 kB

PageTables變小了;

[root@cjc-db-01 ~]# cat /proc/meminfo|grep PageTables
PageTables: 30368 kB

查看內(nèi)存使用

[root@cjc-db-01 ~]# free -h
total        used        free      shared  buff/cache   available
Mem: 3.6G        2.4G        765M        9.4M        477M        343M
Swap: 2.0G         20K        2.0G

1.2 錯(cuò)誤啟用HugePages方法

如果將HugePages設(shè)置低于sga_target,例如1000MB,小于 sga_target(1970MB)。

vm.nr_hugepages值從996改為1000/2=500。

停庫:

SQL> shutdown immediate

修改參數(shù):

vi /etc/sysctl.conf
#vm.nr_hugepages=996
vm.nr_hugepages=500
wq
[root@cjc-db-01 ~]# sysctl -p

啟庫:

SQL>startup

查看alert_cjc.log日志信息:

Starting ORACLE instance (normal)
************************ Large Pages Information *******************
Per process system memlock (soft) limit = UNLIMITED
Total Shared Global Region in Large Pages = 994 MB (50%)
Large Pages used by this instance: 497 (994 MB)
Large Pages unused system wide = 3 (6144 KB)
Large Pages configured system wide = 500 (1000 MB)
Large Page size = 2048 KB
RECOMMENDATION:
Total System Global Area size is 1986 MB. For optimal performance,
prior to the next instance restart:
1. Increase the number of unused large pages by
at least 493 (page size 2048 KB, total size 986 MB) system wide to
get 100% of the System Global Area allocated with large pages
********************************************************************

告警日志有如下建議:

系統(tǒng)全局區(qū)域的總大小為1986 MB。為了獲得最佳性能,在下一次實(shí)例重新啟動(dòng)之前:

在系統(tǒng)范圍內(nèi)將未使用的大頁面數(shù)量增加至少493個(gè)(頁面大小2048 KB,總大小986 MB),以獲得100%的系統(tǒng)全局區(qū)域分配有大頁面。

查看:

頁表比正確配置的偏大

[root@cjc-db-01 ~]# cat /proc/meminfo|grep PageTables
PageTables: 34900 kB

使用了少量的HugePages

[root@cjc-db-01 ~]# grep Huge /proc/meminfo
AnonHugePages: 43008 kB
HugePages_Total: 500
HugePages_Free: 431
HugePages_Rsvd: 428
HugePages_Surp: 0
Hugepagesize: 2048 kB
[root@cjc-db-01 ~]# free -h
total        used        free      shared  buff/cache   available
Mem: 3.6G        1.4G        1.3G        237M        859M        1.0G
Swap: 2.0G          0B        2.0G

二、use_large_pages參數(shù)說明

默認(rèn)參數(shù):TRUE

當(dāng)系統(tǒng)的HugePage被使用盡,只有small pages的情況下,SGA也會(huì)繼續(xù)運(yùn)行。此時(shí),Oracle實(shí)例就運(yùn)行在內(nèi)存使用混合模式(Mixed Mode)下。

SQL> show parameter use_large_pages
NAME             TYPE   VALUE
------------------------------------ ----------- ------------------------------
use_large_pages          string   TRUE

除了TURE,還支持ONLY和AUTO。

其中ONLY表示:Oracle實(shí)例只會(huì)使用HugePage作為內(nèi)存使用,如果系統(tǒng)在AMM模式或者HugePage用盡的時(shí)候,數(shù)據(jù)庫就不能啟動(dòng)。

測試ONLY值:

先備份參數(shù)文件:

[oracle@cjc-db-01 ~]$ cd $ORACLE_HOME/dbs
[oracle@cjc-db-01 dbs]$ cp spfilecjc.ora spfilecjc.ora.bak

修改參數(shù):

SQL> alter system set use_large_pages=only scope=spfile;

重啟數(shù)據(jù)庫:

SQL> shutdown immediate
SQL> startup

報(bào)錯(cuò)如下:

ORA-27137: unable to allocate large pages to create a shared memory segment
Linux-x86_64 Error: 12: Cannot allocate memory
Additional information: 2063597568
Additional information: 1

告警信息如下:

Starting ORACLE instance (normal)
************************ Large Pages Information *******************
Parameter use_large_pages = ONLY
Per process system memlock (soft) limit = UNLIMITED
Large Pages unused system wide = 500 (1000 MB)
Large Pages configured system wide = 500 (1000 MB)
Large Page size = 2048 KB


ERROR:
Failed to allocate shared global region with large pages, unix errno = 12.
Aborting Instance startup.
ORA-27137: unable to allocate Large Pages to create a shared memory segment
ACTION:
Total System Global Area size is 1992 MB. Prior to next instance restart:
1. Increase the number of unused large pages (page size 2048 KB)
to at least 996 (1992 MB) to allocate 100% System Global Area
with large pages.
********************************************************************

恢復(fù)備份參數(shù)文件:

[oracle@cjc-db-01 dbs]$ mv spfilecjc.ora spfilecjc.ora.bak.1
[oracle@cjc-db-01 dbs]$ mv spfilecjc.ora.bak spfilecjc.ora

重新啟動(dòng)數(shù)據(jù)庫:

SQL> shutdown immediate
SQL> startup

三、HugePages說明

HugePages是Linux內(nèi)核2.6中集成的一個(gè)特性。

啟用HugePages可以使操作系統(tǒng)支持大于默認(rèn)值(通常為4KB)的內(nèi)存頁。

使用HugePages時(shí),操作系統(tǒng)頁表(虛擬內(nèi)存到物理內(nèi)存的映射)變小,可以減少訪問頁表?xiàng)l目所需的系統(tǒng)資源量,從而提高系統(tǒng)性能。

HugePage的大小從2MB到256MB不等,這取決于內(nèi)核版本和硬件體系結(jié)構(gòu)。

對(duì)于Oracle數(shù)據(jù)庫,使用HugePages可以減少操作系統(tǒng)頁表狀態(tài)的維護(hù),并提高Translation Lookaside Buffer(TLB)命中率。

四、何時(shí)啟用HugePages

適用于:具有大型SGA和或會(huì)話較多的數(shù)據(jù)庫。

許多文檔將HugePages在Linux上的使用描述為一種可能性,但沒有充分強(qiáng)調(diào)HugePage在某些數(shù)據(jù)庫配置中成為一種要求。

對(duì)于一個(gè)SGA較小或連接用戶數(shù)量較少的數(shù)據(jù)庫(較小的“會(huì)話”),配置HugePages不會(huì)有任何改進(jìn)。

但是,對(duì)于具有大SGA(2Gb以上)和許多連接用戶(會(huì)話>500)的數(shù)據(jù)庫,為了減少操作系統(tǒng)級(jí)別的內(nèi)存使用并提高數(shù)據(jù)庫的整體性能,必須配置HugePages。

每個(gè)會(huì)話的前臺(tái)進(jìn)程將具有一個(gè)稱為PageTable的內(nèi)存結(jié)構(gòu),該進(jìn)程通過該內(nèi)存結(jié)構(gòu)訪問SGA。

簡而言之,由于Linux上的默認(rèn)頁面大小很小(這是英特爾的限制),應(yīng)用程序使用的內(nèi)存非常大,因此頁面表變得太大,無法管理。

HugePages是為克服這一問題而開發(fā)的解決方案。它絕對(duì)不是內(nèi)核錯(cuò)誤。

對(duì)于使用大量SGA區(qū)域的Oracle數(shù)據(jù)庫,如果不是必要的要求,則使用HugePages是最佳實(shí)踐。

SGA越大,每個(gè)進(jìn)程的PageTable就越大。每個(gè)進(jìn)程都有這個(gè)PageTable,所以對(duì)于許多連接的會(huì)話,所有PageTable的總和將變得更大。

內(nèi)存結(jié)構(gòu)PageTables的總大小可以通過以下內(nèi)容查看:

grep PageTables /proc/meminfo

“free”實(shí)用程序不會(huì)顯式顯示這種類型的內(nèi)存,但會(huì)將其包含在“cache”或“buff/cache”下的文件系統(tǒng)緩存中。

具有大型SGA和或許多會(huì)話的數(shù)據(jù)庫必須配置HugePages。

對(duì)于性能和較小的內(nèi)存占用空間,建議使用它。

它可以是具有相對(duì)低的sga_starget=2-5Gb但具有許多會(huì)話=1000-2000的數(shù)據(jù)庫,或者具有巨大的sga_tharget=200Gb且很少會(huì)話=500的數(shù)據(jù)庫。

在這些特定的數(shù)據(jù)庫配置中,PageTables可能會(huì)消耗機(jī)器上的額外內(nèi)存,該內(nèi)存可能等于或大于SGA的總大小。

PageTables內(nèi)存被添加到該機(jī)器上數(shù)據(jù)庫消耗的SGA和總PGA內(nèi)存中。

例如:

(1)數(shù)據(jù)庫配置

sga_target=25 GB
sessions= 500

在高峰時(shí)間(連接了近500個(gè)會(huì)話)PageTables消耗機(jī)器物理內(nèi)存中的20Gb

at peak time (near 500 sessions connected) PageTables consumes 20Gb from the physical memory of the machine

grep PageTables /proc/meminfo
PageTables: 26365324 kB

因此,該數(shù)據(jù)庫在高峰時(shí)段將使用25Gb(sga)+20Gb(PageTables)+10Gb(總PGA)=55Gb。

So this database at peak times would use 25Gb (sga) + 20Gb (PageTables) + 10Gb (total PGA) = 55Gb .

一臺(tái)具有45Gb物理RAM的機(jī)器,我們通常認(rèn)為它可以很容易地容納具有25Gb SGA和10Gb總PGA的數(shù)據(jù)庫,

將開始使用10Gb交換。性能下降,如果更多的用戶連接到數(shù)據(jù)庫,我們最終將沒有內(nèi)存。

A machine with 45Gb physical RAM, which we normally think would accommodate easily a database with 25Gb SGA and 10Gb total PGA, will start swapping using 10Gb of swap.

Performance goes down and if more users connect to the database, we would end up without memory.

(2)數(shù)據(jù)庫配置

sga_target = 250G
sessions= 5000

a.在配置HugePages之前,我們看到209Gb的巨大“buff/cache”幾乎等于SGA

a. before configuring HugePages we see a huge 'buff/cache' of 209Gb almost equal to the SGA

free -g
total   used   free   shared   buff/cache   available
Mem: 503 118    175       201    209            181
Swap: 19 1     18

b.配置HugePages后,“buff/cache”下降95%,“空閑”內(nèi)存顯著增加

b. after configuring HugePages, 'buff/cache' drops by 95% and 'free' memory increase considerably

free -g
total   used   free   shared   buff/cache   available
Mem: 503    210    283       0         10              291
Swap: 19 1      18

(3)數(shù)據(jù)庫配置

sga_target=2Gb
sessions=500

a.如果沒有HugePages,在500個(gè)連接會(huì)話的情況下,PageTables會(huì)消耗機(jī)器物理內(nèi)存中的2.5Gb

a. without HugePages, with 500 connected sessions, PageTables consumes 2.5Gb from the physical memory of the machine

grep PageTables /proc/meminfo
PageTables: 2617248 kB

b.配置HugePages后,在500個(gè)連接會(huì)話的情況下,PageTables僅消耗機(jī)器物理內(nèi)存中的200Mb

b. after configuring HugePages, with 500 connected sessions, PageTables consumes only 200Mb from the physical memory of the machine

grep PageTables /proc/meminfo
PageTables: 226364 kB

啟用HugePages后,系統(tǒng)使用更少的PageTables,從而減少了維護(hù)和訪問它們的開銷。

Huge pages仍然固定在內(nèi)存中,不會(huì)被替換,因此內(nèi)核交換守護(hù)進(jìn)程在管理它們時(shí)沒有任何工作要做,內(nèi)核也不需要為它們執(zhí)行頁面表查找。

較少的頁面數(shù)量減少了執(zhí)行內(nèi)存操作所涉及的開銷,也降低了訪問頁面表時(shí)出現(xiàn)瓶頸的可能性。

如果沒有HugePages,操作系統(tǒng)會(huì)將每個(gè)4KB(通常為默認(rèn)頁面大?。┑膬?nèi)存作為一個(gè)頁面,當(dāng)它被分配給SGA時(shí),該頁面的生命周期(dirty, free、映射到進(jìn)程等)會(huì)由操作系統(tǒng)內(nèi)核保持最新,因此會(huì)產(chǎn)生性能問題。

所以:

IF
SGA >= 2GB AND sessions >= 500
THEN
enabling HugePages becomes a requirement on Linux 64-bit system.

五、使用HugePages性能提升多大

下面的性能測試來自大佬"徐sir的IT之路"公眾號(hào)的《如何正確的在AIX 7.x系統(tǒng)中開啟LargePage for Oracle》文章,原文鏈接如下:

如何正確的在AIX 7.x系統(tǒng)中開啟LargePage for Oracle

數(shù)據(jù)庫版本:oracle 11.2.0.4
操作系統(tǒng):AIX 7.2
服務(wù)器配置:POWER S914,1CPU,128G內(nèi)存
內(nèi)存儲(chǔ)配置:SGA65G+PGA20G
磁盤:華為S5500V5 雙活,128G緩存,每個(gè)存儲(chǔ)上24塊SAS 1.8T盤,RAID10陣列,劃分了3塊600G磁盤,使用了華為的多路徑軟件。

(1)未開啟16M大頁時(shí),500用戶swingbench OE v1模型測試結(jié)果

圖片

(2)開啟16M大頁后,500用戶swingbenchOE v1模型測試結(jié)果

圖片圖片

比較下TPS由3386提升到4444,總體提升約31%左右,測試僅供參考。

六、HugePages配置的限制

Restrictions for HugePages Configurations

HugePages有以下限制:

HugePages has the following limitations:

1.必須取消設(shè)置MEMORY_TARGET和MEMORY_MAX_TARGET初始化參數(shù)。

例如,要取消設(shè)置數(shù)據(jù)庫實(shí)例的參數(shù),請使用命令A(yù)LTER SYSTEM RESET。

You must unset both the MEMORY_TARGET and MEMORY_MAX_TARGET initialization parameters.
For example, to unset the parameters for the database instance, use the command ALTER SYSTEM RESET.

2.自動(dòng)內(nèi)存管理(AMM)和HugePages不兼容。

Automatic Memory Management (AMM) and HugePages are not compatible.

使用AMM時(shí),通過在/dev/shm下創(chuàng)建文件來分配整個(gè)SGA內(nèi)存。

當(dāng)Oracle數(shù)據(jù)庫使用AMM分配SGA時(shí),不保留HugePage。

Oracle 19C使用HugePages,必須禁用AMM(11g也需要禁用AMM)。

When you use AMM, the entire SGA memory is allocated by creating files under /dev/shm.
When Oracle Database allocates SGA with AMM, HugePages are not reserved.
To use HugePages on Oracle Database 19c, You must disable AMM.

3.如果在32位環(huán)境中使用VLM,則不能將HugePages用于Database Buffer cache。

您可以將HugePage用于SGA的其他部分,如shared_pool、large_pool等。

VLM(buffer cache)的內(nèi)存分配是使用共享內(nèi)存文件系統(tǒng)(ramfs/tmpfs/shmfs)完成的。

內(nèi)存文件系統(tǒng)不保留或使用HugePages。

If you are using VLM in a 32-bit environment, then you cannot use HugePages for the Database Buffer cache.
You can use HugePages for other parts of the SGA, such as shared_pool, large_pool, and so on.
Memory allocation for VLM (buffer cache) is done using shared memory file systems (ramfs/tmpfs/shmfs).
Memory file systems do not reserve or use HugePages.

4.除非系統(tǒng)管理員通過修改可用頁面數(shù)或修改池大小來更改HugePages配置,否則系統(tǒng)啟動(dòng)后不會(huì)分配或釋放HugePages。

如果在系統(tǒng)啟動(dòng)期間內(nèi)存中沒有保留所需的空間,則HugePages分配失敗。

HugePages are not subject to allocation or release after system startup, unless a system administrator changes the HugePages configuration, either by modifying the number of pages available, or by modifying the pool size.
If the space required is not reserved in memory during system startup, then HugePages allocation fails.

5.確保HugePages配置正確,因?yàn)槿绻麘?yīng)用程序未使用過多的HugePage,系統(tǒng)可能會(huì)耗盡內(nèi)存。

Ensure that HugePages is configured properly as the system may run out of memory if excess HugePages is not used by the application.

6.如果實(shí)例啟動(dòng)時(shí)HugePages不足,并且初始化參數(shù)use_large_pages設(shè)置為only,則數(shù)據(jù)庫無法啟動(dòng),并且會(huì)顯示一條警報(bào)日志消息,提供有關(guān)HugePages的必要信息。

If there is insufficient HugePages when an instance starts and the initialization parameter use_large_pages is set to only, then the database fails to start and an alert log message provides the necessary information on Hugepages.

七、參考鏈接

官方文檔位置:

Home / Database / Oracle Database Online Documentation 11g, Release 2 (11.2) / Database Administration / Database Administrator's Reference / G.2 Overview of HugePages

11g版本:

https://docs.oracle.com/cd/E11882_01/server.112/e10839/appi_vlm.htm#UNXAR385

19C版本:

https://docs.oracle.com/en/database/oracle/oracle-database/19/unxar/administering-oracle-database-on-linux.html#GUID-95CAEFDE-489B-453A-B5D5-4461DABBEEAD

其他:

Oracle Linux: Shell Script to Calculate Values Recommended Linux HugePages / HugeTLB Configuration(Doc ID 401749.1)
Oracle Linux: HugePages What It Is... and What It Is Not... (Doc ID 361323.1)
When And Why To Use HugePages on Linux x86-64? (Doc ID 2314903.1)
https://mp.weixin.qq.com/s?__biz=MzU0NTU1MzI5MQ==&mid=2247487446&idx=1&sn=0f1824462605f8c32ca711a68dcfd0ab&chksm=fb6a6132cc1de824a17cdd5e5c4a6596f6e0bb5a59fd955415123b188170fd1efd87b0a06891&mpshare=1&scene=24&srcid=0306G78oREb2qf1UN3etAF2V&sharer_shareinfo=636c40a2be34d2f77a73a414678736fa&sharer_shareinfo_first=da8e314bc06332f4854601ead7b59776#rd

八、hugepages_settings.sh腳本內(nèi)容

#!/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 the overall 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" ;;
    '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" ;;
    '4.14') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
    '5.4') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
    *) echo "Kernel version $KERN is not supported by this script (yet). Exiting." ;;
esac


# End
責(zé)任編輯:武曉燕 來源: IT小Chen
相關(guān)推薦

2020-08-17 17:47:30

內(nèi)存技術(shù)測試

2010-10-28 15:15:08

oracle內(nèi)存參數(shù)

2014-07-18 14:10:07

WIFI華為

2010-04-06 12:39:15

Oracle數(shù)據(jù)庫

2013-09-24 15:19:28

甲骨文Oracle數(shù)據(jù)庫

2009-07-30 18:22:14

OracleTimesTenIn-Memory D

2009-01-07 09:22:00

2010-09-14 11:29:43

谷歌

2013-07-22 09:43:29

2010-12-21 09:50:57

Ping交換機(jī)端口端口故障

2013-01-15 10:30:45

Windows 8Metro

2010-01-12 09:25:17

Windows 7死機(jī)系統(tǒng)特效

2010-05-27 17:10:03

MySQL數(shù)據(jù)庫內(nèi)存

2023-02-10 09:21:31

PG數(shù)據(jù)庫內(nèi)存

2009-08-01 15:47:04

網(wǎng)線故障

2023-12-24 22:33:32

宕機(jī)Twitter馬斯克

2009-07-18 16:43:09

光纖鏈路故障接線端面臟污

2012-12-12 09:57:12

Chrome負(fù)載均衡

2010-07-08 09:53:57

SQL Server

2009-12-30 13:26:48

點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)