• 关于redis  WARNING overcommit_memory is set to 0 的问题解决


    1. 报错信息:

     WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf 
      and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.

           警告超委托内存设置为0!后台保存可能在低内存条件下失败。要解决此问题,请将“vm.overcommit_.=1”添加到/etc/sysctl.conf,然后重新启动或运行命令“sysctl vm.overcommit_.=1”,以使其生效。

    2. 解决办法:

               其实报错信息中已经给出了处理办法,进入到/etc/sysctl.conf文件中,将vm.overcommit_.=1添加到sysctl.conf文件中就可以了。

               有两种方法可以实现:

               2.1   执行命令:echo 1 > /proc/sys/vm/overcommit_memory,可能用一般用户没办法执行该命令,那就直接su root,使用root用户执行命令就行了。该命令的优点是直接生效,不用重启redis服务,缺点是如果redis服务重启就会继续报该错误,需要再次执行上述命令

    root@iZbp1bz2wge6lwlpy5kw8sZ:/var/log/redis # sudo echo 1 > /proc/sys/vm/overcommit_memory

               2.2    进入/etc/sysctl.conf文件中,添加vm.overcommit_.=1,重启之后,报错就会消失;该方法的优点是无论以后如何重启redis服务都不会再报该错误,缺点是不能立即生效,必须重启redis服务。

    vm.overcommit_memory=1

      思考:

            以后遇到redis报错,可以先去查看redis的错误日志,一般位于/var/log/redis/redis-server.log,如果没有记日志文件,可以进入redis的配置文件中添加logfile logfilePath,注意日志文件要有写的权限

    # Specify the log file name. Also the empty string can be used to force
    # Redis to log on the standard output. Note that if you use standard
    # output for logging but daemonize, logs will be sent to /dev/null
    logfile /var/log/redis/redis-server.log

     

    有罪是符合人性的,但长期坚持不改就是魔鬼。
  • 相关阅读:
    dynamic_cast
    struct 字节对齐详解
    CentOS修改系统的默认启动模式为命令号界面
    linux系统备份还原
    linux 缺少libxxx.a 静态链接库
    linux下SVN忽略文件/文件夹的方法
    取消svn add
    centos 中文乱码解决办法2
    安装rpm包时遇到error: Failed dependencies:错误
    Linux rpm 命令参数使用详解[介绍和应用]
  • 原文地址:https://www.cnblogs.com/yu-yuan/p/9681725.html
Copyright © 2020-2023  润新知