【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

相关推荐
l1t5 分钟前
DeepSeek总结的PostgreSQL 中的 SQL 与 PL/pgSQL:计划缓存
sql·缓存·postgresql
JJJennie77722 分钟前
MAI Gateway实战部署:大模型网关部署方案?从0到1上手指南
数据库·人工智能·gateway·ai网关
吹什么轩25 分钟前
MySQL 内连接与外连接:从笛卡尔积到 LEFT JOIN,一篇讲透
数据库·mysql
涛思数据(TDengine)25 分钟前
支撑药企全球化合规:TDengine 发布中美欧三地监管对照白皮书
大数据·数据库·人工智能·ai·tdengine
李兆龙的博客29 分钟前
从一到无穷大 #106:Nimble 文件格式——超宽表的元数据、编码与索引设计
数据库·存储·parquet
boy快快长大33 分钟前
MySQL 转 PostgreSQL 使用指南
数据库·mysql·postgresql
晴天¥40 分钟前
Oracle集群中是该如何管理控制文件和日志文件组?
数据库·oracle
NineData1 小时前
NineData 社区版 V5.4.0 上线:715 条复制对比链路,AI Agent 新增表结构设计发布能力
大数据·数据库·人工智能·mysql·数据库管理工具·ninedata·数据库迁移工具
云策数链1 小时前
用友 T+Cloud / U8 项目交接时的账套健康度核查清单
数据库·oracle·erp·用友·云策数链
Tt有了t1 小时前
Redis的数据结构
数据结构·数据库·redis