linux服务器断电后重起RedisRedis服务时出现如下四个报错,在这里记录一下。

服务器系统版本CentOS 7.8

报错:

1.Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf

意思是,未指定配置文件,这里需要我们指定配置文件 redis.conf

解决方案:
①使用find命令查找redis.conf文件

find / -name redis.conf

②使用命令执行配置文件

cd /home/redis-4.1.1/src
redis-server /etc/redis.conf 或者 ./redis-server /etc/redis.conf

 ③使用命令查看服务是否启动成功

ps aux | grep redis
或者
netstat -ntlp

以下界面是服务起来了的效果 (以Nginx服务为例)

请添加图片描述

以下界面是服务没起来的效果,没有nginx进程 

ps 显示出来的是grep nginx进程,它是一个grep进程,不是nginx进程

请添加图片描述  

2.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 太小了

解决方案:

①修改配置文件 vim /etc/sysctl.conf

(1)写入:net.core.somaxconn=551 # 这里的数据根据生产的需要和电脑的性能进行调整 必须 大于等于 551

注意:修改配置文件时要按insert切换最下侧显示insert后录入;保存时按esc然后按冒号“:”,输入wq保存退出

(2)保存之后执行 sysctl -p 使得修改生效,可以再次利用命令vim /etc/sysctl.conf进入配置文件查看是否修改成功

3.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 的值设置为0时 在低内存条件下,后台保存可能会失败

解决方案:

①修改配置文件 vim /etc/sysctl.conf

(1)写入:vm.overcommit_memory=1

注意:修改配置文件时要按insert切换最下侧显示insert后录入;保存时按esc然后按冒号“:”,输入wq保存退出

(2)保存之后执行 sysctl -p 使得修改生效,可以再次利用命令vim /etc/sysctl.conf进入配置文件查看是否修改成功

4.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建议修改Transparent Huge Pages(THP) 的相关配置,Linux kernel在2.6.38内核增加了THP特性, 支持大内存页(2MB) 分配, 默认开启。 当开启时可以降低fork子进程的速度, 但fork操作之后, 每个内存页从原来4KB变为2MB, 会大幅增加重写期间父进程内存消耗。 同时每次写命令引起的复制内存页单位放大了512倍, 会拖慢写操作的执行时间, 导致
大量写操作慢查询。

解决方案:

①Redis日志中建议将此特性进行禁用, 禁用方法如下:

echo never > /sys/kernel/mm/transparent_hugepage/enabled

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐