>>分享Java编程技术,对《Java面向对象编程》等书籍提供技术支持 书籍支持  卫琴直播  品书摘要  在线测试  资源下载  联系我们
发表一个新主题 开启一个新投票 回复文章 您是本文章第 22456 个阅读者 刷新本主题
 * 贴子主题:  redis持久化问题处理 回复文章 点赞(0)  收藏  
作者:flybird    发表时间:2020-01-27 13:41:53     消息  查看  搜索  好友  邮件  复制  引用

  
这个是最近在开发的过程中遇到的问题,因为需要频繁使用redis作为中间查询操作,突然故障了,服务中止,然后抛出异常    
2020-01-09 09:34:17.848 ERROR 25703 --- [ XNIO-2 task-83] o.z.p.spring.web.advice.AdviceTrait      : Internal Server Error

org.springframework.data.redis.RedisSystemException: Error in execution; nested exception is io.lettuce.core.RedisCommandExecutionException: MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the 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:257)
    at org.springframework.data.redis.connection.lettuce.LettuceHashCommands.convertLettuceAccessException(LettuceHashCommands.java:445)
    at org.springframework.data.redis.connection.lettuce.LettuceHashCommands.hSet(LettuceHashCommands.java:70)
    at org.springframework.data.redis.connection.DefaultedRedisConnection.hSet(DefaultedRedisConnection.java:827)
    at org.springframework.data.redis.connection.DefaultStringRedisConnection.hSet(DefaultStringRedisConnection.java:501)
    at org.springframework.data.redis.core.DefaultHashOperations.lambda$put$8(DefaultHashOperations.java:178)
    at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:224)
    at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:184)
    at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:95)
    at org.springframework.data.redis.core.DefaultHashOperations.put(DefaultHashOperations.java:177)
    at com.smpteam.aaaa.service.impl.RedisServiceImpl.setESSession(RedisServiceImpl.java:59)
    at com.smpteam.aaaa.service.impl.RedisServiceImpl$$FastClassBySpringCGLIB$$11b51629.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
    . . .
Caused by: io.lettuce.core.RedisCommandExecutionException: MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.

  然后我通过

redis-cli

登录redis服务器检查情况,发现ping不通
点击在新窗口中浏览原图
CTRL+鼠标滚轮放大或缩小
(error) MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.
这提示及其友好,虽长但我喜欢:)

Redis问题

MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.

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

原因

强制关闭Redis快照导致不能持久化。本质上是内存不足导致的。因此需要进行相关的内存处理:
  1. 修改redis config
  2. 修改快照备份的目录,即将快照重定向到其他目录
  3. 修改主机内存配置

解决方案1

将stop-writes-on-bgsave-error设置为no,这个方式是直接关闭保存持久化快照    

127.0.0.1:6379> config set stop-writes-on-bgsave-error no

  这个在生产中可能会出现一些问题,这个然而这个方法治标不治本,他只是让我们“忽略”他而已,使用之前需要确认

bgsave

失败的原因,比如当redis用于缓存、会话的场景的时候,这么做是允许的
点击在新窗口中浏览原图
CTRL+鼠标滚轮放大或缩小

解决方案2

将备份的rdb文件,重定向到目录    

CONFIG SET dir /tmp/some/directory/other/than/var
CONFIG SET dbfilename temp.rdb

  使用这个命令之后,需要确保

bgsave_in_progress

返回结果是

0

解决方案3

在内核运行时动态地修改内核的运行参数    

echo 'vm.overcommit_memory = 1' >> /etc/sysctl.conf
sysctl vm.overcommit_memory=1

----------------------------
原文链接:https://blog.51cto.com/yerikyu/2466490

程序猿的技术大观园:www.javathinker.net



[这个贴子最后由 sunweiqin 在 2020-01-28 12:11:17 重新编辑]
  Java面向对象编程-->面向对象开发方法概述之UML语言(下)
  JavaWeb开发-->Servlet技术详解(Ⅱ)
  JSP与Hibernate开发-->JPA API的高级用法
  Java网络编程-->Java网络编程入门
  精通Spring-->通过Vuex进行状态管理
  Vue3开发-->通过Axios访问服务器
  CRMEB_Java新零售社交电商系统
  利用堆栈将中缀表达式转换成后缀表达式
  求素数
  BIO、NIO和AIO的区别、三种IO的原理与用法
  BIO和NIO区别
  Java并发编程的总结与思考
  Eclipse和MyEclipse的区别
  64匹马,8个赛道,找出跑得最快的4匹马
  Java方法的嵌套与递归调用
  最实用的10个重构小技巧排行榜,你都用过哪些?
  Java并发之volatile关键字内存可见性问题
  java万年历简单制作
  超详细的Java运算符修炼手册(优秀程序员不得不知道的运算技...
  Java设计模式:装饰器模式
  Java入门实用代码:向文件写入字符串
  更多...
 IPIP: 已设置保密
楼主      
1页 1条记录 当前第1
发表一个新主题 开启一个新投票 回复文章


中文版权所有: JavaThinker技术网站 Copyright 2016-2026 沪ICP备16029593号-2
荟萃Java程序员智慧的结晶,分享交流Java前沿技术。  联系我们
如有技术文章涉及侵权,请与本站管理员联系。