今天在redis中执行setrange name 1 chun 命令时报了如下错误提示:

(error) MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.

大意为:(错误)misconf redis被配置以保存数据库快照,但misconf redis目前不能在硬盘上持久化。用来修改数据集合的命令不能用,请使用日志的错误详细信息。

这是由于强制停止redis快照,不能持久化引起的,运行info命令查看redis快照的状态,如下:

解决方案如下:

连接redis后运行 config set stop-writes-on-bgsave-error no 命令

关闭配置项stop-writes-on-bgsave-error解决该问题。


今天第二次遇到Redis “MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk”的问题。这个错误信息是Redis客户端工具在保存数据时候抛出的异常信息。

网上查了一下,很多人都是建议“config set stop-writes-on-bgsave-error no”。这样做其实是不好的,这仅仅是让程序忽略了这个异常,使得程序能够继续往下运行,但实际上数据还是会存储到硬盘失败!

上一次遇到这个问题是因为一个程序的Bug造成系统内存被耗尽了,后来修复了那个Bug问题就解决了。今天出现问题时查看系统内存还有2GB左右,“感觉好像不是内存的缘故”(后面发现还是因为内存的缘故)。

由于Redis是daemon模式运行的,没法看到详细的日志。修改配置文件设置logfile参数为文件(默认是stdout,建议以后安装完毕就修改这个参数为文件,不然会丢掉很多重要信息),重启Redis,查看日志,看到程序启动时就有一行警告提示:
“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!在低内存环境下,后台保存可能失败。为了修正这个问题,请在/etc/sysctl.conf 添加一项 ‘vm.overcommit_memory = 1’ ,然后重启(或者运行命令’sysctl vm.overcommit_memory=1’ )使其生效。)

当时没明白意思,就忽略了。再启动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进程时内存不够用了!"(还是内存的问题)。

通过谷歌查询“Can’t save in background: fork: Cannot allocate memory”这个提示,找到了解决方法:

// 原文:http://pydelion.com/2013/05/27/redis-cant-save-in-background-fork-cannot-allocate-memory/
If you get this error  Can't save in background: fork: Cannot allocate memory  it means that your current database is bigger than memory you have. To fix the issue enable vm.overcommit_memory:  sysctl vm.overcommit_memory=1  To have if after reboot add this line to /etc/sysctl.cnf:  vm.overcommit_memory=1

修改vm.overcommit_memory=1后问题果然解决了。

为什么系统明明还剩2GB的内存,Redis会说内存不够呢?

网上查了一下,有人也遇到类似的问题,并且给出了很好的分析(详见:http://www.linuxidc.com/Linux/2012-07/66079.htm),简单地说:Redis在保存数据到硬盘时为了避免主进程假死,需要Fork一份主进程,然后在Fork进程内完成数据保存到硬盘的操作,如果主进程使用了4GB的内存,Fork子进程的时候需要额外的4GB,此时内存就不够了,Fork失败,进而数据保存硬盘也失败了。

redis错误:LOADING Redis is loading the dataset in memory

原因是,redis使用的内存超过操作系统一半的内存

查看文件占的内存

du -sh ./*|grep G
df -h

[230]连接Redis后执行命令错误 MISCONF Redis is configured to save RDB snapshots相关推荐

  1. 解决redis连接错误:MISCONF Redis is configured to save RDB snapshots, but it is currently not able to...

    今天重启游戏服务器在连接redis数据库时突然报错:MISCONF Redis is configured to save RDB snapshots, but it is currently not ...

  2. 解决redis连接错误:MISCONF Redis is configured to save RDB snapshots

    今天Redis服务器在连接redis数据库时突然报错:MISCONF Redis is configured to save RDB snapshots, but it is currently no ...

  3. redis数据库错误:MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persis

    转载自:解决redis连接错误:MISCONF Redis is configured to save RDB snapshots, but it is currently not able to.. ...

  4. Redis - MISCONF Redis is configured to save RDB snapshots 报RDB快照错误

    完整的报错信息: Error in execution; nested exception is io.lettuce.core.RedisCommandExecutionException: MIS ...

  5. MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk.

    MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk. ...

  6. MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk.

    一.错误信息 今天运行Redis时发生错误,错误信息如下: (error) MISCONF Redis is configured to save RDB snapshots, but is curr ...

  7. Redis_保存数据时报错MISCONF Redis is configured to save RDB snapshots, but it is curren

    Redis_保存数据时报错MISCONF Redis is configured to save RDB snapshots, but it is currently not able to pers ...

  8. 解决MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk

    1.起因 使用jeecgboot验证码登陆后台时,一直报验证码错误,看控制台发现是redis报错了,具体如下: Error in execution; nested exception is io.l ...

  9. MISCONF Redis is configured to save RDB snapshots, but it is currently not a

    开发环境最近遇到了"MISCONF Redis is configured to save RDB snapshots, but is currently not able to persi ...

最新文章

  1. Windows server2008修改远程桌面端口的方法
  2. v系列存储配置Linux多路径,linux下san存储多路径软件的配置
  3. c#如何通过ftp上传文件_ftp自动上传文件,如何设置ftp自动上传文件及环境配置...
  4. Python内置函数(30)——super
  5. 【Hibernate】Hibernate实体关系映射实例解析
  6. 密歇根大学团队成果:自动驾驶视觉系统——Bio-LSTM: 三维步行姿势和步态预测的生物力学反馈神经网络
  7. 实战:自定义简易版SpringBoot
  8. win10wifi间歇性断网重启后恢复_实用!Xbox Series X 在重启后也能快速恢复之前的游戏状态...
  9. “安全宝”,云安全服务
  10. 算法基础(八):超具体最优二叉树构建(1)
  11. 虚幻开放日2017ppt
  12. 未来手机、电脑和网络将整合为一块
  13. 删除指定天数文件,再删除所有的空目录批处理文件
  14. 关于IE样式兼容问题
  15. 怎么远程传输大文件?
  16. OpenCms for MySql安装
  17. Android下载安装Apk
  18. java中obj_Java中Object类的详细介绍
  19. 星际争霸2服务器未能创建游戏,星际争霸2游戏进不去解决方法
  20. QQ引流脚本,QQ扩列引流脚本实操演示

热门文章

  1. android 静态图片自动切换,Android静态图片人脸识别的完整demo(附完整源码)
  2. imac wifi 链接不了 dns查找失败 感叹号
  3. Invoke-customs are only supported starting with Android O (--min-api 26)
  4. 基于RisParity+BlackLitterman的因子择时
  5. Hashmap扩容方法机制原理
  6. Hough变换(含MATLAB实现)
  7. 我第一次成功安装CocoaPods的过程
  8. 兆讯科技冲刺科创板:年营收3.7亿 拟募资10亿
  9. VMware虚拟机仅主机模式访问外网
  10. linux下实现定时执行php脚本