redis 自动启动
时间: 2023-10-19 11:34:10 浏览: 141
要使Redis在系统启动时自动启动,你可以按照以下步骤进行操作:
1. 打开终端并登录到Redis服务器。
2. 使用以下命令编辑Redis配置文件(redis.conf):
```
sudo vi /etc/redis/redis.conf
```
3. 在配置文件中找到以下行:
```
# If you run Redis from upstart or systemd, Redis can interact with your
# supervision tree. Options:
# supervised no - no supervision interaction
# supervised upstart - signal upstart by putting Redis into SIGSTOP mode
# supervised systemd - signal systemd by writing READY=1 to $NOTIFY_SOCKET
# supervised auto - detect upstart or systemd method based on
# UPSTART_JOB or NOTIFY_SOCKET environment variables
# Note: these supervision methods only signal the process, and do not
# auto-restart Redis after crashes.
```
4. 将`supervised no`行修改为`supervised systemd`:
```
supervised systemd
```
5. 保存并关闭文件。
6. 重新启动Redis服务:
```
sudo systemctl restart redis
```
现在,Redis将在系统启动时自动启动。您可以使用以下命令来验证Redis是否正在运行:
```
sudo systemctl status redis
```
确保状态为"active (running)"表示Redis已成功启动,并在系统重启后自动启动。
阅读全文