OpenEuler 20.03 LTS yum 安装redis后systemctl启动异常
前言通过命令yum install redis,安装redis后,通过systemctl启动报如下错误:[root@ecs-e505 ~]# systemctl start redisJob for redis.service failed because the control process exited with error code.See "systemctl status redis.
·
前言
通过命令yum install redis
,安装redis后,通过systemctl
启动报如下错误:
[root@ecs-e505 ~]# systemctl start redis
Job for redis.service failed because the control process exited with error code.
See "systemctl status redis.service" and "journalctl -xe" for details.
[root@ecs-e505 ~]# systemctl status redis
● redis.service - Redis persistent key-value database
Loaded: loaded (/usr/lib/systemd/system/redis.service; disabled; vendor pres>
Active: failed (Result: exit-code) since Fri 2022-02-18 14:05:57 CST; 33s ago
Process: 2945 ExecStart=/usr/bin/redis-server /etc/redis.conf --supervised sy>
Main PID: 2945 (code=exited, status=217/USER)
2月 18 14:05:57 ecs-e505 systemd[1]: Starting Redis persistent key-value databa>
2月 18 14:05:57 ecs-e505 systemd[1]: redis.service: Main process exited, code=e>
2月 18 14:05:57 ecs-e505 systemd[1]: redis.service: Failed with result 'exit-co>
2月 18 14:05:57 ecs-e505 systemd[1]: Failed to start Redis persistent key-value>
/usr/lib/systemd/system/redis.service
默认服务文件内容如下:
[Unit]
Description=Redis persistent key-value database
After=network.target
[Service]
ExecStart=/usr/bin/redis-server /etc/redis.conf --supervised systemd
Type=notify
User=redis
Group=redis
RuntimeDirectory=redis
RuntimeDirectoryMode=0755
[Install]
WantedBy=multi-user.target
可以看到,服务文件默认使用redis
用户启动服务,使用的配置文件路径为/etc/redis.conf
。配置文件redis.conf
中有如下配置:
# The working directory.
#
# The DB will be written inside this directory, with the filename specified
# above using the 'dbfilename' configuration directive.
#
# The Append Only File will also be created inside this directory.
#
# Note that you must specify a directory here, not a file name.
dir /var/lib/redis
默认工作路径为/var/lib/redis
。
解决办法
执行如下命令创建redis
用户及运行环境
mkdir /var/lib/redis # 创建工作路径,默认没有这个文件夹
mkdir /var/log/redis # 创建日志路径,默认没有这个文件夹
groupadd redis #新增用户组
useradd -M redis -g redis -s /sbin/nologin #新建用户redis并加入admin组中,并禁止登录
chown -R redis:redis /var/lib/redis # 修改工作路径拥有者
chown -R redis:redis /var/log/redis # 修改日志路径拥有者
chmod 644 /etc/redis.conf # 修改默认配置文件权限为644,默认为640
启动redis
服务:
[root@ecs-e505 ~]# systemctl start redis # 启动成功
[root@ecs-e505 ~]# systemctl status redis # 查看运行状态
● redis.service - Redis persistent key-value database
Loaded: loaded (/usr/lib/systemd/system/redis.service; disabled; vendor pres>
Active: active (running) since Fri 2022-02-18 15:20:05 CST; 1min 52s ago
Main PID: 3005 (redis-server)
Tasks: 4
Memory: 2.5M
CGroup: /system.slice/redis.service
└─3005 /usr/bin/redis-server 127.0.0.1:6379
2月 18 15:20:05 ecs-e505 systemd[1]: Starting Redis persistent key-value databa>
2月 18 15:20:05 ecs-e505 systemd[1]: Started Redis persistent key-value databas>
更多推荐
已为社区贡献4条内容
所有评论(0)