0927hugepages與nr_overcommit_hugepages
[20170927]hugepages與核心引數nr_overcommit_hugepages.txt
/proc/sys/vm/nr_overcommit_hugepages specifies how large the pool of huge pages can grow, if more huge pages than
/proc/sys/vm/nr_hugepages are requested by applications. Writing any non-zero value into this file indicates that the
hugetlb subsystem is allowed to try to obtain that number of "surplus" huge pages from the kernel's normal page pool,
when the persistent huge page pool is exhausted. As these surplus huge pages become unused, they are freed back to the
kernel's normal page pool.
--//從上面的說明可以看出設定這個引數可以減少hagepages的使用,避免設定過大導致的浪費.
--//我以前提到引數use_large_pages可以設定auto.參考連結:
--// [20170313]11G use_large_pages引數.txt => http://blog.itpub.net/267265/viewspace-2135210/
--// [20170516]11G use_large_pages引數2.txt => http://blog.itpub.net/267265/viewspace-2145480/
--//我提到設定引數use_large_pages=auto,雖然/etc/sysctl.conf配置vm.nr_hugepages = 105.
--//但是可以透過oradism命令啟動修改核心引數.但是如果關閉資料庫,我的測試配置的hugepage不會回收.
--//測試設定nr_overcommit_hugepages會發生什麼情況?
1.環境:
# cat /proc/version
Linux version 2.6.39-300.26.1.el5uek (mockbuild@ca-build56.us.oracle.com) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-52)) #1 SMP Thu Jan 3 18:31:38 PST 2013
# cat /proc/sys/vm/nr_overcommit_hugepages
0
--//預設是0.
# cat /proc/meminfo | grep -i hugepage
AnonHugePages: 0 kB
HugePages_Total: 305
HugePages_Free: 96
HugePages_Rsvd: 96
HugePages_Surp: 200
Hugepagesize: 2048 kB
--//資料庫配置情況:
SCOTT@book> show sga
Total System Global Area 634732544 bytes
Fixed Size 2255792 bytes
Variable Size 197133392 bytes
Database Buffers 427819008 bytes
Redo Buffers 7524352 bytes
SCOTT@book> show parameter use_large_pages
NAME TYPE VALUE
--------------- ------ -----
use_large_pages string AUTO
SYS@book> alter system set use_large_pages=only scope=spfile;
System altered.
--//如果引數為是Only,從含義上,表示Oracle例項只會使用HugePage作為記憶體使用。如果系統在AMM模式或者HugePage用盡的時候,數
--//據庫就不能啟動或者報錯。
--//關閉資料庫,修改/etc/sysctl.conf,再啟動看看:
SYS@book> shutdown immediate ;
Database closed.
Database dismounted.
ORACLE instance shut down.
--//修改/etc/sysctl.conf
vm.nr_hugepages = 105
vm.nr_overcommit_hugepages=1000
# sysctl -p
# cat /proc/meminfo | grep -i hugepage
AnonHugePages: 0 kB
HugePages_Total: 105
HugePages_Free: 105
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
--//現在HugePages_Total: 105
--//注意檢查修改/etc/security/limits.conf內容:
oracle soft memlock unlimited
oracle hard memlock unlimited
--//再啟動資料庫看看:
SYS@book> startup
ORACLE instance started.
Total System Global Area 634732544 bytes
Fixed Size 2255792 bytes
Variable Size 197133392 bytes
Database Buffers 427819008 bytes
Redo Buffers 7524352 bytes
Database mounted.
Database opened.
--//可以發現現在可以正常啟動!!檢查alert檔案:
Starting ORACLE instance (normal)
Specified value of sga_max_size is too small, bumping to 637534208
************************ Large Pages Information *******************
Parameter use_large_pages = ONLY
Per process system memlock (soft) limit = 51 GB
Total Shared Global Region in Large Pages = 610 MB (100%)
Large Pages used by this instance: 305 (610 MB)
Large Pages unused system wide = 0 (0 KB)
Large Pages configured system wide = 305 (610 MB)
Large Page size = 2048 KB
********************************************************************
--//可以發現我現在設定vm.nr_hugepages = 105,實際上使用305,但是資料庫可以正常啟動,而且use_large_pages = ONLY,也就是強制使
--//用hugepages.透過如下命令也可以發現:
# cat /proc/meminfo | grep -i hugepage
AnonHugePages: 0 kB
HugePages_Total: 305
HugePages_Free: 97
HugePages_Rsvd: 97
HugePages_Surp: 200
Hugepagesize: 2048 kB
SYS@book> shutdown immediate ;
Database closed.
Database dismounted.
ORACLE instance shut down.
# cat /proc/meminfo | grep -i hugepage
AnonHugePages: 0 kB
HugePages_Total: 105
HugePages_Free: 105
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
--//可以發現使用的hupepages回收了.也就是使用的記憶體空間回收了.這樣的使用方式,可以一定程度避免記憶體浪費.
3.繼續測試現在設定vm.nr_overcommit_hugepages=0.
--//修改/etc/sysctl.conf
vm.nr_hugepages = 105
vm.nr_overcommit_hugepages=0
# sysctl -p
# cat /proc/meminfo | grep -i hugepage
AnonHugePages: 0 kB
HugePages_Total: 105
HugePages_Free: 105
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
SYS@book> startup
ORA-27137: unable to allocate large pages to create a shared memory segment
Linux-x86_64 Error: 12: Cannot allocate memory
Additional information: 624951296
Additional information: 1
--//可以這樣無法獲得足夠的hugepages,資料庫無法啟動.修改回來後在啟動正常.
vm.nr_overcommit_hugepages=1000
總結:
透過設定這個引數,一定程度避免記憶體浪費,必須設定大的hugepages,而導致一些記憶體浪費,而且不使用時可以回收.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2145481/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- undefined與null與?. ??UndefinedNull
- &與&&, |與||區別
- 進與穩,時代與技術,新基建與華為雲
- 程式與執行緒、同步與非同步、阻塞與非阻塞、併發與並行執行緒非同步並行
- Promise與async/await與GeneratorPromiseAI
- in與exist , not in與not exist 的區別
- Python學習筆記 5.0 元組 與 字典 與 集合 與 公共操作 與 推導式Python筆記
- 聊聊執行緒與程式 & 阻塞與非阻塞 & 同步與非同步執行緒非同步
- jQuery與JavaScript與ajax三者的區別與聯絡jQueryJavaScript
- forms元件補充與ModelForm簡單使用與cookie與sessionORM元件CookieSession
- PHP 與 Swoole 淺析與學習PHP
- PySpark與GraphFrames的安裝與使用Spark
- PHPCookie與Session的使用與區別PHPCookieSession
- 同步與非同步 阻塞與非阻塞非同步
- define與typedef區別與聯絡
- WAS與IHS整合的安裝與配置
- Iterator與Iterable(迭代器與可迭代)
- 漏型與源型、PNP與NPN
- js == 與 ===JS
- Process與Socket,Select與Accept關係
- cookie與session的區別與聯絡CookieSession
- Java:運用while()與do....while與for()JavaWhile
- 陣列與字串方法與相互轉換陣列字串
- Session與Cookie的區別與聯絡SessionCookie
- cookie與session的自己思考與解釋CookieSession
- GRPC與 ProtoBuf 的理解與總結RPC
- 同步與阻塞的區別與聯絡
- 關於 in與exist , not in與not exist 的區別
- rpm與yum,at與crontab,sed命令使用
- 詳解not in與not exists的區別與用法
- memcache與memcached的區別與安裝
- 病毒預防與硬碟使用與維護硬碟
- UITableView與WKWebView的巢狀與適配UIWebView巢狀
- hive與hbase的聯絡與區別Hive
- JDBC與ODBC的區別與應用JDBC
- STATSPACK與AWR的相同點與區別
- onchange與onpropertychange的聯絡與區別!
- BS與CS的聯絡與區別