Redis "Misconf Redis is configured to save RDB snapshots, but are currently not able to persist on di

Source: Internet
Author: User

For the second time today, I encountered the issue of Redis "Misconf Redis is configured to save RDB snapshots, but are currently not able to persist on disk." This error message is the exception information that the Redis client tool throws when it saves the data.

Online check, a lot of people are recommended "config set Stop-writes-on-bgsave-error no". This is not really good, this is simply to let the program ignore this exception, so that the program can continue to run, but the actual data will still be stored on the hard disk failed.

The last time I encountered this problem was because a bug in one program caused the system memory to run out, and then fixed the bug problem and solved it. Today, when the problem occurs, look at the system memory and about 2GB, "it does not feel like memory" (later found or because of memory).

Because Redis is running in daemon mode, you cannot see the detailed log. Modify profile Settings logfile parameter is a file (the default is stdout, we recommend that after installation to modify this parameter as a file, or you will lose a lot of important information), restart the Redis, view the log, see the program started with a line of warning prompts:

"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 the to take effect. (Warning: Excessive use of memory is set to 0.) In a low memory environment, background saves may fail. To fix this problem, add a ' vm.overcommit_memory = 1 ' in/etc/sysctl.conf and then reboot (or Run command ' sysctl Vm.overcommit_memory=1 ') to make it effective. )

The

didn't understand the meaning at the time, so I ignored it. The Redis client is restarted, and the program saves the data by continuing to report "Misconf Redis is configured to save RDB snapshots, and but is currently does not able to persist on disk" exception. Then look at the Redis log and see that there are such errors as "Can" t save in Background:fork:Cannot allocate memory ", this hint is very obvious" fork process memory is not enough. "(or a problem with memory).

Through Google query "Can ' t save in Background:fork:Cannot allocate memory" this hint, found the solution: View plain Copy to clipboard print? Original: Http://pydelion.com/2013/05/27/redis-cant-save-in-background-fork-cannot-allocate-memory/If Error Can ' t save in Background:fork:Cannot allocate memory it means this your current database is bigger than Memory you have. To fix the issue enable Vm.overcommit_memory:sysctl Vm.overcommit_memory=1 to have if after reboot add this Lin E To/etc/sysctl.cnf:vm.overcommit_memory=1

After modifying the Vm.overcommit_memory=1, the problem was solved.

Why the system is still left with 2GB of memory, Redis will say that there is not enough memory.

Checked on the internet, someone also encountered a similar problem, and gave a good analysis (see: http://www.linuxidc.com/Linux/2012-07/66079.htm), To put it simply: Redis to save data to the hard drive in order to avoid the main process of death, 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 uses 4GB of memory, fork child process requires additional 4GB, this time the memory is not enough, Fork failed, and the data saved hard drive failed.

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.