vim /usr/lib/systemd/system/redis.service
[Unit]
Description=Redis Server
Documentation=https://redis.io
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
Type=forking
Group=root
User=root
ExecStart=/opt/redis/bin/redis-server /opt/redis/redis.conf
Restart=always
PrivateTmp=true
[Install]
WantedBy=multi-user.target
其中
/opt/redis/bin/redis-server
为 redis-server 可执行文件路径,/opt/redis/redis.conf
为配置文件路径,根据具体环境配置即可
systemctl daemon-reload
systemctl enable redis.service
附:操作命令
systemctl status redis.service
systemctl start redis.service
systemctl stop redis.service
systemctl reload redis.service
systemctl enable redis.service
systemctl disable redis.service
redis-server --service-install redis.windows-service.conf --loglevel verbose --service-name redis
其中
redis.windows-service.conf
为配置文件,redis
为服务名称,根据具体环境配置即可
redis-server --service-start --service-name redis
附:操作命令
redis-server --service-stop
redis-server --service-uninstall