Home  >  Article  >  Database  >  Specific steps to add systemctl service to redis

Specific steps to add systemctl service to redis

王林
王林forward
2021-03-04 09:23:283722browse

Specific steps to add systemctl service to redis

1. Install redis

First we need to download the latest version of redis from the official website

$ wget http://download.redis.io/releases/redis-4.0.11.tar.gz
$ tar xzf redis-4.0.11.tar.gz
$ mv redis-4.0.11 redis  //改个名字
$ cd redis
$ make

Then select the installation path

Install After uploading, create a /etc directory and put the configuration file in it

$ mkdir etc
$ mv redis.conf etc/redis.conf

Then modify the configuration file

$ cd etc
$ vi redis.conf

Finally change daemonize no to daemonize yes This option means that redis runs in the background

Specific steps to add systemctl service to redis

redis has been installed successfully, test it

/usr/local/redis/src/redis-server /usr/local/redis/etc/ redis.conf

Specific steps to add systemctl service to redis

Specific steps to add systemctl service to redis

(Learning video sharing: redis video tutorial

2. Join the service

vi /lib/systemd/system/redis.service 
$ vi /lib/systemd/system/redis.service

Add the following content

[Unit]
Description=redis
After=network.target
[Service]
Type=forking
PIDFile=/var/run/redis_6379.pid  //注意
ExecStart=/usr/local/redis/src/redis-server /usr/local/redis/etc/redis.conf //注意
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target

Replace the path in the warning part with your own installation path, and keep the pid path consistent with the path in redis.conf

3. Save and exit

$ systemctl enable redis.service  //加入开机启动
 
$ systemctl start redis //开启redis服务
 
$ systemctl status redis  //查看redis运行状态

Uninstall redis:

//删除安装目录
//删除所有redis相关命令脚本
//删除redis解压文件夹

Related recommendations:redis database tutorial

The above is the detailed content of Specific steps to add systemctl service to redis. For more information, please follow other related articles on the PHP Chinese website!

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