前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >解决Redis报错Redis is configured to save RDB snapshots, but it is currently not able to persist on disk

解决Redis报错Redis is configured to save RDB snapshots, but it is currently not able to persist on disk

作者头像
程序新视界
发布2020-03-18 17:16:28
33.7K1
发布2020-03-18 17:16:28
举报
文章被收录于专栏:丑胖侠丑胖侠

Redis报错信息

在Spring Boot中集成Redis客户之后,进行数据操作,发现报如下错误:

代码语言:javascript
复制
org.springframework.data.redis.RedisSystemException: Error in execution; nested exception is io.lettuce.core.RedisCommandExecutionException: MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk. Commands that may modify the data set are disabled, because this instance is configured to report errors during writes if RDB snapshotting fails (stop-writes-on-bgsave-error option). Please check the Redis logs for details about the RDB error.

	at org.springframework.data.redis.connection.lettuce.LettuceExceptionConverter.convert(LettuceExceptionConverter.java:54)
	at org.springframework.data.redis.connection.lettuce.LettuceExceptionConverter.convert(LettuceExceptionConverter.java:52)
	at org.springframework.data.redis.connection.lettuce.LettuceExceptionConverter.convert(LettuceExceptionConverter.java:41)
	at org.springframework.data.redis.PassThroughExceptionTranslationStrategy.translate(PassThroughExceptionTranslationStrategy.java:44)
	at org.springframework.data.redis.FallbackExceptionTranslationStrategy.translate(FallbackExceptionTranslationStrategy.java:42)
	at org.springframework.data.redis.connection.lettuce.LettuceConnection.convertLettuceAccessException(LettuceConnection.java:270)
	at org.springframework.data.redis.connection.lettuce.LettuceStringCommands.convertLettuceAccessException(LettuceStringCommands.java:799)
	at org.springframework.data.redis.connection.lettuce.LettuceStringCommands.set(LettuceStringCommands.java:148)
	at org.springframework.data.redis.connection.DefaultedRedisConnection.set(DefaultedRedisConnection.java:281)
	at org.springframework.data.redis.core.DefaultValueOperations$3.inRedis(DefaultValueOperations.java:240)
	at org.springframework.data.redis.core.AbstractOperations$ValueDeserializingRedisCallback.doInRedis(AbstractOperations.java:60)
	at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:228)
	at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:188)
	at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:96)
	at org.springframework.data.redis.core.DefaultValueOperations.set(DefaultValueOperations.java:236)

报错原因

从Redis层面来分析错误的直接原因是:

Redis被配置为保存数据库快照,但它目前不能持久化到硬盘。用来修改集合数据的命令不能用。请查看Redis日志的详细错误信息。

也就是说,Redis无法将缓存中的数据写入本地磁盘。

针对Redis报错无法写入磁盘,往往有以下原因:

  • 磁盘满了
  • Redis配置问题
  • 操作权限问题

如果磁盘满了,直接清理磁盘或进行扩充即可。

解决方案

问题一

如果是权限问题,查看日志会发现如下日志:

代码语言:javascript
复制
11875:M 06 Mar 2020 09:00:12.034 * 1 changes in 3600 seconds. Saving...
11875:M 06 Mar 2020 09:00:12.035 * Background saving started by pid 12625
12625:C 06 Mar 2020 09:00:12.036 # Failed opening the RDB file dump.rdb (in server root dir /usr/local/redis-5.0.7) for saving: Permission denied

如果是权限问题,则服务对应目录的权限,或在配置文件中修改目标目录到有权限操作的目录。

默认目录配置如下:

代码语言:javascript
复制
# The filename where to dump the DB
dbfilename dump.rdb

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

修改下面的dir路径:

代码语言:javascript
复制
dir /Users/zzs/tools/dbs

然后重启即可。在重启的过程中可能依然由于无法保存数据而死循环,此时就需要杀手锏了。

问题二

如果是配置问题导致,则可进行如下修改。

使用redis-cli连接上redis,然后执行如下命令:

代码语言:javascript
复制
config set stop-writes-on-bgsave-error no

通过将stop-writes-on-bgsave-error设置为no来进行解决。但这种方案治标不治本,从根本上来讲,还是需要大家查看后台异常原因,进行有针对性的解决。

原文链接:《解决Redis报错Redis is configured to save RDB snapshots, but it is currently not able to persist on disk.

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Redis报错信息
  • 报错原因
  • 解决方案
    • 问题一
      • 问题二
      相关产品与服务
      云数据库 Redis
      腾讯云数据库 Redis(TencentDB for Redis)是腾讯云打造的兼容 Redis 协议的缓存和存储服务。丰富的数据结构能帮助您完成不同类型的业务场景开发。支持主从热备,提供自动容灾切换、数据备份、故障迁移、实例监控、在线扩容、数据回档等全套的数据库服务。
      领券
      问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档