Centos版本:7.4
image.png
redis版本:4.0.11
image.png
系统操作用户:root
image.png
步骤:
1.新建redis.service服务文件
vim /usr/lib/systemd/system/redis.service
2.redis.service文件的内容
[Unit]
Description=Redis Server Manager
After=syslog.target network.target
[Service]
Type=forking
PIDFile=/var/run/redis_6379.pid
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/bin/redis.conf
ExecReload=/bin/kill -USR2 $MAINPID
ExecStop=/bin/kill -SIGINT $MAINPID
[Install]
WantedBy=multi-user.target
3.ExecStart参数需要注意下,这里我的安装路径是"/usr/local/redis/bin",更改为各自的安装路径
4.刷新systemctl
systemctl daemon-reload
5.启动redis
systemctl start redis
5.设置redis开机自启动
systemctl enable redis