這個是最近在開發的過程當中遇到的問題,由於須要頻繁使用redis做爲中間查詢操做,忽然故障了,服務停止,而後拋出異常java
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不通
(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.
這提示及其友好,雖長但我喜歡:)web
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日誌的詳細錯誤信息。spring
強制關閉Redis快照致使不能持久化。本質上是內存不足致使的。所以須要進行相關的內存處理:數據庫
將stop-writes-on-bgsave-error設置爲no,這個方式是直接關閉保存持久化快照緩存
127.0.0.1:6379> config set stop-writes-on-bgsave-error no
這個在生產中可能會出現一些問題,這個然而這個方法治標不治本,他只是讓咱們「忽略」他而已,使用以前須要確認bgsave
失敗的緣由,好比當redis用於緩存、會話的場景的時候,這麼作是容許的
服務器
將備份的rdb文件,重定向到目錄ide
CONFIG SET dir /tmp/some/directory/other/than/var CONFIG SET dbfilename temp.rdb
使用這個命令以後,須要確保bgsave_in_progress
返回結果是0
日誌
在內核運行時動態地修改內核的運行參數code
echo 'vm.overcommit_memory = 1' >> /etc/sysctl.conf sysctl vm.overcommit_memory=1