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
相关文章
|
6月前
|
NoSQL Linux Redis
Linux centos8安装redis
Linux centos8安装redis
271 0
|
2月前
|
存储 NoSQL Linux
centos7部署redis以及多实例
centos7部署redis以及多实例
55 0
|
2月前
|
NoSQL Linux Redis
基于centos7.7编译Redis6.0
基于centos7.7 源码编译redis-6.0.6记录
164 2
|
2月前
|
NoSQL 应用服务中间件 Linux
CentOS7搭建MySQL+Redis+MongoDB+FastDF
CentOS7搭建MySQL+Redis+MongoDB+FastDF
138 0
|
3月前
|
消息中间件 NoSQL Linux
什么是Redis数据库,如何在 CentOS 7 上安装 Redis,看完你就懂了
【1月更文挑战第1天】Redis ,是一个高性能(NOSQL)的key-value数据库,Redis是一个开源的使用ANSI C语言编写、支持网络、可基于内存亦可持久化的日志型、Key-Value数据库,并提供多种语言的API。Redis是完全开源免费的,遵守BSD协议。
什么是Redis数据库,如何在 CentOS 7 上安装 Redis,看完你就懂了
|
4月前
|
存储 缓存 NoSQL
CentOS7 下源码安装Redis并配置服务开机启动
CentOS7 下源码安装Redis并配置服务开机启动
109 1
|
7月前
|
NoSQL Linux Redis
百度搜索:蓝易云【Centos8 stream系统编译安装Redis教程。】
以上是在CentOS 8 Stream系统上编译安装Redis的基本教程。请注意,具体的配置和参数可能因您的需求而有所不同,您可以根据自己的情况进行调整。同时,请确保在执行任何操作之前备份重要的文件和配置。
300 1
|
存储 缓存 NoSQL
Centos安装Redis
Centos安装Redis
Centos安装Redis
|
存储 缓存 NoSQL
centos7 安装Redis
centos7 安装Redis
centos7 安装Redis
|
NoSQL Linux 网络安全
CentOS 安装 Redis
CentOS 安装 Redis
601 0
CentOS 安装 Redis