Connect Reids to get data when prompted
Redis is configured to save the RDB snapshots, but was currently not able to persist on disk. Commands T
Online Search Data http://www.cnblogs.com/qq78292959/p/3994349.html tips
Add a ' vm.overcommit_memory = 1 ' Restart or Run command in/etc/sysctl.conf
Problem solving.
Reasons for investigation:
Simply put: Redis when saving data to the hard disk in order to avoid the main process of animation, need to fork a master process, and then in the fork process to complete the operation of the data to the hard disk, if the main process uses 4GB of memory, fork sub-process requires an additional 4GB, when the memory is not enough, Fork failed, and the data saved the hard drive also failed.
Data loss issues with Redis
Website: http://www.linuxidc.com/Linux/2012-07/66079.htm
The data writeback mechanism of Redis is divided into two types, synchronous and asynchronous.
Synchronous writeback is the Save command, and the main process writes back data directly to the disk. In the case of large data can cause the system to feign death for a long time, so it is generally not recommended. Asynchronous writeback is the Bgsave command, after the main process fork, copy itself and write back to the disk through this new process, and the new process shuts itself down after the write-back is completed. Since this does not require the main process to block, the system will not feign animation, the general default will use this method.
Personal feeling Method 2 the way to fork the main process is clumsy, but it seems to be the only way. Hot data in memory can be modified at any time, and the memory image to be saved on disk must be frozen. Freezing will result in suspended animation. Fork a new process is equivalent to replicating a memory image then, so that the main process does not need to freeze, as long as the child process on the operation.
A fork in a small memory process does not require much resources, but when the memory space of the process is in G, fork becomes a horrible operation. Not to mention the process of fork 14G memory on a 16G memory host? It will certainly be reported that memory cannot be allocated. More exasperating is, the more frequent changes in the host fork on the more frequent, the fork of the cost of the operation itself may not be much better than suspended animation.
After you find the reason, directly modify the kernel parameter Vm.overcommit_memory = 1
The Linux kernel determines whether or not to release according to the parameter vm.overcommit_memory parameters.
If vm.overcommit_memory = 1= 0= 2: The process will be compared to all allocated virtual memory plus the virtual memory allocated by the request and the current free physical memory of the system plus swap to determine whether to release.
Redis-Memory Exception Redis is configured to save RDB snapshots resolution