1. 程式人生 > >解決redis Can't save in background: fork: Cannot allocate memory

解決redis Can't save in background: fork: Cannot allocate memory

前面啟動Redis時,看到如下警告:

[1958] 13 Aug 16:18:24 # 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.

需要修改/etc/sysctl.conf

檔案:

vim /etc/sysctl.conf

末尾追加vm.overcommit_memory = 1
然後執行sysctl vm.overcommit_memory=1,使之生效:
# sysctl vm.overcommit_memory=1  
vm.overcommit_memory = 1