Press "Enter" to skip to content

redis安装好之后必做的几件事

先来看一段日志

1525:M 21 Nov 11:10:36.412 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
22552:M 19 Jan 10:36:26.936 # Server started, Redis version 3.2.12
22552:M 19 Jan 10:36:26.936 # 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.overcommit_memory=1' for this to take effect.
22552:M 19 Jan 10:36:26.936 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
22552:M 19 Jan 10:36:26.936 * The server is now ready to accept connections on port 6380

解决办法:

$ echo never > /sys/kernel/mm/transparent_hugepage/enabled

$ vim /etc/rc.local  # 写入下面一行
echo never > /sys/kernel/mm/transparent_hugepage/enabled

$ vim /etc/sysctl.conf  # 写入下面2行
net.core.somaxconn = 1024
vm.overcommit_memory = 1

$ sysctl -p
Leave a Reply

Your email address will not be published. Required fields are marked *