【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

相关推荐
YangYang9YangYan1 小时前
商业数据分析校招项目怎么选,附项目设计与简历包装思路
大数据·数据库·数据分析
李白客1 小时前
数据库培训怎么选?零基础到DBA的学习路线与机构认证对比(2026)
数据库·学习
shark-chili2 小时前
关于AI辅助编程的认知
数据库·人工智能·redis·macos·缓存
SendTomo2 小时前
.ico透明图标在线生成下载平台深度解析
大数据·数据结构·数据库·数据仓库·个人开发
蓝速科技2 小时前
国产化信创终端等保合规核心防护与落地方案丨蓝速科技
大数据·运维·数据库·人工智能·科技
IvorySQL2 小时前
PostgreSQL 日报|在线校验和特性被回退(9 月 17 日)
数据库·人工智能·postgresql
实验室管理云平台2 小时前
北京盛元广通检测管理方案:信息集成、质量控制与移动应用
大数据·数据库·科技
IT大白鼠2 小时前
MySQL 高可用系列 · Orchestrator + ProxySQL 第三篇——核心原理精讲
数据库·mysql·架构
刘天远3 小时前
Agent系统接入编排:评分模型、状态机与Python门禁
数据库·人工智能·python
DBA_G3 小时前
GBase数据库安全“全牌照“技术解读:从等保四级到全密态计算的实践
数据库