Redis "Misconf Redis is configured to save RDB snapshots, but was currently not able to persist on disk" solution

Source: Internet
Author: User

Today's second encounter with Redis "Misconf Redis is configured to save the RDB snapshots, but was currently not able to persist on disk" issue. This error message is the exception information that the Redis client tool throws when it saves data.

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

The last time you encounter this problem is because a bug in the program caused the system memory to be exhausted, and then fixed the bug solved. Look at the system memory at the time of the problem today and about 2GB, "it feels like it's not Memory" (later discovered or because of memory).

Because Redis is running in daemon mode, you can't see the detailed logs. Modify the profile settings logfile parameter to the file (the default is stdout, it is recommended to modify this parameter after installation, otherwise you will lose a lot of important information), restart Redis, view the log, see the program starts with a line of warning:

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

When I didn't understand the meaning, I ignored it. After starting the Redis client, the program continues to report "Misconf Redis is configured to save RDB snapshots, and is currently not able to persist on disk" exception, Then look at the Redis logs and see the error "Can ' t save in Background:fork:Cannot allocate memory", the hint is obvious "the fork process is not enough RAM!" "(Still a memory problem).

By Google query "Can ' t save in Background:fork:Cannot allocate memory" this hint, found the solution:

    //Original:http://pydelion.com/2013/05/27/redis-cant-save-in-background-fork-cannot-allocate-memory/If you get ThisError Can' t save in Background:fork:Cannot allocate memoryIt means that your the current database is bigger than memory. To fix the issue enable Vm.overcommit_memory:sysctl Vm.overcommit_memory=1 to hasifAfter rebootAdd this line to /etc/  sysctl.cnf: vm.overcommit_memory        =1 

The problem is solved after modifying Vm.overcommit_memory=1.

Why does the system still have 2GB of memory left, Redis will say that memory is not enough?

Online check, some people have encountered similar problems, and gave a very good analysis (see: Http://www.linuxidc.com/Linux/2012-07/66079.htm), simply: Redis to save data to the hard disk in order to avoid the main process of suspended animation, Need to fork a copy of the main process, and then in the fork process to save the data to the hard disk operation, if the main process uses 4GB of memory, fork sub-process when the need for additional 4GB, when the memory is not enough, fork failed, and then the data saved hard disk also failed.

Redis "Misconf Redis is configured to save RDB snapshots, but was currently not able to persist on disk" solution

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.