redis安装后修改三个地方


Redis学习笔记——启动警告问题的解决


如果启动前不对linux内核做任何更改,那么redis启动会报出警告,共三个:如下图所示

第一个警告:The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
意思是:TCP  backlog设置值,511没有成功,因为 /proc/sys/net/core/somaxconn这个设置的是更小的128.
临时解决方法:(即下次启动还需要修改此值)
echo 511 > /proc/sys/net/core/somaxconn

第一个警告的意思是:redis设置的tcp连接数受限于系统默认限制的/proc/sys/net/core/somaxconn中128,因此必须要先调整内核的连接数

永久解决方法:(即以后启动还需要修改此值)
将其写入/etc/rc.local文件中。
baklog参数实际控制的是已经3次握手成功的还在accept queue的大小。
参考linux里的backlog详解

————————————————————————————————————————————————————————————————————————————————————
第二个警告: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.
意思是:overcommit_memory参数设置为0!在内存不足的情况下,后台程序save可能失败。建议在文件 /etc/sysctl.conf 中将overcommit_memory修改为1。
临时解决方法:echo "vm.overcommit_memory=1" > /etc/sysctl.conf
永久解决方法:将其写入/etc/sysctl.conf文件中。
参考:有关linux下redis overcommit_memory的问题

第二个警告的意思:系统默认是有空闲内存才会分配给redis,因此如果在内存不足的情况,redis存储数据的时候可能会失败。 所以要把内存分配机制,改为无论有没有空闲内存,都要分配内存给redis
方法是:echo "vm.overcommit_memory=1" >> /etc/sysctl.conf 执行sysctl -p,使之生效



第三个警告:you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix thisissue 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 thesetting after a reboot. Redis must be restarted after THP is disabled.

第三个警告意思是:你使用的是透明大页,可能导致redis延迟和内存使用问题。执行 echo never > /sys/kernel/mm/transparent_hugepage/enabled 修复该问题。
临时解决方法:
echo never > /sys/kernel/mm/transparent_hugepage/enabled。

永久解决方法:
将其写入/etc/rc.local文件中。
参考透明大页介绍。

  参考链接:http://blog.csdn.net/a491857321/article/details/52006376

原文地址:https://www.cnblogs.com/to-be-rich/p/7818618.html