"lack of free swap space"告警处理,自动挂载swap

在这里插入图片描述

[root@zabbix ~]# free -h
              total        used        free      shared  buff/cache   available
Mem:           991M        636M        199M         47M        155M        174M
Swap:            0B          0B          0B
[root@zabbix ~]# 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
[root@zabbix ~]# du -sh /tmp/vmfile 
2.1G    /tmp/vmfile

[root@zabbix ~]# mkswap -f /tmp/vmfile 
Setting up swapspace version 1, size = 2097148 KiB
no label, UUID=28904d6d-29e8-4932-8ec2-f9c038fab25c

[root@zabbix ~]# swapon /tmp/vmfile
swapon: /tmp/vmfile: insecure permissions 0644, 0600 suggested.
[root@zabbix ~]# free -h
              total        used        free      shared  buff/cache   available
Mem:           991M        637M         66M         47M        287M        151M
Swap:          2.0G          0B        2.0G
[root@zabbix ~]# 
[root@zabbix ~]# vi /etc/fstab
/tmp/vmfile swap swap defaults 0 0

此时zabbix上的告警显示“已解决”

但是当reboot后,swap又消失了,告警再次出现

[root@zabbix ~]# swapon -a	#重读/etc/fstab文件,使新swap分区挂载
swapon: /tmp/vmfile: insecure permissions 0644, 0600 suggested.
[root@zabbix ~]# swapon -s
Filename                                Type            Size    Used    Priority
/tmp/vmfile                             file    2097148 0       -1

但解决不了reboot后不自动挂载

  • 解决办法如下
[root@zabbix ~]# vi /etc/rc.d/rc.local 
/usr/sbin/swapon /tmp/vmfile

当在reboot后,swap将自动挂载成功

[root@zabbix ~]# reboot

Last login: Sat Oct 13 15:26:03 2018 from 49.80.240.5
[root@zabbix ~]# free -h
              total        used        free      shared  buff/cache   available
Mem:           991M        471M        162M         26M        358M        337M
Swap:          2.0G          0B        2.0G
[root@zabbix ~]# 

在这里插入图片描述

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值