skip to content
Wentao Zhang

Linux yum 安装 Redis 踩坑

/ 1 min read

Linux yum 安装 Redis 踩坑

安装命令

yum install -y redis

启动报错

启动命令service redis start,以下是具体报错信息

Terminal window
[root@master01 etc]# systemctl status redis.service
redis.service - Redis persistent key-value database
Loaded: loaded (/usr/lib/systemd/system/redis.service; disabled; vendor pres>
Active: failed (Result: exit-code) since Mon 2023-09-04 11:39:56 CST; 6min a>
Process: 51746 ExecStart=/usr/bin/redis-server /etc/redis.conf --supervised s>
Main PID: 51746 (code=exited, status=217/USER)
9月 04 11:39:56 master01 systemd[1]: Starting Redis persistent key-value databa>
9月 04 11:39:56 master01 systemd[1]: redis.service: Main process exited, code=e>
9月 04 11:39:56 master01 systemd[1]: redis.service: Failed with result 'exit-co>
9月 04 11:39:56 master01 systemd[1]: Failed to start Redis persistent key-value>

分析以后发现是没有权限导致的,以下是解决方案

Terminal window
mkdir /var/lib/redis;
mkdir /var/log/redis;
groupadd redis;
useradd -M redis -g redis -s /sbin/nologin;
chown -R redis:redis /var/lib/redis;
chown -R redis:redis /var/log/redis;
chmod 644 /etc/redis.conf;

依次执行之后再使用service redis start 就能成功启动