zl程序教程

您现在的位置是:首页 >  数据库

当前栏目

【Redis】启动3个告警解决:WARNING: The TCP backlog setting of 511

RedisTCP 解决 启动 The of WARNING 告警
2023-09-11 14:17:06 时间

【问题】

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