首先我们已经在linux服务器上安装好redis服务
- 在
/etc/systemd/system
下新建redis.service,并添加一下内容 - 注意
/usr/local/redis
路径修改成自己安装的redis路径
[Unit] Description=Redis After=network.target [Service] Type=forking ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/bin/redis.conf ExecReload=/usr/local/redis/bin/redis-server -s reload ExecStop=/usr/local/redis/bin/redis-server -s stop PrivateTmp=true [Install] WantedBy=multi-user.target
配置完以后就可以 运行 systemctl start redis
启动redis
systemctl
的一些其他命令
systemctl enable redis # 开机自启redis服务 systemctl disable redis # 取消开机自启 systemctl start redis # 启动redis服务 systemctl stop redis # 停止服务 systemctl restart redis # 重新启动服务 systemctl status redis # 查看服务当前状态 systemctl list-units --type=service # 查看所有已启动的服务 systemctl daemon-reload # 加载服务配置文件