【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

相关推荐
light blue bird17 小时前
MES/ERP的Web多页签报表系统
数据库·node.js·ai大数据·mes/erp·web报表
九章-17 小时前
医疗系统数据库选型技术指南:从合规性到高性能的全方位考量
数据库·信创·医疗信创
Predestination王瀞潞17 小时前
4.1.1 存储->数据库:MongoDB
数据库·mongodb
JZC_xiaozhong17 小时前
ERP与MES制造数据同步:痛点破解与高效落地实践
大数据·数据库·制造·数据传输·数据孤岛解决方案·数据集成与应用集成·异构数据整合
墨着染霜华18 小时前
Java实战:封装Redis非阻塞分布式锁,彻底解决表单重复提交主键冲突
java·redis·分布式
尽兴-18 小时前
超越缓存:Redis Stack 如何将 Redis 打造成全能实时数据平台
数据库·redis·缓存·redis stack
胡西风_foxww18 小时前
nextjs部署更新,Turbopack 和 Webpack 缓存冲突问题解决
缓存·webpack·react·nextjs·turbopack
Qlittleboy18 小时前
TP5.0的“请求缓存”,把页面缓存为静态HTML文件,提升加载速度
前端·缓存·html·php
Lution Young18 小时前
缓存命中率
缓存
一个有温度的技术博主18 小时前
Redis系列七:Java客户端Jedis的入门
java·数据库·redis