Skip to content

Instantly share code, notes, and snippets.

@dolt131943
Created September 24, 2017 06:50
Show Gist options
  • Save dolt131943/b9aba295697035f4e9f10a43d3435182 to your computer and use it in GitHub Desktop.
Save dolt131943/b9aba295697035f4e9f10a43d3435182 to your computer and use it in GitHub Desktop.
redis更改快照dump目录问题,redis change snapshot dump dir error.

Ubuntu想更改redis快照保存目录,打开/etc/redis/redis.conf,修改了dir为新的目录. 重启服务后,发现报错,保存数据失败.

进入redis-cli

config get dir save

提示ERR

查看异常信息

cat /var/log/redis/redis-server.log

Failed opening .rdb for saving: Read-only file system

经google,发现还要更改systemd的配置,打开/etc/systemd/system/redis.service,更改其中原来的数据目录为新的数据目录: ReadWriteDirectories=-/newpath

此时可在redis-cli中暂存数据,避免重启服务后导致数据丢失.

config set dir /old_dump_path save

此时应该会提示OK成功.

然后再重启,重启服务后问题解决. 看来Systemd里启动的进程有对目录访问权限进行了设置.这个设置可以覆盖系统的设置.!!!待考!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment