linux引數之/proc/sys/vm詳解
/proc/sys/vm
該目錄下的檔案用來最佳化虛擬記憶體
比較重要的引數如下
justin_$ uname -a
Linux justin 2.6.32-100.26.2.el5 #1 SMP Tue Jan 18 20:11:49 EST 2011 x86_64 x86_64 x86_64 GNU/Linux
Swappiness
justin_$ more swappiness
60
--範圍從0—100,因為即便有足夠空餘實體記憶體,linux也會將部分長期沒有用到的頁swap,該值越高則linux越傾向於此;
vfs_cache_pressure
預設值100,用於控制回收cache頻率,值越小則越傾向於保留cache,0 表示從不回收cache容易導致out-of-memory
注:cache用於快取inode/dentry,而buffer用於快取data
justin_$ more vfs_cache_pressure
100
stat_interval
VM資訊更新頻率,預設每1秒更新一次
justin_$ more stat_interval
1
hugetlb_shm_group
指定group id,擁有該gid的使用者可以使用huge page建立SysV共享記憶體段;
注:使用者可透過2種方式使用huge page
Mmap:使用此API時,如果沒有指定MAP_HUGETLB選項,系統必須載入hugetlbfs檔案系統到/mnt/huge
SYSV共享記憶體system call(shmget/shmat):呼叫此API則需要配置hugetlb_shm_group
如果oracle使用了huge page且透過shm*呼叫,則將該值設為oracle使用者的gid,否則可能會遭遇ORA-27125
ORA-27125: unable to create shared memory segment
Cause: shmget() call failed
Action: contact Oracle support
justin_$ more hugetlb_shm_group
0
http://www.kernel.org/doc/Documentation/vm/hugetlbpage.txt
nr_hugepages
huge頁的最小數目,需要連續的實體記憶體;oracle使用hugepage可以降低TLB的開銷,節約記憶體和CPU資源,但要同時設定memlock且保證其大於hugepage;其與11gAMM不相容;
# - memlock - max locked-in-memory address space (KB)
顯然此係統分配了hugepage但沒有程式使用
justin_$ more nr_hugepages
5120
justin_$ more /proc/meminfo | grep -i huge
HugePages_Total: 5120
HugePages_Free: 5120
HugePages_Rsvd: 0
HugePages_Surp: 0 –當請求的頁數超過nr_hugepages時可額外申請的頁數,最大值由nv_overcommit_hugepages引數控制
Hugepagesize: 2048
http://www.kernel.org/doc/Documentation/vm/hugetlbpage.txt
nr_overcommit_hugepages
系統可分配最大huge page數= nr_hugepages + nr_overcommit_hugepages
justin_$ more nr_overcommit_hugepages
0
mmap_min_addr
指定使用者程式透過mmap可使用的最小虛擬記憶體地址,以避免其在低地址空間產生對映導致安全問題;如果非0,則不允許mmap到NULL頁,而此功能可在出現NULL指標時除錯Kernel;mmap用於將檔案對映至記憶體;
該設定意味著禁止使用者程式訪問low 4k地址空間
justin_$ more mmap_min_addr
4096
http://justanothergeek.chdir.org/2011/01/linux-security-one-year-later.html
https://blogs.oracle.com/ksplice/entry/much_ado_about_null_exploiting1
panic_on_oom
用於控制如何處理out-of-memory,可選值包括0/1/2,預設為0
0:當記憶體不足時核心呼叫OOM killer殺死一些rogue程式,每個程式描述符都有一個oom_score標示,oom killer會選擇oom_score較大的程式
1/2:記憶體不足時不殺死程式,但具體策略有所差異
justin_$ more panic_on_oom
0
oom_kill_allocating_task
控制如何kill觸發OOM的程式,可選值包括0/non-0,受panic_on_oom值影響
0:OOM killer掃描所有的程式尋找oom_score最高的,可透過將其kill釋放大量記憶體
Non-0:kill出發out-of-memory的那個程式,避免程式佇列掃描
justin_$ more oom_kill_allocating_task
0
lowmem_reserve_ratio
保留的lowmem,3列分別為DMA/normal/HighMem
justin_$ more lowmem_reserve_ratio
256 256 32
dirty_background_bytes/ dirty_background_ratio
當記憶體中髒頁達到一定數量或比例時,啟用pdflush將其重新整理至磁碟,兩者只能取其一;
[oracle@usuwsoadb05 vm]$ more dirty_background_bytes
0
[oracle@usuwsoadb05 vm]$ more dirty_background_ratio
10
dirty_bytes/ dirty_ratio
當程式的髒資料達到某個臨界點則該程式自動將其重新整理至磁碟,dirty_ratio是與整個系統記憶體相除
justin_$ more dirty_bytes
0
justin_$ more dirty_ratio
20
drop_caches
預設為0,可選值包括1/2/3
1:釋放頁快取,即buffer
2:是否inode和dentries快取,即cache
3:包含1和2
注:由於buffer/cache裡的值
justin_$ more drop_caches
0
max_map_count
一個程式最多可用於的記憶體對映區(memory map areas),在呼叫malloc會用到,由mmap/mprotect生成
Memory map areas are used as a side-effect of calling malloc, directly by mmap and mprotect, and also when loading shared libraries.
大部分程式使用數量不會超過1000,預設值65536
注:該值若太小某些情況下會導致ora-4030,詳情參照ID 1325100.1,
當4030跟蹤檔案的process map dump記錄如下,此時max_map_cout設定為65536導致資源不足 ,可適當調大
----- Process Map Dump -----
00400000-0954f000 r-xp 00000000 fd:09 3131376 /e00/oracle/prod/v11.2.0/bin/oracle <<
0974e000-0a2be000 rwxp 0914e000 fd:09 3131376 /e00/oracle/prod/v11.2.0/bin/oracle
0a2be000-0a304000 rwxp 0a2be000 00:00 0
0c8c9000-0c950000 rwxp 0c8c9000 00:00 0 [heap]
60000000-60001000 r-xs 00000000 00:13 9374560 /dev/shm/ora_DSSP_11698195_0
60001000-70000000 rwxs 00001000 00:13 9374560 /dev/shm/ora_DSSP_11698195_0
70000000-80000000 rwxs 00000000 00:13 9374561 /dev/shm/ora_DSSP_11698195_1
80000000-90000000 rwxs 00000000 00:13 9374565 /dev/shm/ora_DSSP_11730964_0
90000000-a0000000 rwxs 00000000 00:13 9374566 /dev/shm/ora_DSSP_11730964_1
a0000000-b0000000 rwxs 00000000 00:13 9374569 /dev/shm/ora_DSSP_11763733_0
b00
2aed84a4f000-2aed86e5f000 rwxp febe2000 00:11 29160 /dev/zero
7fffea3ca000-7fffea418000 rwxp 7ffffffb1000 00:00 0 [stack]
ffffffffff600000-ffffffffffe00000 ---p 00000000 00:00 0 [vdso] <
******************* End of process map dump ***********
justin_$ more max_map_count
65530
http://www.cppblog.com/feixuwu/archive/2011/05/14/146395.html
nr_pdflush_threads
當前pdfflush執行緒數量,為read-only,系統會根據髒頁數自動調整,1秒增加1個直至nr_pdflush_threads_max;
justin_$ more nr_pdflush_threads
0
overcommit_memory
為一個flag,可選值包括0/1/2,用於控制記憶體過度分配
0:當使用者空間請求更多記憶體時,核心則評估當前空閒記憶體量,如果足夠則分配
1:核心假定系統中始終有足夠的記憶體直至耗盡為止
2:核心採用”never overcommit”策略,以避免記憶體被耗盡
有很多程式呼叫malloc()請求大量記憶體卻很少使用,該引數則十分有用
justin_$ more overcommit_memory
0
overcommit_ratio
該值為實體記憶體比率,當overcommit_memory=2時,程式可使用的swap空間不可超過PM * overcommit_ratio/100
justin_$ more overcommit_ratio
50
page-cluster
一次寫入swap的記憶體頁數=2的page-cluster次方,若該值為0則一次寫入1個頁,為1
justin_$ more page-cluster
3
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15480802/viewspace-753757/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【kernel】從 /proc/sys/net/ipv4/ip_forward 引數看如何玩轉 procfs 核心引數Forward
- linux 程式引數檔案 /proc/pid/cmdline 簡介Linux
- Linux網路卡配置檔案 引數詳解Linux
- tomcat vm 引數設定Tomcat
- linux下/proc/meminfo解讀Linux
- OGG引數詳解
- ajax 引數詳解
- percona-tools 之 pt-kill 引數詳解
- java 之泛型與可變引數詳解Java泛型
- Linux 核心引數 arp_ignore & arp_announce 詳解Linux
- lsblk命令引數詳解
- tar命令引數詳解
- Dockerfile - 引數與詳解Docker
- 函式引數詳解函式
- Flink Checkpoint 引數詳解
- 【Linux】bash: /proc/sys/net/ipv4/ip_forward: 許可權不夠LinuxForward
- Nginx編譯引數大全 configure引數中文詳解Nginx編譯
- Oracle GoldenGate常用引數詳解OracleGo
- oracle rac 核心引數詳解Oracle
- 常用的 wget 引數詳解wget
- variables_order引數詳解
- Prometheus hashmod 配置引數詳解Prometheus
- pg_settings引數詳解
- SQL*Plus Set引數詳解SQL
- find 命令的引數詳解
- linux之kill命令詳解Linux
- 詳解Linux bash變數Linux變數
- Linux下nginx編譯安裝教程和編譯引數詳解LinuxNginx編譯
- Pandas read_csv 引數詳解
- Nginx 配置檔案引數詳解Nginx
- Redis日常運維-引數詳解Redis運維
- expdp/impdp 詳細引數解釋
- ansible.cfg 配置引數詳解
- curl常用引數詳解及示例
- JQuery中$.ajax()方法引數詳解jQuery
- plt.figure()引數使用詳解
- caffe網路各層引數詳解
- composer.json 檔案引數詳解JSON
- consul配置引數大全、詳解、總結