redis hput异常org.springframework.dao.InvalidDataAccessApiUsageException: 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.; nested exception is redis.clients.jedis.exceptions.JedisDataException: 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.jedis.JedisExceptionConverter.convert(JedisExceptionConverter.java:64)
at org.springframework.data.redis.connection.jedis.JedisExceptionConverter.convert(JedisExceptionConverter.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.jedis.JedisConnection.convertJedisAccessException(JedisConnection.java:181)
at org.springframework.data.redis.connection.jedis.JedisHashCommands.convertJedisAccessException(JedisHashCommands.java:433)
at org.springframework.data.redis.connection.jedis.JedisHashCommands.hSet(JedisHashCommands.java:69)
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 org.springframework.data.redis.core.DefaultBoundHashOperations.put(DefaultBoundHashOperations.java:145)
at com.augurit.xmjg.province.config.RedisClient.hput(RedisClient.java:165)
at
redis deleteKey操作异常org.springframework.dao.InvalidDataAccessApiUsageException: 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.; nested exception is redis.clients.jedis.exceptions.JedisDataException: 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.jedis.JedisExceptionConverter.convert(JedisExceptionConverter.java:64)
at org.springframework.data.redis.connection.jedis.JedisExceptionConverter.convert(JedisExceptionConverter.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.jedis.JedisConnection.convertJedisAccessException(JedisConnection.java:181)
at org.springframework.data.redis.connection.jedis.JedisKeyCommands.del(JedisKeyCommands.java:93)
at org.springframework.data.redis.connection.DefaultedRedisConnection.del(DefaultedRedisConnection.java:61)
at org.springframework.data.redis.connection.DefaultStringRedisConnection.del(DefaultStringRedisConnection.java:252)
at org.springframework.data.redis.core.RedisTemplate.lambda$delete$2(RedisTemplate.java:709)
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.RedisTemplate.delete(RedisTemplate.java:709)
at
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.; nested exception is redis.clients.jedis.exceptions.JedisDataException: 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 erro
Redis被配置为保存RDB快照,但目前无法持久化到磁盘上。可能修改数据集的命令被禁用。请检查Redis日志的详细错误。Redis被配置为保存RDB快照,但目前不能持久化到磁盘上。可能修改数据集的命令被禁用。请检查Redis日志的详细错误
翻看日志
find / -name redis
find / -name redis.conf
找到redis的日志路径并查看
Can't save in background: fork: Cannot allocate memory
WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect
国外给的方法如下:
sysctl vm.overcommit_memory=1
编辑
/etc/sysctl.cnf
补充:
vm.overcommit_memory=1
国外的文章如下:
If you get this error
Can't save in background: fork: Cannot allocate memory
it means that your current database is bigger than memory you have. To fix the issue enable vm.overcommit_memory:
sysctl vm.overcommit_memory=1
To have if after reboot add this line to /etc/sysctl.cnf:
vm.overcommit_memory=1
程序保存数据时继续报“MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk”异常,再查看Redis日志,看到有这样的错误提示“Can’t save in background: fork: Cannot allocate memory”,这个提示很明显"Fork进程时内存不够用了!"(还是内存的问题)。
编辑sysctl.conf
vi /etc/sysctl.conf
最下方补充内容
net.core.somaxconn= 1024
执行命令
sysctl -p
重启之后,起码可以释放当前所有的内存,可以先观察一下重启是否正常!
或者杀掉redis进程重启
ps -ef|grep redis
kill -9 {redis进程号}
找到redis-server的bin路径,并且要找到redis配置文件的路径
find / -name redis
find / -name redis.conf
redis-cli shutdown #关闭命令
redis-server /path/to/redis.conf #启动命令
或者注册服务的重启redis服务
free -h
cd /usr
mkdir swap
dd if=/dev/zero of=/usr/swap/swapfile bs=1M count=64096
提前保证路径下有剩余的空间
mkswap /usr/swap/swapfile
chmod 0600 /usr/swap/swapfile #改一下权限,系统建议0600
swapon /usr/swap/swapfile
free -h #检查虚拟内存是否增加了
vim /etc/fstab
/usr/swap/swapfile swap swap defaults 0 0 #将这个内容添加到上面的配置文件
保持文件退出
reboot -h now #重启服务器命令
top #命令验证
验证成功,扩展虚拟内存成功!