Linux (Centos7) install Redis

1. Compile and install the offline installation package

1. Upload the redis compressed package to the server/opt via Xftp

insert image description here

2. Unzip to /usr/local/

tar -zxvf redis-4.0.11.tar.gz -C /usr/local/

insert image description here

3. Install gcc dependencies

yum -y install gcc

insert image description here

4. Enter the redis directory and execute make

make

insert image description here

5. Continue to execute make install

make install

insert image description here

6. Start redis

  1. front-end startup
//在redis/src目录执行启动指令,出现如图即启动成功
redis-server

insert image description here
2. Background start

//在redis根目录执行
redis-server redis.conf >>/dev/null &

insert image description here

Set up autostart

1. First configure redis.conf to enable background startup. Then create a new system service file (redis.service) and write the following content into the file

insert image description here

vim /etc/systemd/system/redis.service

[Unit]
Description=redis-server
After=network.target

[Service]
Type=forking
# 这行配置内容要根据redis的安装目录自定义redis-server,redis.conf路径
ExecStart=/usr/local/redis-4.0.11/src/redis-server /usr/local/redis-4.0.11/redis.conf
PrivateTmp=true

[Install]
WantedBy=multi-user.target #执行指令

2. Set redis to boot automatically

1. systemctl daemon-reload
2. systemctl enable redis

3. Start the redis service

systemctl start redis

4. Other common commands

systemctl status redis   //查看redis状态
systemctl stop redis     //关闭redis
systemctl restart redis  //重启redis

Two, yum installation

1. Download the epel repository

yum install epel-release -y

2. Download redis database

yum install redis -y

3. Start the redis service

systemctl start redis

insert image description here
4. Other common commands

1. systemctl status redis    //查看redis状态
2. systemctl stop redis      //关闭redis
3. systemctl restart redis   //重启redis

Check the version and the path of each file

1. View version

rpm -qa | grep redis

insert image description here
2. View the path of each file

1. rpm -qa | grep redis
2. rpm -ql redis-3.2.12-2.el7.x86_64

insert image description here

Guess you like

Origin blog.csdn.net/dontYouWorry/article/details/128934959