Redis 自发失败:“无法打开 .rdb 进行保存:权限被拒绝”

Redis 自发失败:“无法打开 .rdb 进行保存:权限被拒绝”

我在 Rackspace Cloud Server 中的 Ubuntu 14.04 上运行 redis-server (版本 2.8.4)。 redis-server 进程由 redis 用户运行。

今天早上,Redis 服务器突然出现“无法打开 .rdb 进行保存”的错误。在此之前,该进程已经运行了 20 多天,没有发生任何意外。

从下面的日志片段中可以看出,Redis 运行正常,然后在 UTC 时间上午 8:08 左右开始出现故障。之后对服务器进行电源循环,问题得以解决。

[26083] 31 Aug 07:54:47.089 * RDB: 2 MB of memory used by copy-on-write
[17183] 31 Aug 07:54:47.186 * Background saving terminated with success
[17183] 31 Aug 07:59:48.028 * 10 changes in 300 seconds. Saving...
[17183] 31 Aug 07:59:48.029 * Background saving started by pid 26653
[26653] 31 Aug 07:59:48.032 * DB saved on disk
[26653] 31 Aug 07:59:48.032 * RDB: 2 MB of memory used by copy-on-write
[17183] 31 Aug 07:59:48.129 * Background saving terminated with success
[17183] 31 Aug 08:04:49.061 * 10 changes in 300 seconds. Saving...
[17183] 31 Aug 08:04:49.061 * Background saving started by pid 27197
[27197] 31 Aug 08:04:49.064 * DB saved on disk
[27197] 31 Aug 08:04:49.065 * RDB: 2 MB of memory used by copy-on-write
[17183] 31 Aug 08:04:49.162 * Background saving terminated with success
[17183] 31 Aug 08:07:56.881 * DB saved on disk
[17183] 31 Aug 08:08:05.880 # Failed opening .rdb for saving: Permission denied
[17183] 31 Aug 08:12:57.047 * 10 changes in 300 seconds. Saving...
[17183] 31 Aug 08:12:57.047 * Background saving started by pid 28087
[28087] 31 Aug 08:12:57.048 # Failed opening .rdb for saving: Permission denied
[17183] 31 Aug 08:12:57.148 # Background saving error
[17183] 31 Aug 08:13:03.068 * 10 changes in 300 seconds. Saving...
[17183] 31 Aug 08:13:03.069 * Background saving started by pid 28088
[28088] 31 Aug 08:13:03.070 # Failed opening .rdb for saving: Permission denied
[17183] 31 Aug 08:13:03.169 # Background saving error
[17183] 31 Aug 08:13:09.087 * 10 changes in 300 seconds. Saving...
[17183] 31 Aug 08:13:09.087 * Background saving started by pid 28089
[28089] 31 Aug 08:13:09.088 # Failed opening .rdb for saving: Permission denied
(... continues like this until server restart)

那么,我的问题是:这怎么可能发生?

我很困惑,但这是我的一些模糊的预感:

  • 内存使用率过高(我只运行了一个 512MB 的实例,Redis 警告我在 /etc/sysctl.conf 中设置“vm.overcommit_memory = 1”)
  • Redis 在连续运行 20 天后达到了某种内部限制(因此这种情况会在约 20 天内再次发生)。
  • Rackspace 在 UTC 时间早上 8 点(东部时间凌晨 4 点)做了一些事情,对我的服务器产生了一定影响。

答案1

运行redis-cli并查看CONFIG GET dbfilename输出CONFIG GET dir

我感觉这些可能已经改变。值应该分别是dump.rdb和类似的/var/lib/redis

如果它们发生了变化,则有人入侵了您的 redis 服务器。如果是这种情况,请检查您的 redis 服务是否向公众开放。您不应该能够从外部 IP 连接到它。

相关内容