1.关闭守护线程(默认是no)
vim /data/redis/redis.conf
#找到 daemonize yes
修改为
daemonize no
2.将redis服务配置为系统服务
vim /usr/lib/systemd/system/redisd.service
[Unit]
Description=The redis-server Process Manager
After=syslog.target network.target
[Service]
Type=forking
PIDFile=/var/run/redis_6379.pid
ExecStart=/usr/local/bin/redis-server /data/redis/redis.conf #根据自己安装目录进行修改
ExecReload=/bin/kill -s -HUP $MAINPID
ExecStop=/bin/kill -s -QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
3.测试
重载系统服务
systemctl daemon-reload
启动redis
systemctl start redisd
设置开机自启动
systemctl enable redisd
查看运行状态<