Home >Database >Redis >How to configure Redis as a system service in CentOS

How to configure Redis as a system service in CentOS

藏色散人
藏色散人forward
2020-04-26 14:21:042011browse

Create redis.service

cd  /usr/lib/systemd/system
touch redis.service

Related recommendations: "centos tutorial"

Edit content

[Unit]
Description=Redis Server
After=network.target
[Service]
PIDFile=/var/run/redis_6379.pid
ExecStart=/usr/local/bin/redis-server /etc/redis.conf
ExecStop=/usr/local/bin/redis-cli -a passwd shutdown
ExecReload=/bin/kill -s HUP $MAINPID
[Install]
WantedBy=mutli-user.target

Reload systemctl and Start service

systemctl daemon-reload
systemctl start redis.service

Check status

systemctl status redis.service

Close Redis

systemctl stop redis.service

Auto-start at boot

systemctl enable redis.service

Whether to start automatically at boot

systemctl is-enabled redis.service

More For redis knowledge, please pay attention to the redis introductory tutorial column.

The above is the detailed content of How to configure Redis as a system service in CentOS. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete