SpringBoot + redis. 程序隔一段时间会莫名其妙的报Redis的错误. 报错如下:

org.springframework.data.redis.RedisSystemException: Redis exception; nested exception is io.lettuce.core.RedisException: java.io.IOException: Connection reset by peer

百度得知说: 是因为redis默认快照是关闭的, 导致了Redis连接不能持久化,通过stop-writes-on-bgsave-error值设置为no 可避免这种问题。

有两种设置方式:

  1. 通过命令修改的方式:
127.0.0.1:6379> config set stop-writes-on-bgsave-error no
  1. 修改redis.conf文件
    vim或者vi 编辑redis.conf, 找到stop-writes-on-bgsave-error配置设置为no即可.
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐