Redis Boot warning error resolution [GO]

Source: Internet
Author: User
Tags redis server

Redis Boot Warning Error Resolution

Startup error

1.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.
2.warning:the TCP Backlog setting of 511 cannot be enforced because/proc/sys/net/core/somaxconn are set to the lower Valu E of 128.
Workaround

First warning two ways to solve (overcommit_memory)

1. Echo "Vm.overcommit_memory=1" >/etc/sysctl.conf or vi/etcsysctl.conf, then reboot restart the machine

2. Echo 1 >/proc/sys/vm/overcommit_memory no need to start the machine to take effect

A second warning resolves

1. Echo 511 >/proc/sys/net/core/somaxconn

overcommit_memory parameter Description :
Set the memory allocation policy (optional, set according to the actual situation of the server)
/proc/sys/vm/overcommit_memory
Optional values: 0, 1, 2.
0, indicates that the kernel will check for sufficient available memory to be used by the process, and if sufficient memory is available, the memory request is allowed; otherwise, the memory request fails and the error is returned to the application process.
1, which means that the kernel allows all physical memory to be allocated regardless of the current memory state.
2, which indicates that the kernel allows allocating more memory than the sum of all physical memory and swap space

Note: Redis in the dump data, will fork out a sub-process, in theory the child process occupies the same memory and the parent is the same, such as the parent occupies 8G of memory, this time also to allocate 8G of memory to child, if the memory is not affordable, Will often cause the Redis server down or IO load is too high, inefficient. So the more optimized memory allocation policy here should be set to 1 (indicating that the kernel allows all physical memory to be allocated regardless of the current memory state).

It also involves Overcommit and oom.

What is Overcommit and oom?
In Unix, when a user process uses the malloc () function to request memory, if the return value is NULL, the process knows that there is currently no available memory space and will do the appropriate processing. Many processes print error messages and exit.

Linux uses a different approach, which responds "yes" to most requests for memory, so that it can run a larger number of programs. Memory is not used immediately after memory is applied. This technique is called overcommit.
When memory is low, OOM killer (oom=out-of-memory) occurs. It chooses to kill some processes (the user-state process, not the kernel thread) in order to free up memory.

Overcommit's strategy
There are three strategies for Linux under Overcommit (documentation/vm/overcommit-accounting):
0. Heuristic strategy. Reasonable overcommit will be accepted and unreasonable overcommit will be rejected.
1. Any overcommit will be accepted.
2. Commit is rejected when the system allocates more memory than swap+n%* physical RAM (N% determined by Vm.overcommit_ratio).
The Overcommit policy is set through Vm.overcommit_memory.
The percentage of Overcommit is set by Vm.overcommit_ratio.

# echo 2 >/proc/sys/vm/overcommit_memory
# echo >/proc/sys/vm/overcommit_ratio

When oom-killer occurs, Linux chooses which processes to kill
The function that selects a process is the oom_badness function (in MM/OOM_KILL.C), which calculates the number of points (0~1000) per process.
The higher the number of points, the more likely the process is to be killed.
The number of points per process is related to Oom_score_adj, and Oom_score_adj can be set (-1000 min, 1000 max).

Redis Boot warning error resolution [GO]

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.