MISCONF Redis配置为保存RDB快照

本文翻译自:MISCONF Redis is configured to save RDB snapshots

During writes to Redis ( SET foo bar ) I am getting the following error: 在写入Redis( SET foo bar )期间,出现以下错误:

MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. MISCONF Redis配置为保存RDB快照,但当前无法持久保存在磁盘上。 Commands that may modify the data set are disabled. 禁用了可能修改数据集的命令。 Please check Redis logs for details about the error. 请检查Redis日志以获取有关该错误的详细信息。

Basically I understand that the problem is that redis is not able to save data on the disk, but have no idea how to get rid of the problem. 基本上,我了解到问题在于redis无法将数据保存在磁盘上,但是不知道如何解决该问题。

Also the following question has the same problem, it is abandoned long time ago with no answers and most probably no attempts to solve the problem. 同样,以下问题也有相同的问题,它很久以前就被抛弃了,没有答案,很可能没有尝试解决该问题。


#1楼

参考:https://stackoom.com/question/1K9vX/MISCONF-Redis配置为保存RDB快照


#2楼

Thanks everyone for checking the problem, apparently the error was produced during bgsave . 感谢大家检查问题,显然错误是在bgsave期间bgsave

For me, typing config set stop-writes-on-bgsave-error no in a shell and restarting Redis solved the problem. 对我来说,在shell中键入config set stop-writes-on-bgsave-error no并重新启动Redis解决了该问题。


#3楼

In case you encounter the error and some important data cannot be discarded on the running redis instance (problems with permissions for the rdb file or its directory incorrectly, or running out of disk space), you can always redirect the rdb file to be written somewhere else. 如果遇到错误,并且一些重要数据无法在正在运行的Redis实例上丢弃(存在对rdb文件或其目录的权限不正确的问题,或者磁盘空间不足),则始终可以重定向将rdb文件写入某处其他。

Using redis-cli , you can do something like this: 使用redis-cli ,您可以执行以下操作:

CONFIG SET dir /tmp/some/directory/other/than/var
CONFIG SET dbfilename temp.rdb

After this, you might want to execute a BGSAVE command to make sure that the data will be written to the rdb file. 此后,您可能要执行BGSAVE命令以确保将数据写入rdb文件。 Make sure that when you execute INFO , bgsave_in_progress is already 0 (either the operation is successful or there is an error encountered). 确保执行INFObgsave_in_progress已经为0 (操作成功或遇到错误)。 After that, you can now start backing up the generated rdb file somewhere safe. 之后,您现在可以在安全的地方开始备份生成的rdb文件。


#4楼

There might be errors during the bgsave process due to low memory. 由于内存不足,在bgsave过程中可能会出错。 Try this (from redis background save FAQ) 试试看(从Redis后台保存常见问题解答)

echo 'vm.overcommit_memory = 1' >> /etc/sysctl.conf
sysctl vm.overcommit_memory=1

#5楼

Using redis-cli , you can stop it trying to save the snapshot: 使用redis-cli ,可以尝试保存快照来停止它:

config set stop-writes-on-bgsave-error no

This is a quick workaround, but if you care about the data you are using it for, you should check to make sure why bgsave failed in first place. 这是一个快速的解决方法,但是如果您关心要使用它的数据,则应检查以确保bgsave首先失败的原因。


#6楼

in case you are working on a linux machine, also recheck the file and folder permissions of the database. 如果您在Linux机器上工作,还请重新检查数据库的文件和文件夹权限。

The db and the path to it can be obtained via: 可以通过以下方式获取数据库及其路径:

in redis-cli : redis-cli

CONFIG GET dir 配置获取目录

CONFIG GET dbfilename 配置获取dbfilename

and in the commandline ls -l . 并在命令行ls -l The permissions for the directory should be 755 , and those for the file should be 644 . 目录的权限应为755 ,文件的权限应为644 Also, normally redis-server executes as the user redis , therefore its also nice to give the user redis the ownership of the folder by executing sudo chown -R redis:redis /path/to/rdb/folder . 另外,通常redis-server会以用户redis身份执行,因此也可以通过执行sudo chown -R redis:redis /path/to/rdb/folder给用户redis文件夹的所有权。 This has been elaborated in the answer here . 这已经在这里的答案中得到了阐述。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值