告警信息

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_memory = 1”添加到/etc/sysctl.conf,然后重新启动或运行命令“sysctl vm.overcommit_memory=1”使其生效。

解决办法

方式一:执行“echo 1 > /proc/sys/vm/overcommit_memory”命令,如果没有权限执行该命令需要切换至root账户,执行su root命令使用root用户。这会使其立即生效,不用重启redis服务,但是如果redis服务重启后还会报错误,需要再次执行上述命令。

方式二:彻底解决Redis中overcommit_memory is set to 0!告警问题,编辑/etc/sysctl.conf文件,添加net.core.somaxconn = 1024然后执行sysctl -p命令查看是否添加成功,之后重启Redis服务即可。

[root@mrwang redis-4.0.9]# vim /etc/sysctl.conf 
[root@mrwang redis-4.0.9]# sysctl -p            
vm.swappiness = 0
kernel.sysrq = 1
net.ipv4.neigh.default.gc_stale_time = 120
net.ipv4.conf.all.rp_filter = 0
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.default.arp_announce = 2
net.ipv4.conf.lo.arp_announce = 2
net.ipv4.conf.all.arp_announce = 2
net.ipv4.tcp_max_tw_buckets = 5000
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_syn_backlog = 1024
net.ipv4.tcp_synack_retries = 2
vm.overcommit_memory = 1

来源:https://blog.yoodb.com/yoodb/article/detail/1722

更多详细内容。

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐