我的 Linux 正在使用大量交换,即使交换率很低并且有充足的可用空间

我的 Linux 正在使用大量交换,即使交换率很低并且有充足的可用空间
cat /proc/meminfo
---------
MemTotal:        7990416 kB
MemFree:         2094352 kB
MemAvailable:    2506396 kB
Buffers:              44 kB
Cached:          1040004 kB
SwapCached:       144332 kB
Active:          1947668 kB
Inactive:         699264 kB
Active(anon):    1898344 kB
Inactive(anon):   580272 kB
Active(file):      49324 kB
Inactive(file):   118992 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:       9437172 kB
SwapFree:         803596 kB
Dirty:                40 kB
Writeback:             0 kB
AnonPages:       1462784 kB
Mapped:           928188 kB
Shmem:            871688 kB
Slab:            2190580 kB
SReclaimable:     557436 kB
SUnreclaim:      1633144 kB
KernelStack:       55904 kB
PageTables:       144848 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:    13432380 kB
Committed_AS:    8070896 kB
VmallocTotal:   34359738367 kB
VmallocUsed:      134996 kB
VmallocChunk:   34359548340 kB
HardwareCorrupted:     0 kB
AnonHugePages:    114688 kB
CmaTotal:              0 kB
CmaFree:               0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:      350144 kB
DirectMap2M:     6989824 kB
DirectMap1G:     3145728 kB

 free -m
-----
            total        used        free      shared  buff/cache   available
Mem:           7803        2553        2083         838        3166        2463
Swap:          9215        8464         751

--
 cat /proc/sys/vm/swappiness
30

答案1

由于可用mem约为30%,因此vm swappiness值为30。

更改交换值:

编辑或创建文件 /etc/sysctl.d/99-sysctl.conf

vm.swappiness=5

https://wiki.archlinux.org/index.php/Swap#Swappiness

相关内容