When learning redis, you need to manually open redis every time. For convenience, set a boot-up self-start
1. Create a new system service file:
vi /etc/systemd/system/redis.service
[Unit]
Description=redis-server
After=network.target
[Service]
Type=forking
ExecStart=/opt/software/redis-6.2.6/src/redis-server /etc/redis.conf
PrivateTmp=true
[Install]
WantedBy=multi-user.target
ExecStart=/opt/software/redis-6.2.6/src/redis-server : the location of the command to start the service
/etc/redis.conf The location of the configuration file command
2. Overload system services
systemctl daemon-reload
Now you can turn it on, turn it off, and check the status
# 启动
systemctl start redis
# 停止
systemctl stop redis
# 重启
systemctl restart redis
# 查看状态
systemctl status redis
3. Set the boot to start automatically
systemctl enable redis