查看Redis后臺,有如下錯誤日志:
1 [2963] 07 Sep 09:15:07.053 * 10 changes in 300 seconds. Saving
2 [2963] 07 Sep 09:15:07.055 * Background saving started by pid 3143
3 [3143] 07 Sep 09:15:07.058 # Failed opening .rdb for saving: Permission denied
4 [2963] 07 Sep 09:15:07.156 # Background saving error

根據(jù)提示,可以看出是權(quán)限問題。
進入redis.conf配置文件。
搜索dir,找到如下內(nèi)容:

 1 # The working directory.
 2 #
 3 # The DB will be written inside this directory, with the filename specified
 4 # above using the 'dbfilename' configuration directive.
 5 # 
 6 # The Append Only File will also be created inside this directory.
 7 # 
 8 # Note that you must specify a directory here, not a file name.
 9 dir ./

如果是./表示:運行reides命令的目錄(例如,$redis_home中,執(zhí)行./bin/redis-server etc/redis.conf命令,./則代表的是$redis_home)。

查看當前用戶對dir所配置的路徑是否有寫權(quán)限。

調(diào)整權(quán)限后,應(yīng)該能看到如下信息:

1 [3223] 07 Sep 09:29:57.007 * 10 changes in 300 seconds. Saving
2 [3223] 07 Sep 09:29:57.008 * Background saving started by pid 3270
3 [3270] 07 Sep 09:29:57.028 * DB saved on disk
4 [3270] 07 Sep 09:29:57.029 * RDB: 6 MB of memory used by copy-on-write
5 [3223] 07 Sep 09:29:57.112 * Background saving terminated with success

表示成功寫入磁盤文件,即該問題解決。
現(xiàn)在查看dir所配置的目錄下應(yīng)該有dump.rdb文件。