启动redis.service一直卡住了,最后报错

来源:4-3 应用服务化

灵魂百度

2021-03-07 10:55:56

相关截图:

1.  redis.service文件截图如下:

http://img.mukewang.com/climg/60443f4e09cd44e109620362.jpg

2.启动redis服务 运行结果截图

http://img.mukewang.com/climg/60444054099032d112160298.jpg

3.查看redis status

http://img.mukewang.com/climg/604440aa09bbaa4712280469.jpg


问题:这该如何解决了?

写回答

2回答

球状闪电2012

2021-03-07

启动不成功的问题我也碰到了。我折腾了一天时间。

正好在这里记录一下,希望能帮到您。


启动不成功之后,可以运行这个命令看日志。

systemctl status redis.service -l


日志中可能出现很多原因导致启动不成功,同时也提供了解决方法

#如果出现
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.
#可以执行
sysctl vm.overcommit_memory=1

#如果出现
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.
#可以执行
echo never > /sys/kernel/mm/transparent_hugepage/enabled

#如果出现
Increased maximum number of open files to 10032 (it was originally set to 1024)
#可以执行
ulimit -n 10032

#我没保存住出现某个提示的话 应该有关键字somaxconn
#可以先到 /proc/sys/net/core/ 目录
cd /proc/sys/net/core/
#然后执行(将somaxconn文件里边的数字改为511 保存)
echo 511 > ./somaxconn

#可能还会碰到的问题是/usr/lib/systemd/system/redis.service文件的权限太小 要给这个文件足够的权限
chmod 777 ./redis.service

#可能还会碰到的问题是redis.service中  注释掉Type=forking
#或者更改为 Type=simple

总之以上各种情况我都碰到了。建议老师能重新录制一下这节课程。
我确实是跟着老师一步一步,一点儿错误都没有出现过,操作下来,结果启动不了。
最后用一天时间才启动redis. 这一天我过的很痛苦,最后搞定了问题很开心。
还是很感谢老师循循善诱的课程。


2

好帮手慕阿满

2021-03-07

同学你好,建议同学看一下是否启动了redis,如果启动了,先关闭redis,如下:

ps -ef | grep redis
kill 进程id

http://img.mukewang.com/climg/60010f3d09e0b21300000000.jpg

​然后建议同学注释Type=forking 再试试,如:

[Service]
#Type=forking
#PIDFile=/run/redis_6379.pid
ExecStart=/usr/local/redis-4.0.14/src/redis-server /usr/local/redis-4.0.14/redis.conf
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

之后重新加载 Service 文件并启动 Redis 服务

sudo systemctl daemon-reload
sudo systemctl start redis

祝学习愉快~

0

0 学习 · 16556 问题

查看课程