[Unit] Description=The redis-server Process Manager Documentation=https://redis.io/ After=network.target [Service] Type=forking ExecStart=/root/redis-5.0.7/src/redis-server /root/redis-5.0.7/redis.conf
#有密码则需要在cli后面加 -a "密码" ExecStop=/root/redis-5.0.7/src/redis-cli shutdown [Install] WantedBy=multi-user.target
1.先输入
vi /lib/systemd/system/redis.service
把上述配置复制进去,保存退出
2.设置开机自启动
systemctl enable redis
3.使用命令
#开启服务 systemctl start redis #停止服务 systemctl stop redis #查看运行状态 system status redis