Redis 5.0.3默认配置启动报错解决方法

Posted 悠游网鱼

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Redis 5.0.3默认配置启动报错解决方法相关的知识,希望对你有一定的参考价值。

一、redis默认配置启动报错误信息如下

# /usr/local/redis/bin/redis-server /usr/local/src/redis-5.0.3/redis.conf
5852:C 24 Jan 2019 23:00:07.676 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
5852:C 24 Jan 2019 23:00:07.676 # Redis version=5.0.3, bits=64, commit=00000000, modified=0, pid=5852, just started
5852:C 24 Jan 2019 23:00:07.676 # Configuration loaded
5852:M 24 Jan 2019 23:00:07.676 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._
           _.-``__ ‘‘-._
      _.-``    `.  `_.  ‘‘-._           Redis 5.0.3 (00000000/0) 64 bit
  .-`` .-```.  ```/    _.,_ ‘‘-._
 (    ‘      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|‘` _.-‘|     Port: 6379
 |    `-._   `._    /     _.-‘    |     PID: 5852
  `-._    `-._  `-./  _.-‘    _.-‘
 |`-._`-._    `-.__.-‘    _.-‘_.-‘|
 |    `-._`-._        _.-‘_.-‘    |           http://redis.io
  `-._    `-._`-.__.-‘_.-‘    _.-‘
 |`-._`-._    `-.__.-‘    _.-‘_.-‘|
 |    `-._`-._        _.-‘_.-‘    |
  `-._    `-._`-.__.-‘_.-‘    _.-‘
      `-._    `-.__.-‘    _.-‘
          `-._        _.-‘
              `-.__.-‘

5852:M 24 Jan 2019 23:00:07.677 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
5852:M 24 Jan 2019 23:00:07.677 # Server initialized
5852:M 24 Jan 2019 23:00:07.677 # 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.
5852:M 24 Jan 2019 23:00:07.677 # 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.
5852:M 24 Jan 2019 23:00:07.677 * Ready to accept connections

 二、解决方法

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.

# 对一个高负载的环境来说tcp设置128这个值,太小了。

临时生效
echo 1024 > /proc/sys/net/core/somaxconn

永久生效
vim /etc/sysctl.conf
net.core.somaxconn = 1024
sysctl -p

2、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_memory参数说明:
设置内存分配策略(可选,根据服务器的实际情况进行设置)
/proc/sys/vm/overcommit_memory
可选值:0、1、2。
0、表示内核将检查是否有足够的可用内存供应用进程使用;如果有足够的可用内存,内存申请允许;否则,内存申请失败,并把错误返回给应用进程。
1、表示内核允许分配所有的物理内存,而不管当前的内存状态如何。
2、表示内核允许分配超过所有物理内存和交换空间总和的内存

临时生效
echo 1 > /proc/sys/vm/overcommit_memory

永久生效
vim /etc/syctl.conf
vm.overcommit_memory = 1
sysctl -p


3、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.

# 你使用的是透明大页,可能导致redis延迟和内存使用问题。

临时生效
echo never > /sys/kernel/mm/transparent_hugepage/enabled

永久生效
vim /etc/rc.local
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
    echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi

chmod +x /etc/rc.local

 三、修改后启动无报错状态

# /usr/local/redis/bin/redis-server /usr/local/src/redis-5.0.3/redis.conf
1228:C 24 Jan 2019 23:26:50.044 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1228:C 24 Jan 2019 23:26:50.044 # Redis version=5.0.3, bits=64, commit=00000000, modified=0, pid=1228, just started
1228:C 24 Jan 2019 23:26:50.044 # Configuration loaded
1228:M 24 Jan 2019 23:26:50.044 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._
           _.-``__ ‘‘-._
      _.-``    `.  `_.  ‘‘-._           Redis 5.0.3 (00000000/0) 64 bit
  .-`` .-```.  ```/    _.,_ ‘‘-._
 (    ‘      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|‘` _.-‘|     Port: 6379
 |    `-._   `._    /     _.-‘    |     PID: 1228
  `-._    `-._  `-./  _.-‘    _.-‘
 |`-._`-._    `-.__.-‘    _.-‘_.-‘|
 |    `-._`-._        _.-‘_.-‘    |           http://redis.io
  `-._    `-._`-.__.-‘_.-‘    _.-‘
 |`-._`-._    `-.__.-‘    _.-‘_.-‘|
 |    `-._`-._        _.-‘_.-‘    |
  `-._    `-._`-.__.-‘_.-‘    _.-‘
      `-._    `-.__.-‘    _.-‘
          `-._        _.-‘
              `-.__.-‘

1228:M 24 Jan 2019 23:26:50.045 # Server initialized
1228:M 24 Jan 2019 23:26:50.045 * DB loaded from disk: 0.000 seconds
1228:M 24 Jan 2019 23:26:50.045 * Ready to accept connections

 

以上是关于Redis 5.0.3默认配置启动报错解决方法的主要内容,如果未能解决你的问题,请参考以下文章

redis部分配置与报错解决

SpringBoot项目启动报错踩坑

MongoDB基础操作

Redis报错:ERR This instance has cluster support disabled

项目启动报错Redis health check failed:Unable to connect to localhost:6379

windows下redis的安装和启动