笔记:解决redis连接错误:MISCONF Redis is configured to save RDB snapshots, but it is currently not able to

今天redis突然报错,缓存不能存入,导致登录接口出现问题,后续的查验token接口都没查到redis的token。

cache 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.

查了原因是因为使用了rdb持久化,redis在保存数据到磁盘是为了防止主线程假死,会fock一个子进程来完成这个操作,而这个子进程需要分配和主进程相同的内存,即内存翻倍,导致在申请内存时不被允许。
解决方式:
编辑/etc/sysctl.conf ,改vm.overcommit_memory=1
然后sysctl -p使配置文件生效

链接1
链接2

你可能感兴趣的:(笔记:解决redis连接错误:MISCONF Redis is configured to save RDB snapshots, but it is currently not able to)