Redis "MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk"问题

今天在程序中,jedis put数据到redis过程中,“MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk”报错;

再查看Redis日志,看到有这样的错误提示“Can’t save in background: fork: Cannot allocate memory”,这个提示很明显"Fork进程时内存不够用了!",但内存明明还有一个多G;

经网上查询,Redis在保存数据到硬盘时为了避免主进程假死,需要Fork一份主进程,然后在Fork进程内完成数据保存到硬盘的操作,如果主进程使用了4GB的内存,Fork子进程的时候需要额外的4GB,此时内存就不够了,Fork失败,进而数据保存硬盘也失败了。

解决如下:

执行命令 sysctl vm.overcommit_memory=1

/etc/sysctl.conf 文件添加

vm.overcommit_memory=1

posted @ 2016-02-03 10:48  sl521100  阅读(2111)  评论(0编辑  收藏  举报