centos7 systemctl 启动 Redis 失败

本文涉及的产品
云数据库 Redis 版,社区版 2GB
推荐场景:
搭建游戏排行榜
简介: 转自:http://sloger.info/posts/systemd-failed-to-start-redis-in-gentoo今天启动 Redis 时阻塞很长时间,之后显示启动失败,启动状态如下。

转自:http://sloger.info/posts/systemd-failed-to-start-redis-in-gentoo

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

systemd[1]: redis.service start operation timed out. Terminating.
systemd[1]: Failed to start A persistent key-value database.
systemd[1]: Unit redis.service entered failed state.

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

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

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

[Service]
# Type=forking
# PIDFile=/var/run/redis/redis.pid
ExecStart=/usr/sbin/redis-server /etc/redis.conf
User=redis
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 off

相关实践学习
基于Redis实现在线游戏积分排行榜
本场景将介绍如何基于Redis数据库实现在线游戏中的游戏玩家积分排行榜功能。
云数据库 Redis 版使用教程
云数据库Redis版是兼容Redis协议标准的、提供持久化的内存数据库服务,基于高可靠双机热备架构及可无缝扩展的集群架构,满足高读写性能场景及容量需弹性变配的业务需求。 产品详情:https://www.aliyun.com/product/kvstore     ------------------------------------------------------------------------- 阿里云数据库体验:数据库上云实战 开发者云会免费提供一台带自建MySQL的源数据库 ECS 实例和一台目标数据库 RDS实例。跟着指引,您可以一步步实现将ECS自建数据库迁移到目标数据库RDS。 点击下方链接,领取免费ECS&RDS资源,30分钟完成数据库上云实战!https://developer.aliyun.com/adc/scenario/51eefbd1894e42f6bb9acacadd3f9121?spm=a2c6h.13788135.J_3257954370.9.4ba85f24utseFl
相关文章
|
11天前
|
存储 NoSQL Linux
centos7部署redis以及多实例
centos7部署redis以及多实例
68 0
|
11天前
|
NoSQL Linux Redis
在CentOS上安装和配置Redis
在CentOS上安装和配置Redis
97 0
|
11天前
|
NoSQL Linux Redis
本地虚拟机centos7通过docker安装主从redis3.2
本地虚拟机centos7通过docker安装主从redis3.2
27 0
|
11天前
|
NoSQL Linux Redis
基于centos7.7编译Redis6.0
基于centos7.7 源码编译redis-6.0.6记录
209 2
|
11天前
|
NoSQL 应用服务中间件 Linux
CentOS7搭建MySQL+Redis+MongoDB+FastDF
CentOS7搭建MySQL+Redis+MongoDB+FastDF
149 0
|
11天前
|
消息中间件 NoSQL Linux
什么是Redis数据库,如何在 CentOS 7 上安装 Redis,看完你就懂了
【1月更文挑战第1天】Redis ,是一个高性能(NOSQL)的key-value数据库,Redis是一个开源的使用ANSI C语言编写、支持网络、可基于内存亦可持久化的日志型、Key-Value数据库,并提供多种语言的API。Redis是完全开源免费的,遵守BSD协议。
什么是Redis数据库,如何在 CentOS 7 上安装 Redis,看完你就懂了
|
11天前
|
前端开发 jenkins 持续交付
新的centos7.9安装docker版本的jenkins2.436.1最新版本-前端项目发布(五)
新的centos7.9安装docker版本的jenkins2.436.1最新版本-前端项目发布(五)
33 1
|
11天前
|
jenkins 网络安全 持续交付
新的centos7.9安装docker版本的jenkins2.436.1最新版本-后端项目发布(四)
新的centos7.9安装docker版本的jenkins2.436.1最新版本-后端项目发布(四)
43 3
|
2天前
|
存储 Linux 虚拟化
Hyper-V 安装 CentOS 8.5
本文档介绍了在 Windows 10 上使用 Hyper-V 安装 CentOS 8.5.2111 的详细步骤
18 3