systemctl管理Redis
背景
直接編譯安裝的redis沒有直接service管理,試試使用systemctl管理吧。
1.編輯服務文件
vim /usr/lib/systemd/system/redis.service
[Unit]
Description=Redis persistent key-value database
After=network.target
[Service]
ExecStart=/home/data/redis/bin/redis-server /home/data/redis/etc/redis.conf --supervised systemd
ExecStop=/bin/kill -s QUIT $MAINPID
Type=notify
User=redis
Group=redis
RuntimeDirectory=redis
RuntimeDirectoryMode=0755
[Install]
WantedBy=multi-user.target
2.加載服務,啓動
systemctl daemon-reload
systemctl enable redis
systemctl start redis