如何解决redis启动时的三个警告

这篇文章主要介绍“如何解决redis启动时的三个警告”,在日常操作中,相信很多人在如何解决redis启动时的三个警告问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”如何解决redis启动时的三个警告”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

Redis安装后直接启动会提示三个错误,如下:

[lb@centos-linux src]$ ./redis-server
1988:C 19 Apr 2021 00:33:16.869 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1988:C 19 Apr 2021 00:33:16.869 # Redis version=6.2.1, bits=64, commit=00000000, modified=0, pid=1988, just started
1988:C 19 Apr 2021 00:33:16.869 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
1988:M 19 Apr 2021 00:33:16.870 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
1988:M 19 Apr 2021 00:33:16.870 # Server can't set maximum open files to 10032 because of OS error: Operation not permitted.
1988:M 19 Apr 2021 00:33:16.870 # Current maximum open files is 4096. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
1988:M 19 Apr 2021 00:33:16.870 * monotonic clock: POSIX clock_gettime
                _._
           _.-``__ ''-._
      _.-``    `.  `_.  ''-._           Redis 6.2.1 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 1988
  `-._    `-._  `-./  _.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |           http://redis.io
  `-._    `-._`-.__.-'_.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |
  `-._    `-._`-.__.-'_.-'    _.-'
      `-._    `-.__.-'    _.-'
          `-._        _.-'
              `-.__.-'

1988:M 19 Apr 2021 00:33:16.872 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
1988:M 19 Apr 2021 00:33:16.872 # Server initialized
1988:M 19 Apr 2021 00:33:16.872 # 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.
1988:M 19 Apr 2021 00:33:16.872 * Ready to accept connections

为解决这个问题,可已通过如下配置进行解决,具体操作如下:

  1. 修改linux系统配置

[root@centos-linux lb]# vim /etc/sysctl.conf
  1. 添加配置

net.core.somaxconn = 1024
vm.overcommit_memory = 1
  1. 添加完成后,刷新内核参数,立即生效

[redis-5.0.8]$ /sbin/sysctl -p

到此,关于“如何解决redis启动时的三个警告”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注网站,小编会继续努力为大家带来更多实用的文章!