1、修改 redis.conf 文件,把 daemonize no 改为 daemonize yes
2、vim /usr/lib/systemd/system/redis.service,添加如下内容
[Unit]
Description=redis
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/bin/redis.conf
ExecReload=/bin/kill -s HUP $MAINPID
这个根据配置填写
ExecStop=/usr/local/redis/bin/redis-cli -p 6379 -a 123456 shutdown
PrivateTmp=true
[Install]
WantedBy=multi-user.target
3、systemctl daemon-reload
4、systemctl restart redis
5、systemctl enable redis