Redis:Failed opening .rdb for saving: Permission denied 解决方案

解决Redis权限错误
部署运行你感兴趣的模型镜像

先贴图,我自己遇到的问题如下:




从图中很容易可以看出是后台保存数据时出错。并提示尝试打开“.rdb”文件被拒绝。


公司环境搭建用到了Redis,但是自己使用过程中遇到了一些问题,就是在更新数据的时候,Redis一直报错,导致服务端一直反馈500错误。


因为还在实习阶段,还不是很熟悉Redis的配置以及相关开发,一开始以为是我自己安装的Redis有问题,但是网上看了安装的博客,自己也查看了一下自己的安装过程,发现没什么大事。但只要遇到更新数据的操作,就会报错,苦苦寻找半小时,发现是自己的启动方式不对!!!真是一个不该有的错误。


先说说我的原因吧:

我将redis的启动文件redis.conf 复制到了 /etc/redis 目录下(我自己创建的),

接着因为项目绑定的是其他端口(如:5555),我便有复制了一份redis.conf 改名为5555.conf,并将端口也改为了5555(可在文件中找到port对应的值)。

然后每次启动redis的时候就总是先进入这个目录,然后在当前目录下执行redis启动命令:redis-server [5555.conf] ,后面是可以指定启动文件的。

接着就是运行项目,错误就如上述所说。


下面是解决方案:

1、在/usr 目录下执行:find . -name "redis.conf" ,我们会发现在:/usr/local/etc 目录下有redis.conf 文件(可能你的电脑不一样哟),

然后我将他的权限改为了 755 (如果你想启动某个配置文件,就将他改的权限改为这个)。

2、找到你项目对应的 xxx.rdb 文件,将其权限也改为 755 。

3、现在便可以进入上述目录:/usr/local/etc 执行:redis-server [redis.conf] 即可正常运行。

下面是我正常运行后,更新数据的结果截图:





stackoverflow 解决方案:

http://stackoverflow.com/questions/22160753/redis-failed-opening-rdb-for-saving-permission-denied


您可能感兴趣的与本文相关的镜像

ComfyUI

ComfyUI

AI应用
ComfyUI

ComfyUI是一款易于上手的工作流设计工具,具有以下特点:基于工作流节点设计,可视化工作流搭建,快速切换工作流,对显存占用小,速度快,支持多种插件,如ADetailer、Controlnet和AnimateDIFF等

journalctl -u redis.service -- Logs begin at 二 2025-10-14 08:39:10 CST, end at 二 2025-10-14 09:10:01 CST. -- 10月 14 08:39:19 localhost.localdomain systemd[1]: Starting Redis persistent key-value database... 10月 14 08:39:19 localhost.localdomain redis-server[1245]: 1245:C 14 Oct 2025 08:39:19.532 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 10月 14 08:39:19 localhost.localdomain redis-server[1245]: 1245:C 14 Oct 2025 08:39:19.532 * Redis version=7.2.5, bits=64, commit=00000000, modified=0, pid=1245, just started 10月 14 08:39:19 localhost.localdomain redis-server[1245]: 1245:C 14 Oct 2025 08:39:19.532 * Configuration loaded 10月 14 08:39:19 localhost.localdomain redis-server[1245]: 1245:M 14 Oct 2025 08:39:19.534 * monotonic clock: POSIX clock_gettime 10月 14 08:39:19 localhost.localdomain redis-server[1245]: 1245:M 14 Oct 2025 08:39:19.537 # Failed to write PID file: Permission denied 10月 14 08:39:19 localhost.localdomain redis-server[1245]: 1245:M 14 Oct 2025 08:39:19.537 * Running mode=standalone, port=6379. 10月 14 08:39:19 localhost.localdomain redis-server[1245]: 1245:M 14 Oct 2025 08:39:19.537 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. 10月 14 08:39:19 localhost.localdomain redis-server[1245]: 1245:M 14 Oct 2025 08:39:19.538 * Server initialized 10月 14 08:39:19 localhost.localdomain redis-server[1245]: 1245:M 14 Oct 2025 08:39:19.538 * Ready to accept connections tcp 10月 14 08:39:49 localhost.localdomain systemd[1]: redis.service start operation timed out. Terminating. 10月 14 08:39:49 localhost.localdomain redis-server[1245]: 1245:signal-handler (1760402389) Received SIGTERM scheduling shutdown... 10月 14 08:39:49 localhost.localdomain redis-server[1245]: 1245:M 14 Oct 2025 08:39:49.273 * User requested shutdown... 10月 14 08:39:49 localhost.localdomain redis-server[1245]: 1245:M 14 Oct 2025 08:39:49.273 * Saving the final RDB snapshot before exiting. 10月 14 08:39:49 localhost.localdomain redis-server[1245]: 1245:M 14 Oct 2025 08:39:49.273 # Failed opening the temp RDB file temp-1245.rdb (in server root dir /) for saving: Permission denied 10月 14 08:39:49 localhost.localdomain redis-server[1245]: 1245:M 14 Oct 2025 08:39:49.273 # Error trying to save the DB, can't exit. 10月 14 08:39:49 localhost.localdomain redis-server[1245]: 1245:M 14 Oct 2025 08:39:49.273 # Errors trying to shut down the server. Check the logs for more information. 10月 14 08:41:19 localhost.localdomain systemd[1]: redis.service stop-sigterm timed out. Killing. 10月 14 08:41:19 localhost.localdomain systemd[1]: redis.service: control process exited, code=killed status=9 10月 14 08:41:19 localhost.localdomain systemd[1]: Failed to start Redis persistent key-value database. 10月 14 08:41:19 localhost.localdomain systemd[1]: Unit redis.service entered failed state. 10月 14 08:41:19 localhost.localdomain systemd[1]: redis.service failed. 10月 14 08:56:49 localhost.localdomain systemd[1]: Starting Redis persistent key-value database... 10月 14 08:56:49 localhost.localdomain systemd[1]: redis.service: control process exited, code=exited status=1 10月 14 08:56:49 localhost.localdomain systemd[1]: Failed to start Redis persistent key-value database. 10月 14 08:56:49 localhost.localdomain systemd[1]: Unit redis.service entered failed state. 10月 14 08:56:49 localhost.localdomain systemd[1]: redis.service failed. 10月 14 08:59:38 localhost.localdomain systemd[1]: Starting Redis persistent key-value database... 10月 14 08:59:38 localhost.localdomain redis-server[11598]: 11598:C 14 Oct 2025 08:59:38.899 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 10月 14 08:59:38 localhost.localdomain redis-server[11598]: 11598:C 14 Oct 2025 08:59:38.899 * Redis version=7.2.5, bits=64, commit=00000000, modified=0, pid=11598, just started 10月 14 08:59:38 localhost.localdomain redis-server[11598]: 11598:C 14 Oct 2025 08:59:38.899 * Configuration loaded 10月 14 08:59:38 localhost.localdomain redis-server[11598]: 11598:M 14 Oct 2025 08:59:38.899 * monotonic clock: POSIX clock_gettime 10月 14 08:59:38 localhost.localdomain redis-server[11598]: 11598:M 14 Oct 2025 08:59:38.900 # Failed to write PID file: Permission denied 10月 14 08:59:38 localhost.localdomain redis-server[11598]: 11598:M 14 Oct 2025 08:59:38.900 * Running mode=standalone, port=6379. 10月 14 08:59:38 localhost.localdomain redis-server[11598]: 11598:M 14 Oct 2025 08:59:38.900 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. 10月 14 08:59:38 localhost.localdomain redis-server[11598]: 11598:M 14 Oct 2025 08:59:38.900 * Server initialized 10月 14 08:59:38 localhost.localdomain redis-server[11598]: 11598:M 14 Oct 2025 08:59:38.900 * Ready to accept connections tcp 10月 14 09:00:09 localhost.localdomain systemd[1]: redis.service start operation timed out. Terminating. 10月 14 09:00:09 localhost.localdomain redis-server[11598]: 11598:signal-handler (1760403609) Received SIGTERM scheduling shutdown... 10月 14 09:00:09 localhost.localdomain redis-server[11598]: 11598:M 14 Oct 2025 09:00:09.160 * User requested shutdown... 10月 14 09:00:09 localhost.localdomain redis-server[11598]: 11598:M 14 Oct 2025 09:00:09.160 * Saving the final RDB snapshot before exiting. 10月 14 09:00:09 localhost.localdomain redis-server[11598]: 11598:M 14 Oct 2025 09:00:09.160 # Failed opening the temp RDB file temp-11598.rdb (in server root dir /) for saving: Permission denied 10月 14 09:00:09 localhost.localdomain redis-server[11598]: 11598:M 14 Oct 2025 09:00:09.160 # Error trying to save the DB, can't exit. 10月 14 09:00:09 localhost.localdomain redis-server[11598]: 11598:M 14 Oct 2025 09:00:09.160 # Errors trying to shut down the server. Check the logs for more information. 10月 14 09:01:39 localhost.localdomain systemd[1]: redis.service stop-sigterm timed out. Killing. 10月 14 09:01:39 localhost.localdomain systemd[1]: redis.service: control process exited, code=killed status=9 10月 14 09:01:39 localhost.localdomain systemd[1]: Failed to start Redis persistent key-value database. 10月 14 09:01:39 localhost.localdomain systemd[1]: Unit redis.service entered failed state. 10月 14 09:01:39 localhost.localdomain systemd[1]: redis.service failed. 10月 14 09:03:02 localhost.localdomain systemd[1]: Starting Redis persistent key-value database... 10月 14 09:03:02 localhost.localdomain redis-server[11726]: 11726:C 14 Oct 2025 09:03:02.569 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 10月 14 09:03:02 localhost.localdomain redis-server[11726]: 11726:C 14 Oct 2025 09:03:02.569 * Redis version=7.2.5, bits=64, commit=00000000, modified=0, pid=11726, just started 10月 14 09:03:02 localhost.localdomain redis-server[11726]: 11726:C 14 Oct 2025 09:03:02.569 * Configuration loaded 10月 14 09:03:02 localhost.localdomain redis-server[11726]: 11726:M 14 Oct 2025 09:03:02.570 * monotonic clock: POSIX clock_gettime 10月 14 09:03:02 localhost.localdomain redis-server[11726]: 11726:M 14 Oct 2025 09:03:02.570 # Failed to write PID file: Permission denied 10月 14 09:03:02 localhost.localdomain redis-server[11726]: 11726:M 14 Oct 2025 09:03:02.570 * Running mode=standalone, port=6379. 10月 14 09:03:02 localhost.localdomain redis-server[11726]: 11726:M 14 Oct 2025 09:03:02.571 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. 10月 14 09:03:02 localhost.localdomain redis-server[11726]: 11726:M 14 Oct 2025 09:03:02.571 * Server initialized 10月 14 09:03:02 localhost.localdomain redis-server[11726]: 11726:M 14 Oct 2025 09:03:02.571 * Ready to accept connections tcp 10月 14 09:03:32 localhost.localdomain systemd[1]: redis.service start operation timed out. Terminating. 10月 14 09:03:32 localhost.localdomain redis-server[11726]: 11726:signal-handler (1760403812) Received SIGTERM scheduling shutdown... 10月 14 09:03:32 localhost.localdomain redis-server[11726]: 11726:M 14 Oct 2025 09:03:32.629 * User requested shutdown... 10月 14 09:03:32 localhost.localdomain redis-server[11726]: 11726:M 14 Oct 2025 09:03:32.629 * Saving the final RDB snapshot before exiting. 10月 14 09:03:32 localhost.localdomain redis-server[11726]: 11726:M 14 Oct 2025 09:03:32.630 # Failed opening the temp RDB file temp-11726.rdb (in server root dir /) for saving: Permission denied 10月 14 09:03:32 localhost.localdomain redis-server[11726]: 11726:M 14 Oct 2025 09:03:32.630 # Error trying to save the DB, can't exit. 10月 14 09:03:32 localhost.localdomain redis-server[11726]: 11726:M 14 Oct 2025 09:03:32.630 # Errors trying to shut down the server. Check the logs for more information.
最新发布
10-15
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值