An analytic method for Redis read-only non-writable problems

Source: Internet
Author: User
Tags redis

Read and write on the Redis terminal, found only unreadable, get operation is normal, set operation prompt error: (error) misconf Redis is configured to save RDB Snapshots,but is currently Not able to persist on disk. Commands that may modify the data set are disabled. As shown in the picture:


This issue is communicated to the operational dimension after the solution, the method is to modify the configuration for Vm.overcommit_memory=1.

Reason:

Redis when saving data to a hard disk to avoid the main process from suspended animation, need to fork a main process, and then in the fork process to complete the operation of data saved to the hard disk, if the main process using 4GB of memory, the fork child process requires additional 4GB, this time the memory is not enough, fork failure, And then the data saved hard drive failed.
The Linux kernel determines whether to release according to the setting of the parameter vm.overcommit_memory parameter.

If vm.overcommit_memory = 1, direct release.
Vm.overcommit_memory = 0: Compares the amount of virtual memory allocated to this request and the system's current free physical memory plus swap to determine whether to release.
Vm.overcommit_memory = 2: Will compare all allocated virtual memory of the process plus the virtual memory allocated by this request and the current free physical memory of the system plus swap to determine whether to release.
As shown in this error:

[13223] Mar 13:18:02.207 # 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.overcom Mit_memory=1 ' for this to take effect.

The error message clearly illustrates the solution, and it also sets the Vm.overcommit_memory=1.

Redis Kernel parameter Overcommit_memory

It is an optional value for the memory allocation policy: 0, 1, 2.

0 indicates that the kernel will check if there is enough available memory to use the process, and if there is sufficient memory available, the memory request is allowed, otherwise the memory request fails and the error is returned to the application process.
1 means that the kernel allows all physical memory to be allocated regardless of the current state of memory.
2 indicates that the kernel allows memory to be allocated that exceeds the sum of all physical memory and swap space

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.