1、编写启动服务文件 /lib/systemd/system/redis.service
[Unit]
Description=The redis-server Process Manager
Documentation=https://redis.io/
After=network.target
[Service]
Type=forking
#根据自己的redis路径启动和停止
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/redis.conf
ExecStop=/usr/local/redis/bin/redis-cli shutdown
[Install]
WantedBy=multi-user.target
2、添加开机启动
systemctl daemon-reload
systemctl enable redis