由于我对Redis服务器的此实例有一些问题,所以我已经检查了SystemD服务的日志the命令:
redis.service
journalctl -u redis | less
我正在尝试遵循警告提供的建议,但是在我的系统上,我找不到任何文件redis-server[320]: 320:M 19 Feb 2025 15:40:12.802 # 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 th
is to take effect.
/etc/sysctl.conf
可以在我的系统上执行以前的命令而不会出错,并给出输出:
sysctl vm.overcommit_memory=1
但是,当我重新启动系统时,警告始终存在于vm.overcommit_memory = 1
因此,我尝试创建一个用以下内容创建一个文件:
redis
我如何解决此警告?
thislink我找到了以下句子:
此人页面描述了procps sysctl的配置文件。 如果您使用的是Systemd-Sysctl(8),请参阅Sysctl.d(5),并注意 它不会使用file/etc/sysctl.conf.
I发现我的Linux发行版正在使用/etc/sysctl.conf
vm.overcommit_memory = 1
/etc/sysctl.d/.conf.conf
/run/sysctl.d/
/USR/local/lib/sysctl.d/
.conf/USR/lib/sysctl.d/
.conf配置sysctl(8)内核参数。 为了在系统中设置参数
systemd-sysctl
,我决定通过配置文件设置它;该文件的内容如下:
/etc/sysctl.conf
通过添加此文件,然后在重新启动后,通过执行以下命令可以看到,内核参数设置为vm.overcommit_memory = 1
:/etc/sysctl.d/kernel_vm_overcommit_memory.conf
服务停止发出警告:vm.overcommit_memory = 1