Home > Database > Redis > body text

Specific steps to add systemctl service to redis

王林
Release: 2021-03-04 09:23:28
forward
3732 people have browsed it

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
Copy after login

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
Copy after login

Then modify the configuration file

$ cd etc
$ vi redis.conf
Copy after login

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
Copy after login

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
Copy after login

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运行状态
Copy after login

Uninstall redis:

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

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!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template