Linux 如何調整虛擬記憶體大小

2021-06-28 11:09:24 字數 2050 閱讀 1971

我用的centos, 直接貼操作步驟,供參考:

[root@1pad ~]# free -m

total       used       free     shared    buffers     cached

mem:          3702        722       2979          0        149        230

-/+ buffers/cache:        342       3359

swap:         3839          0       3839

[root@1pad ~]# cd /home

[root@1pad home]# pwd

/home

[root@1pad home]# dd if=/dev/zero of=swapfile bs=4096 count=15728640                              #(新的虛擬記憶體大小 = bs * count bytes)

15728640+0 records in

15728640+0 records out

64424509440 bytes (64 gb) copied, 478.958 s, 135 mb/s

[root@1pad home]# ls

alex  swapfile

[root@1pad home]# /sbin/mkswap swapfile

mkswap: swapfile: warning: don't erase bootbits sectors

on whole disk. use -f to force.

setting up swapspace version 1, size = 62914556 kib

no label, uuid=a029accb-6676-48cb-ba7d-d31b9e84be37

[root@1pad home]# /sbin/swapon swapfile

[root@1pad home]# /sbin/swapon -s

filename                                type            size    used    priority

/dev/dm-1                               partition       3932152 236     -1

/home/swapfile                          file            62914552        0       -2

[root@1pad home]# free -m

total       used       free     shared    buffers     cached

mem:          3702       3565        137          0        138       2972

-/+ buffers/cache:        453       3248

swap:        65279          0      65279

[root@1pad home]# vim /etc/fstab                             #在fstab結尾加入如下兩行,目的是為了讓新建立的swap分割槽在電腦重啟後能夠自動掛載

#expand the swap space---alex tian, jan. 27th, 2015

/home/swapfile swap swap defaults 0 0

最後檢查/etc/rc.d/rc.local指令碼中是否將所有fstab中要求掛載的swap分割槽都給關閉。

如果是的話,將其中的swapoff -a注釋或者刪掉。

調整伺服器的虛擬記憶體大小

最近在計算一例瀰漫性結節時,出現了由於記憶體不足導致演算法服務重啟的問題,從而出現了肺結節無結果的故障。除了通過土豪加物理記憶體來解決的方法外,其實可以有0成本的解決方案 增大伺服器的虛擬記憶體。在家裡一台32g的伺服器上,原來虛擬記憶體只有1g,跑瀰漫性結節會出現演算法服務重啟。通過增加虛擬記憶體...

調整虛擬記憶體

調整虛擬記憶體 虛擬記憶體一般由程序 檔案系統快取以及核心消耗。虛擬記憶體的使用由很多因素決定,受以下引數影響 引數值可為 0 100,控制系統 swap 的程式。高數值可優先系統效能,在程序不活躍時主動將其轉換出物理記憶體。低數值可優先互動性並盡量避免將程序轉換處物理記憶體,並降低反應延遲。預設值...

檢視linux記憶體大小

用free m檢視的結果 free m total used free shared buffers cached mem 504 471 32 0 19 269 buffers cache 183 321 swap 996 0 996 檢視 proc kcore檔案的大小 ll h proc kc...