centos7 将redis加入到systemctl开机启动项

相关阅读 https://www.ruanyifeng.com/blog/2016/03/systemd-tutorial-commands.html

相关阅读 http://www.ruanyifeng.com/blog/2013/08/linux_boot_process.html

redis安装参考 http://www.suphp.cn/news/62/62.html

1 编辑systemctl服务配置文件

vi /etc/systemd/system/redis.service

2 内容如下

[Unit]
Description=Redis
After=network.target
[Service]
Type=forking
PIDFile=/redis/redis6379.pid
ExecStart=/usr/local/bin/redis-server /redis/conf/redis6379.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target

3 重载系统服务

systemctl daemon-reload

4 查看状态

systemctl status redis

5 启动redis

systemctl start redis
systemctl restart redis

6 设置开机启动

systemctl enable redis

7 禁止开机启动

systemctl disable redis

8 查看redis服务是否在systemctl中

systemctl list-units |grep redis


(完)