topを見ると。
top - 22:39:48 up 244 days, 23:54, 1 user, load average: 0.00, 0.01, 0.05
Tasks: 82 total, 2 running, 80 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 1016780 total, 249264 free, 546088 used, 221428 buff/cache
KiB Swap: 0 total, 0 free, 0 used. 257548 avail Mem # ← swapが0になっている。
→swapがない。
2Gのswap領域を作る
[user1@server1 ~]$ ll /s
sbin/ srv/ sys/
[user1@server1 ~]$ sudo dd if=/dev/zero of=/swap bs=1M count=2048
2048+0 records in
2048+0 records out
2147483648 bytes (2.1 GB) copied, 15.9838 s, 134 MB/s
[user1@server1 ~]$ ll /s
sbin/ srv/ swap sys/
[user1@server1 ~]$ ll /s
sbin/ srv/ swap sys/
[user1@server1 ~]$ sudo mkswap /swap
Setting up swapspace version 1, size = 2097148 KiB
no label, UUID=85d63f02-cc26-40ab-bc40-f92b0b698543
[user1@server1 ~]$ sudo swapon /swap
swapon: /swap: insecure permissions 0644, 0600 suggested.
[user1@server1 ~]$ sudo chmod 0600 /swap
[user1@server1 ~]$ ll / | grep swap
-rw-------. 1 root root 2147483648 Mar 13 22:41 swap
top - 22:45:18 up 245 days, 0 min, 1 user, load average: 0.01, 0.04, 0.05
Tasks: 81 total, 2 running, 79 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 1016780 total, 68808 free, 542788 used, 405184 buff/cache
KiB Swap: 2097148 total, 2097148 free, 0 used. 253468 avail Mem
→swap できた。
再起動したときに自動でswapが有効になる設定
[user1@server1 ~]$ sudo vim /etc/fstab
/swapfile none swap sw 0 0
を追加