The Java log error is as follows:
redis hput exception 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 operation exception 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 is configured to save RDB snapshots, but currently cannot persist them to disk. Commands that may modify the data set are disabled. Please check the Redis logs for detailed errors. Redis is configured to save RDB snapshots, but currently cannot persist to disk. Commands that may modify the data set are disabled. Please check the Redis log for detailed errors
Solution (1)
Read the log
find/-name redis find/-name redis.conf
Find the redis log path and view it
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
The methods given abroad are as follows:
sysctl vm.overcommit_memory=1
edit
/etc/sysctl.cnf
Replenish:
vm.overcommit_memory=1
Foreign articles are as follows:
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
When the program saves data, it continues to report the “MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk” exception. Check the Redis log again and see the error message “Can’t save in background: fork: Cannot allocate memory”, this prompt is obvious “The memory is not enough when Fork the process!” (It is still a memory problem).
Edit sysctl.conf
vi /etc/sysctl.conf
Supplementary content at the bottom
net.core.somaxconn= 1024
Excuting an order
sysctl -p
Solution (2) Restart the ultimate move to release memory:
After restarting, at least all the current memory can be released. You can first check whether the restart is normal!
Step (1) Close the JAVA application first
Step (2) Use the Redis tool to connect to the database and manually clear the database FLASH DATABASE operation
FLASH DATABASE
Step 3 Restart the redis service
Or kill the redis process and restart it
ps -ef|grep redis
kill -9 {<!-- -->redis process number}
Find the bin path of redis-server and find the path of the redis configuration file
find/-name redis find/-name redis.conf
Enter the bin path of redis
redis-cli shutdown #shutdown command
redis-server /path/to/redis.conf #Start command
Or restart the redis service by registering the service
Solution (3) Expand the virtual memory of the server. Physical methods can be used to expand the redis service to use larger memory resources of the server
1. Check the current configuration size of virtual memory
free -h
2. Create swap file
cd /usr mkdir swap dd if=/dev/zero of=/usr/swap/swapfile bs=1M count=64096
Make sure there is remaining space in the path in advance
3. Set the target to the swap partition file
mkswap /usr/swap/swapfile
chmod 0600 /usr/swap/swapfile #Change the permissions, the system recommends 0600
4. Enable swap partition file
swapon /usr/swap/swapfile
free -h #Check whether the virtual memory has been increased
5. Add the virtual memory configuration to the automatic startup configuration at boot
vim /etc/fstab
/usr/swap/swapfile swap swap defaults 0 0 #Add this content to the above configuration file
Keep file exited
6. Verify whether the virtual memory takes effect after restarting the server
reboot -h now #Restart server command
top #Command verification
Verification successful, virtual memory expansion successful!