After Redis saves the snapshot, it cannot be written.

Source: Internet
Author: User
Tags redis cluster install redis

After Redis saves the snapshot, it cannot be written.

Today, developers suddenly told me that Redis cannot be written. After entering Redis, I found that this is indeed the case and I cannot execute the set command. The following error is reported:

172.31.18.90: 6379> set test test1

(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. please check Redis logs for details about the error.

Previously, redis was normal. This is not caused by permission issues, nor is the memory used up

The error fork: Cannot allocate memory is found by checking the log.

Creating a fork on a small memory process does not require too many resources. However, when the memory space of the process is measured in GB, fork becomes a terrible operation. What's more, on a 16 GB memory host, what about the fork 14 GB memory process? It will certainly report that the memory cannot be allocated. What's more, the more frequently changed the fork on the host, the more frequent the fork operation, the more costly it is.

After finding the cause, directly modify the Kernel Parameter vm. overcommit_memory = 1

Run sysctl-p to make kernel parameters take effect.

Parameter description:

The Linux kernel determines whether to allow access based on the vm. overcommit_memory parameter settings.

If vm. overcommit_memory = 1, open

Vm. overcommit_memory = 0: Compare the virtual memory size allocated for this request with the physical memory occupied by the system plus the swap, and decide whether to allow access.

Vm. overcommit_memory = 2: Compare all virtual memory allocated by the process with the virtual memory allocated by the request and the current idle physical memory of the system with swap to determine whether to allow access.

Here we are re-sending the redis write-back mechanism.

Redis's data write-back mechanism is divided into two types: synchronous and asynchronous,

Synchronous write-back refers to the SAVE command, and the main process directly writes data back to the disk. In the case of big data, the system will be suspended for a long time, so it is generally not recommended.

Asynchronous write-back is the BGSAVE command. After the main process fork, copy itself and write it back to the disk through the new process. After the write-back is complete, the new process is closed. Because this does not require the main process to be blocked, the system will not be suspended. This method is generally used by default.

Note:

Running the config set stop-writes-on-bgsave-error no command in redis can only temporarily solve the problem that cannot be set. If something goes wrong, you still need to check the log.

By default, stop-writes-on-bgsave-error yes is configured. data cannot be modified when bgsave fails.

You may also like the following articles about Redis. For details, refer:

Install and test Redis in Ubuntu 14.04

Basic configuration of Redis master-slave Replication

Redis cluster construction and simple use

Install and configure Redis in CentOS 7

Install Redis and simple configuration in Ubuntu 14.04

Install PHP7.0 Redis extension in Ubuntu 16.04

Offline installation and deployment of Redis standalone and Cluster

CentOS 7.0 install Redis 3.2.1 detailed process and usage FAQs

Install PHP7.0 Redis extension in Ubuntu 16.04

Redis cluster deployment document under Ubuntu 15.10

Redis practice PDF

Redis hot migration Summary

Redis3.0 configuration file details

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.