Redis 解决MISCONF Redis is configured to save RDB snapshots, but is currently not able to

本文探讨了Redis在尝试保存RDB快照时遇到的问题及其原因,并提供了两种解决方案:一是临时禁用错误报告,二是调整系统配置以确保Fork操作成功。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Redis 错误内容:

MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk. Commands that may modify the data set are disabled, because this instance is configured to report errors during writes if RDB snapshotting fails (stop-writes-on-bgsave-error option). Please check the Redis logs for details about the RDB error.

Redis被配置为保存数据库快照,但它目前不能持久化到硬盘。用来修改集合数据的命令不能用。请查看Redis日志的详细错误信息。

出错原因:

强制关闭Redis快照导致不能持久化

解决方法:

stop-writes-on-bgsave-error 设置为 no ,该方法只能忽略错误

在 Redis-cli  客户端执行

127.0.0.1:6379> config set stop-writes-on-bgsave-error no

参考自:http://www.jianshu.com/p/3aaf21dd34d6

             http://www.cnblogs.com/qq78292959/p/3994349.html

查看 Redis 日志 ,提示“Can’t save in background: fork: Cannot allocate memory”,这个提示很明显"Fork进程时内存不够用了!"(还是内存的问题)。

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

解决方法:

/etc/sysctl.conf 添加一项 'vm.overcommit_memory = 1' ,然后重启(或者运行命令'sysctl vm.overcommit_memory=1' )使其生效。)

转载于:https://my.oschina.net/esdn/blog/1489079

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值