Tag Archives: redis  WARNING overcommit_memory is set to 0

About redis    WARNING overcommit_ The solution of memory is set to 0

1. Error information:

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.

Warning super delegate memory set to 0! Background save may fail under low memory conditions. To solve this problem, change “VM. Overcommit?U= 1 “to/etc/sysctl. Conf, and then restart or run the command” sysctl VM. Overcommit?1 “= 1 “to make it effective

2. Solutions:

In fact, the processing method has been given in the error message. Enter the/etc/sysctl.conf file and add vm.overcommit to the file= 1 to the sysctl. Conf file

There are two ways to do this:

2.1 execute command: echo 1 & gt/ proc/sys/vm/overcommit_ Memory, you may not be able to execute the command with ordinary users, so you can directly Su root and use the root user to execute the command. The advantage of this command is that it takes effect directly and does not need to restart the redis service. The disadvantage is that if the redis service is restarted, the error will continue to be reported and the above command needs to be executed again

root@iZbp1bz2wge6lwlpy5kw8sZ:/var/log/redis # sudo echo 1 > /proc/sys/vm/overcommit_memory

2.2 enter the/etc/sysctl.conf file and add vm.overcommit= 1. After restart, the error will disappear; The advantage of this method is that no matter how to restart the redis service in the future, the error will not be reported again. The disadvantage is that it can’t take effect immediately and must restart the redis service

vm.overcommit_memory=1

Thinking:

In the future, you can check the error log of redis, which is generally located at/var/log/redis/redis-server.log. If you don’t record the log file, you can enter the configuration file of redis and add logfile logfilepath. Note that the log file must have write permission

# Specify the log file name. Also the empty string can be used to force
# Redis to log on the standard output. Note that if you use standard
# output for logging but daemonize, logs will be sent to /dev/null
logfile /var/log/redis/redis-server.log