解决redis启动时的三个警告

我在CentOS 7.2中安装完redis,初次启动时出现了三个警告:
在这里插入图片描述

第一个警告:The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
第二个警告: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.
第三个警告: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.

作者:黑色小核
链接:https://www.jianshu.com/p/a86e0248af58
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

解决方案
考虑到redis一般都是部署在服务器上作为服务存在的。所以,本文的解决方案都是持久性配置,不是临时配置。

第一个警告
将net.core.somaxconn = 1024添加到/etc/sysctl.conf中,然后执行sysctl -p生效配置。

第二个警告
将vm.overcommit_memory = 1添加到/etc/sysctl.conf中,然后执行sysctl -p生效配置。

第三个警告
将echo never > /sys/kernel/mm/transparent_hugepage/enabled添加到/etc/rc.local中,然后执行source /etc/rc.local生效配置。

总结
redis想的挺周全的,其实解决方案已经写在警告里了,除了第一个警告的解决方案稍作了一些修改外,其他警告的解决方案其实只是对redis的提示做了一个精简。

作者:黑色小核
链接:https://www.jianshu.com/p/a86e0248af58
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

猜你喜欢

转载自blog.csdn.net/weixin_43897590/article/details/106512713