前提:今天发现某台主机一直报警:swap内存被用光

1、查看了服务器的内存情况【发现在物理内存还剩余的情况下,swap开始被使用,甚至到被用光】
[root@note1 ~]# free -h
total used free shared buff/cache available
Mem: 15G 4.9G 169M 141M 10G 10G
Swap: 4.0G 3.4G 651M

2、查看swappiness文件的值
[root@note1 ~]# cat /proc/sys/vm/swappiness
30

说明:在centos里面,swappiness的值的大小对如何使用swap分区是有着很大的联系的。
swappiness=0的时候表示最大限度使用物理内存,然后才是 swap空间;
swappiness=100的时候表示积极的使用swap分区,并且把内存上的数据及时的搬运到swap空间里面。
两个极端,对于Centos的默认设置,这个值等于60,建议修改为10。

3、修改swappiness的值
[root@note1 ~]# sysctl vm.swappiness=10
vm.swappiness = 10

#修改配置文件,确保重启后不恢复为默认值
[root@note1 ~]# echo vm.swappiness=10 >> /etc/sysctl.conf

4、重启swap
//关闭虚拟内存
[root@note1 ~]# swapoff -a

//开启虚拟内存
[root@note1 ~]# swapon -a

5、再次查看内存情况
//关闭swap后内存情况
[root@note1 ~]# free -h
total used free shared buff/cache available
Mem: 15G 7.7G 165M 393M 7.6G 7.0G
Swap: 0B 0B 0B

// 重启swap后
[root@note1 ~]# free -h
total used free shared buff/cache available
Mem: 15G 7.7G 165M 393M 7.6G 7.0G
Swap: 4.0G 0B 4.0G

参考链接:https://blog.51cto.com/davidbj/1172879

cetos报错“Lack of free swap space” 解决方法的更多相关文章

  1. zabbix server监控报主机 Lack of free swap space

    zabbix server监控报主机 Lack of free swap space,因为交换空间不足引起.该主机内存为3G,正常交换空间大小为物理内存2倍左右. #查看已有内存及交换空间 free ...

  2. linux下svn客户端报错Cannot negotiate authentication mechanism的解决方法

    svn客户端报错Cannot negotiate authentication mechanism的解决方法: 问题出现的原因之一: 因为SVN服务器配置了saslauthd服务用来实现与ldap的对 ...

  3. 安装PHP过程中,make步骤报错:(集合网络上各种解决方法)

    安装PHP过程中,make步骤报错:(集合网络上各种解决方法) (1)-liconv -o sapi/fpm/php-fpm /usr/bin/ld: cannot find -liconv coll ...

  4. 关于163发邮件报错535 Error:authentication failed解决方法

    关于发邮件报错535 Error:authentication failed解决方法 调用163邮箱服务器来发送邮件,我们需要开启POP3/SMTP服务,这时163邮件会让我们设置客户端授权码,这个授 ...

  5. shell报错:-bash: [: ==: 期待一元表达式 解决方法 ([: ==: unary operator expected)

    shell报错:-bash: [: ==: 期待一元表达式 解决方法 ([: ==: unary operator expected) blogdaren 2015-02-26  抢沙发 14916人 ...

  6. tomcat启动报错java.lang.OutOfMemoryError:PermGen space解决办法

    tomcat启动错误提示: 严重: Error waiting for multi-thread deployment of WAR files to completejava.util.concur ...

  7. zabbix监控报错zabbix server is not running解决方法

    问题描述: 布置好zabbix监控,正常运行.但是重启了虚拟机服务器之后,页面出现如下的报错,而且设置的报信息也是失效的:

  8. python安装locustio报错error: invalid command 'bdist_wheel'的解决方法

    locust--scalable user load testing tool writen in Python(是用python写的.规模化.可扩展的测试性能的工具) 安装locustio需要的环境 ...

  9. Linux服务器init 5启动图形界面,报错Retrigger failed udev events的解决方法

    1.开启linux系统的桌面环境,使用startx未成功,报如下错误: 提示:Retrigger failed udev events [root@ /]# startx xauth: creatin ...

随机推荐

  1. Spring Security教程之基于表达式的权限控制(九)

    目录 1.1      通过表达式控制URL权限 1.2      通过表达式控制方法权限 1.2.1     使用@PreAuthorize和@PostAuthorize进行访问控制 1.2.2   ...

  2. 删除list集合中某些数据

    去除list集合中不符合条件的数据 List<DictVo> applyStateList = SingletonHoldResource.getInstance().getList(Fr ...

  3. 【技术博客】使用PhpStorm和Xdebug实现Laravel工程的远程开发及调试

    目录 使用PhpStorm和Xdebug实现Laravel工程的远程开发及调试 简介 PhpStorm中的远程开发 1. 配置服务器 2. 配置路径对应 3. 配置同步 4. 进行代码同步 5. 优点 ...

  4. HashMap源码2

    public class test { @SuppressWarnings({ "rawtypes", "unchecked" }) public static ...

  5. Jenkins绑定git

    1,新建任务

  6. java的this关键字

    class point{ int x; int y; point(int x,int y){ this.x=x;//如果形参和属性名相同,为了区分开来,必须要在属性名前加this y=y;//若不加t ...

  7. [转帖]Kubernetes v1.17 版本解读 | 云原生生态周报 Vol. 31

    Kubernetes v1.17 版本解读 | 云原生生态周报 Vol. 31 https://www.kubernetes.org.cn/6252.html 2019-12-13 11:59 ali ...

  8. AntDesign vue学习笔记(九)自定义文件上传

    第七节时提到,上传文件时实际可能需要传输一个token. 1.查看vue antdesign文档https://vue.ant.design/components/upload-cn/ 2.使用cus ...

  9. 第十五节:Asp.Net Core中的各种过滤器(授权、资源、操作、结果、异常)

    一. 简介 1. 说明 提到过滤器,通常是指请求处理管道中特定阶段之前或之后的代码,可以处理:授权.响应缓存(对请求管道进行短路,以便返回缓存的响应). 防盗链.本地化国际化等,过滤器用于横向处理业务 ...

  10. Docker 制作定制asp.netcore 的容器

    上文Windows docker k8s asp.net core的k8swebap镜像只是一个asp.net core程序,在实际生产中我们希望容器中还有一些其他程序,比如ssh 和telegraf ...