There is a problem with redis replica today. After the slaveof command is executed, slave info is displayed as disconnected from the master. The following error is returned when you view the system log: connecting to master... [17727] 07 Dec 11:31:03 * master <-> slave sync started [17727] 07 Dec 11:31:03 * Non Blocking connect for sync fired the event. [17727] 07 Dec 11:31:03 # Master aborted replication with an error: Err unable to perform background save is used to view the system logs of the master. The error is as follows: slave ask for synchronization [2487] 07 Dec 14:08:09 * Starting bgsave for sync [2487] 07 Dec 14:08:09 # Can't save in Background: fork: cannot allocate memory [2487] 07 Dec 14:08:09 * replication failed, can't bgsave on the console to execute bgsave really does not work, Google for a long time, Found the root cause:Http://groups.google.com/ Group/redis-DB/browse_thread/ Thread/dc1_6861b174358When I look at the start part of the system log of the master node, the following warning is displayed: [5660] 08 Oct 13:49:56 # 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 key to locating the problem is the parameter VM. overcommit _ For settings of memory, refer to http: // iloutuoli. Blogspot.com/2011/11/sysctl- Vmovercommitmemory.htmlSaid:
VM. overcommit_memory indicates the checking method when the kernel allocates memory. This variable can be obtained from 0, 1,2. The processing method for getting different values is defined in the kernel source code mm/MMAP. C's _ vm_enough_memory function.
When taking 1:
In this case, the macro is overcommit_always, and the function returns 0 directly. The assignment is successful.
When taking 2:
At this time, the macro is overcommit_never, and kernel computing: total memory × VM.Total overcommit_ratio/100 + swap. If the applied space exceeds this value, the allocation fails. VM.The default value of overcommit_ratio is 50.
When the value is 0:
In this case, the macro is overcommit_guess, and kernel computing: nr_file _Total pages + total swap + total memory that can be released in slab,If the applied space exceeds this value, totalreserve_pages (?) is subtracted from the total amount of free memory (?) Total. If the requested space still exceeds this value, the allocation fails.
The above is a rough description. In actual calculation, if the process is not a root process,In computing, 3% of the space is retained, while the root process does not.For detailed procedures, see the source code.
This configuration involves the system kernel and requires the root permission, The next step is to wait for OPS to help you.