【Redis】启动3个告警解决:WARNING: The TCP backlog setting of 511
【问题】
28687:C 09 Sep 10:14:31.681 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
28687:C 09 Sep 10:14:31.681 # Redis version=4.0.11, bits=64, commit=00000000, modified=0, pid=28687, just started
28687:C 09 Sep 10:14:31.681 # Configuration loaded
28687:M 09 Sep 10:14:31.682 * Increased maximum number of open files to 10032 (it was originally set to 1024).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 4.0.11 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 28687
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
28687:M 09 Sep 10:14:31.685 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
28687:M 09 Sep 10:14:31.685 # Server initialized
28687:M 09 Sep 10:14:31.685 # 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.
28687:M 09 Sep 10:14:31.686 # 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.
28687:M 09 Sep 10:14:31.688 * DB loaded from disk: 0.001 seconds
28687:M 09 Sep 10:14:31.688 * Ready to accept connections
【解决方法】
要有root权限:
1、WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
原因就是因为128太小了。
执行echo 511 > /proc/sys/net/core/somaxconn命令就把这个问题解决了。
但是这个只是暂时的。如果想要永久解决,打开vi /etc/sysctl.conf
在/etc/sysctl.conf这里面添net.core.somaxconn= 1024
然后执行sysctl -p 就可以永久消除这个warning
2、内核参数设置,按提示的操作
(1)编辑/etc/sysctl.conf ,改vm.overcommit_memory=1,然后sysctl -p 使配置文件生效
(2)sysctl vm.overcommit_memory=1
(3)echo 1 > /proc/sys/vm/overcommit_memory
3、按提示的操作
echo never > /sys/kernel/mm/transparent_hugepage/enabled
【查看效果】
1、重启
[root@DATASC-DB-01-new src]# ./redis-server ../redis.conf &
[1] 31115
2、看日志
[root@DATASC-DB-01-new src]# cd ../logs/
[root@DATASC-DB-01-new logs]# cat redis.log
31115:C 09 Sep 10:44:32.813 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
31115:C 09 Sep 10:44:32.814 # Redis version=4.0.11, bits=64, commit=00000000, modified=0, pid=31115, just started
31115:C 09 Sep 10:44:32.814 # Configuration loaded
31115:M 09 Sep 10:44:32.815 * Increased maximum number of open files to 10032 (it was originally set to 1024).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 4.0.11 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 31115
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
31115:M 09 Sep 10:44:32.817 # Server initialized
31115:M 09 Sep 10:44:32.819 * DB loaded from disk: 0.002 seconds
31115:M 09 Sep 10:44:32.819 * Ready to accept connections
[root@DATASC-DB-01-new logs]#
【补充】
报错
7125:M 01 Oct 18:39:46.025 * 10 changes in 300 seconds. Saving...
7125:M 01 Oct 18:39:46.026 * Background saving started by pid 42239
42239:C 01 Oct 18:39:46.051 * DB saved on disk
42239:C 01 Oct 18:39:46.052 * RDB: 4 MB of memory used by copy-on-write
7125:M 01 Oct 18:39:46.127 * Background saving terminated with success
原因
内存不足,导致无法folk进程做RDB持久化。看了一下内存使用率:
free -g
解决
1、可以简单的通过修改overcommit_memory系统参数为1来改变这种简单粗暴的检查行为:
(1)编辑/etc/sysctl.conf ,改vm.overcommit_memory=1,然后sysctl -p 使配置文件生效
(2)sysctl vm.overcommit_memory=1
(3)echo 1 > /proc/sys/vm/overcommit_memory
相关文章
- redis集群与分片(2)-Redis Cluster集群的搭建与实践
- redis实战笔记(10)-第10章 扩展Redis
- redis实战笔记(2)-第2章 使用 Redis构建Web应用
- redis cluster 集群 HA 原理和实操(史上最全、面试必备)
- Redis源代码剖析--对象object
- Redis安装和操作
- MVC的验证(模型注解和非侵入式脚本的结合使用) .Net中初探Redis .net通过代码发送邮件 Log4net (Log for .net) 使用GDI技术创建ASP.NET验证码 Razor模板引擎 (RazorEngine) .Net程序员应该掌握的正则表达式
- 84分布式电商项目 - Redis存储购物车
- Redis开发运维实践开发设计规范之数据异常处理
- redis
- Redis的数据结构及其使用场景
- Redis——jedis连接redis哨兵模式简单使用
- Redis第二十四讲 Redis集群如何确保数据能被插入到同一个哈希槽与集群的哈希槽为什么是16384
- 顿悟!百度强推的 Redis 天花板笔记
- 分布式锁的几种实现方法:redis实现分布式锁
- redis trim
- redis 队列
- Spring Boot 2.x基础教程:使用Redis的发布订阅功能
- Spring集成Redis集群(含spring集成redis代码)
- Redis知识点总结
- Shiro Redis注入失败,shiro导致redis不能注入
- Redis总结
- Redis Desktop Manager无法连接虚拟机中启动的redis服务问题排查步骤
- linux 之 redis单机安装
- Redis_redis分布式锁-SETNX
- Redis(1.1)redis安装,linux下安装redis
- 曹工说Redis源码(8)--面试时,redis 内存淘汰总被问,但是总答不好
- Redis 优化之 tcp-backlog