"lack of free swap space"告警處理,自動掛載swap
阿新 • • 發佈:2018-11-01
[[email protected] ~]# free -h
total used free shared buff/cache available
Mem: 991M 636M 199M 47M 155M 174M
Swap: 0B 0B 0B
[[email protected] ~]# dd if=/dev/zero of=/tmp/vmfile bs=2M count=1024
1024+0 records in
1024+0 records out
2147483648 bytes (2.1 GB) copied, 39.5264 s, 54.3 MB/s
[[email protected] ~]# du -sh /tmp/vmfile
2.1G /tmp/vmfile
[[email protected] ~]# mkswap -f /tmp/vmfile
Setting up swapspace version 1, size = 2097148 KiB
no label, UUID=28904d6d-29e8-4932-8ec2-f9c038fab25c
[ [email protected] ~]# swapon /tmp/vmfile
swapon: /tmp/vmfile: insecure permissions 0644, 0600 suggested.
[[email protected] ~]# free -h
total used free shared buff/cache available
Mem: 991M 637M 66M 47M 287M 151M
Swap: 2.0G 0B 2.0G
[ [email protected] ~]#
[[email protected] ~]# vi /etc/fstab
/tmp/vmfile swap swap defaults 0 0
此時zabbix上的告警顯示“已解決”
但是當reboot後,swap又消失了,告警再次出現
[[email protected] ~]# swapon -a #重讀/etc/fstab檔案,使新swap分割槽掛載
swapon: /tmp/vmfile: insecure permissions 0644, 0600 suggested.
[[email protected] ~]# swapon -s
Filename Type Size Used Priority
/tmp/vmfile file 2097148 0 -1
但解決不了reboot後不自動掛載
- 解決辦法如下
[[email protected] ~]# vi /etc/rc.d/rc.local
/usr/sbin/swapon /tmp/vmfile
當在reboot後,swap將自動掛載成功
[[email protected] ~]# reboot
Last login: Sat Oct 13 15:26:03 2018 from 49.80.240.5
[[email protected] ~]# free -h
total used free shared buff/cache available
Mem: 991M 471M 162M 26M 358M 337M
Swap: 2.0G 0B 2.0G
[[email protected] ~]#