vi /etc/systemd/system/redis.service
i
[Unit]
Description=redis-server
After=network.target[Service]
Type=forking#使用(/usr/local/bin/redis-server)运行(/usr/local/src/redis-6.2.6/redis.conf)
ExecStart=/usr/local/bin/redis-server /usr/local/src/redis-6.2.6/redis.conf
PrivateTmp=true[Install]
WantedBy=multi-user.target
:wq
#加载服务配置文件
systemctl daemon-reload
#启动redis
systemctl start redis
#设置开机自启
systemctl enable redis
#查看启动状态
systemctl status redis