Redis installation steps and foreground, background redis service startup

1. Download the installation package from the official website

First, we go to the official website of redis: https://redis.io/download/ to download the installation package

insert image description here
insert image description here

2. Use Xftp to transfer the installation package to the Linux opt directory

Open the Xftp tool, connect to the Linux host, and then transfer the redis installation package to the opt directory of Linux

insert image description here
insert image description here

3. Use Xshell to connect to the Linux host to install redis

After transferring the installation package, use the Xshell tool to connect to the Linx host, and then switch to the opt directory to decompress the redis installation package. (To be on the safe side, first check whether the gcc tool exists)

cd /opt/  # 切换到opt目录
ls # 查看opt的子文件
gcc --version # 查看gcc编译器是否安装
tar -vzxf redisXXX.tar.gz # 解压redis的安装包 xxx为版本号

insert image description here
insert image description here

Then enter the directory where the redis installation package is decompressed, and use the make command to compile

cd redis-XXX/ # xxx为版本号
make

insert image description here

The successfully compiled interface is similar to the following figure

insert image description here

Then use the make install command to download and install. After installation, its default installation directory is /user/local/bin .

make install 

insert image description here

Installation directory description

  1. redis-benchmark : performance testing tool
  2. redis-check-aof : Fix problematic AOF files
  3. redis-check-dump : fix buggy dump.rdb files
  4. redis-sentinel : used by redis cluster
  5. redis-server : redis server startup command
  6. redis-cli : client, operation entry

4. Two ways to start the redis service

4.1 Foreground startup

Switch to the redis installation directory /usr/local/bin directory, and then enter the command redis-server to start the redis service in the foreground

cd /usr/local/bin
ls
redis-server

After the redis service starts, the interface is as follows:

insert image description here

4.2 Background start

To start in the background, you need to modify the configuration, that is, to modify the redis.conf configuration file, and change the daemonize no to yes (generally, copy a copy of redis.conf to the etc directory, and then modify it).

First enter the redis installation package directory, and then find the redis.conf configuration file.

cd /opt/redis-xxxx/ # xxx为版本号
ls

insert image description here

Copy the redis.conf configuration file to the etc directory

cp redis.conf /etc/redis.conf

insert image description here
insert image description here

Use vim to modify the redis.conf configuration file, and use to /关键字quickly find the daemonize configuration item.

vim redis.conf

insert image description here

After modification, press ESC to enter command mode, enter :wqto save and exit the redis configuration file.

insert image description here

Now, the redis service can be started through the background

cd /usr/local/bin/ # 切换目录
ls
redis-server /etc/redis.conf #通过后台启动redis服务

insert image description here

Enter ps -ef | grep redisto view the service process

insert image description here

Use the redis-cli client to connect to the port number, and then use the ping command to test whether it is connected.

redis-cli # 连接端口号
ping #测试是否连通

insert image description here

The service is stopped, and the service can be stopped through the kill or shutdown command

shutdown

insert image description here


Guess you like

Origin blog.csdn.net/m0_63622279/article/details/129087412