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

关于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

 

posted @ 2018-09-20 16:44 StimmerLove 阅读( ...) 评论( ...) 编辑 收藏
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值