redis配置systemctl

vim /lib/systemd/system/redis.service

[Unit]
Description=redis
After=network.target

[Service]
Type=forking
PIDFile=/var/run/redis_6379.pid
ExecStart=/usr/local/redis/src/redis-server /usr/local/redis/redis.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

注意,路径替换成你自己的安装路径, pid路径和 redis.conf里面的路径保持一致
systemctl daemon-reload //刚刚配置的服务需要让systemctl能识别,就必须刷新配置
systemctl enable redis.service //加入开机启动

原文地址:https://www.cnblogs.com/lazy-sang/p/12034997.html