redis 启动警告 调整LINUX系统参数

按照REDIS启动报错的提示语,3个命令优化了系统参数

1)# ulimit -n
65535

对应的配置文件vi /etc/security/limits.conf  ,加上这段配置(注意注意ubuntu一定不能直接用*,否则会不生效

用户退出重新登陆就生效了

* soft nofile 65535
* hard nofile 65535
* soft noproc 65535
* hard noproc 65535

提示:写入到/etc/sysctl.conf就已经永久生效了,如果要让刚写入的立即也生效可以执行以下sysctl -p

假如重启不生效,参考https://www.linuxidc.com/Linux/2011-01/31626.htm

# ulimit -a查看是否生效

2)# sysctl vm.overcommit_memory=1
vm.overcommit_memory = 1

对应的配置文件/etc/sysctl.conf ,或者编辑 添加 'vm.overcommit_memory = 1' 然后重启电脑 

执行命令 'sysctl vm.overcommit_memory=1' 也可以让配置立即生效

3)# echo never > /sys/kernel/mm/transparent_hugepage/enabled

4)# echo 511 >/proc/sys/net/core/somaxconn
# echo "net.core.somaxconn = 551" > /etc/sysctl.conf
 

 

 

没有优化LINUX系统参数前,redis启动报错如下:

9976:C 19 Sep 14:49:22.579 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo

9976:C 19 Sep 14:49:22.579 # Redis version=4.0.1, bits=64, commit=00000000, modified=0, pid=9976, just started

9976:C 19 Sep 14:49:22.579 # Configuration loaded

9978:M 19 Sep 14:49:22.605 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.

9978:M 19 Sep 14:49:22.606 # Server can't set maximum open files to 10032 because of OS error: Operation not permitted.  操作系统限制,导致最大open文件数不能达到10032,目前最大open文件数是4096,可以用命令 'ulimit -n'调大

9978:M 19 Sep 14:49:22.606 # 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'.

                _._

           _.-``__ ''-._

      _.-``    `.  `_.  ''-._           Redis 4.0.1 (00000000/0) 64 bit

  .-`` .-```.  ```\/    _.,_ ''-._

(    '      ,       .-`  | `,    )     Running in standalone mode

|`-._`-...-` __...-.``-._|'` _.-'|     Port: 34242

|    `-._   `._    /     _.-'    |     PID: 9978

  `-._    `-._  `-./  _.-'    _.-'

|`-._`-._    `-.__.-'    _.-'_.-'|

|    `-._`-._        _.-'_.-'    |           http://redis.io

  `-._    `-._`-.__.-'_.-'    _.-'

|`-._`-._    `-.__.-'    _.-'_.-'|

|    `-._`-._        _.-'_.-'    |

  `-._    `-._`-.__.-'_.-'    _.-'

      `-._    `-.__.-'    _.-'

          `-._        _.-'

              `-.__.-'

 

9978:M 19 Sep 14:49:22.628 # 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导致redis配置的511不能起作用

9978:M 19 Sep 14:49:22.628 # Server initialized

9978:M 19 Sep 14:49:22.628 # 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.

这个地方系统参数限制了不能overcommit内存,这个地方要调成1

9978:M 19 Sep 14:49:22.629 # 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.

9978:M 19 Sep 14:49:22.638 . Unrecognized RDB AUX field: 'redis-ver'因为前面内存限制太小RDB都有问题

9978:M 19 Sep 14:49:22.638 . Unrecognized RDB AUX field: 'redis-bits'

9978:M 19 Sep 14:49:22.638 . Unrecognized RDB AUX field: 'ctime'

9978:M 19 Sep 14:49:22.638 . Unrecognized RDB AUX field: 'used-mem'

9978:M 19 Sep 14:49:22.638 . Unrecognized RDB AUX field: 'aof-preamble'

没有更多推荐了,返回首页