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

发布时间 2023-06-08 14:50:49作者: 肖建锋

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 可避免这种问题。

有两种设置方式:

通过命令修改的方式:
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即可.