【Redis】centos7 systemctl 启动 Redis 失败

今天启动 Redis 时阻塞很长时间,之后显示启动失败,启动状态如下。

  1. systemd[1]: redis.service start operation timed out. Terminating.

  2. systemd[1]: Failed to start A persistent key-value database.

  3. systemd[1]: Unit redis.service entered failed state.

看了下 service 文件,发现 Systemd 启动命令如下

复制代码
ExecStart=/usr/sbin/redis-server /etc/redis.conf

手动运行这条命令,发现是正常的,所以猜想是 service 文件的问题,后来发现只需要把 [Service] 部分的Type=forking注释掉就行了。

  1. [Service]

  2. # Type=forking

  3. # PIDFile=/var/run/redis/redis.pid

  4. ExecStart=/usr/sbin/redis-server /etc/redis.conf

  5. User=redis

  6. Group=redis

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

复制代码
sudo systemctl daemon-reload

sudo systemctl start redis

Man pages 对 Systemd 服务启动类型 Type 的解释如下

复制代码
If set to forking, it is expected that the process configured with ExecStart= will call fork() as part of its start-up. The parent process is expected to exit when start-up is complete and all communication channels are set up. The child continues to run as the main daemon process. This is the behavior of traditional UNIX daemons. If this setting is used, it is recommended to also use the PIDFile= option, so that systemd can identify the main process of the daemon. systemd will proceed with starting follow-up units as soon as the parent process exits.

因为 Redis 配置文件里配置的是
daemonize no

相关推荐
7ioik18 小时前
说一说MySQL数据库基本架构?
数据库·mysql·架构
@淡 定18 小时前
Redis持久化机制
数据库·redis·缓存
云老大TG:@yunlaoda36018 小时前
华为云国际站代理商DAS的跨境合规适配是如何保障数据合规的?
网络·数据库·华为云
TG:@yunlaoda360 云老大18 小时前
华为云国际站代理商HiLens的技术优势对跨境客户有哪些具体帮助?
服务器·数据库·华为云
+VX:Fegn089518 小时前
计算机毕业设计|基于springboot + vue健身房管理系统(源码+数据库+文档)
数据库·vue.js·spring boot·后端·课程设计
Leon-Ning Liu18 小时前
当SGA大于hugepage的时候,Oracle数据库是怎么使用hugepage的
数据库·oracle
马克学长18 小时前
SSM校园二手交易系统aqj3i(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面
数据库·ssm 框架·javaweb 开发
利剑 -~18 小时前
letcode数据库题联系
数据库
小程故事多_8018 小时前
Agent Skills深度解析,让智能体从“会连接”到“会做事”的核心引擎
数据库·人工智能·aigc
2501_9411481519 小时前
从边缘节点到云端协同的分布式缓存一致性实现原理实践解析与多语言代码示例分享笔记集录稿
笔记·分布式·物联网·缓存