redis配置systemctl

tee /lib/systemd/system/redis.service << 'EOF'
[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
EOF

注意,路径替换成你自己的安装路径, pid路径和 redis.conf里面的路径保持一致

systemctl daemon-reload	#刚刚配置的服务需要让systemctl能识别,就必须刷新配置
systemctl enable redis.service #加入开机启动
posted @ 2019-12-13 14:40  左岸丶  阅读(1277)  评论(0)    收藏  举报