First, the use of the environment

  • Centos7.8
  • Redis – 5.0.9

1.1 Environment Description

The reids official website has been updated to version 6.0, but redis-6.0 requires a higher version of GCC to compile, which is very troublesome. Here we use Redis5.0 to demonstrate

Centos login account is not the administrator account, because I want to form a habit, later work will not get the administrator account

Download the decompressed installation package

IO/Download

1. Copy the installation package address on the official website. Download the redis-5.0.9 version as follows

http://download.redis.io/releases/redis-5.0.9.tar.gz
Copy the code

2. Create two directories, one for storing the installation package and the other for storing the decompressed installation package

Mkdir /opt/software sudo mkdir /opt/environment sudo chown -r myboy:myboy /opt/* # You can make it your ownCopy the code

Why use username and package name instead?

Since our account does not have administrator rights by default (in real development as well), we need to add sudo and enter password every time we operate files under root package, so we set our own folder as our own group, so it is very convenient

3. Download the installation package from the corresponding directory in Centos7. I have created a new directory /opt/software specifically for storing the installation package

#Use the wget command to downloadWget HTTP: / / http://download.redis.io/releases/redis-5.0.9.tar.gzCopy the code

4. Download the decompression package

Tar -zxf redis-5.0.9.tar.gz-c.. /environmentCopy the code

-c indicates that the decompression is to another folder. -zxf indicates that the decompression does not output any information

5. Access the redis root directory

Compile Redis

1. Install GCC

Sudo yum install -y GCC -c++ GCC -vCopy the code

Note: Yum supports the installation of GCC (4.8.5). If redis6.0 is used, a later GCC version is required

2. Compile in the redis root directory

make
Copy the code

Compilation takes a little time, maybe 1-2 minutes

3. Install Redis

sudo make install
Copy the code

4. Check the default Redis installation directory

cd /usr/local/bin
ls -al
Copy the code

If redis-cli and redis-server files are displayed, the installation is successful

Configure Redis

If you do not specify a configuration file when you start Redis, the default configuration file will be loaded. However, we will not use the default configuration before using Redis, we need to modify the redis configuration file, so we need to specify the configuration file when starting Redis, the following is the operation of the configuration file

1. Copy the configuration file to the /etc directory so that you can specify the configuration file during startup

Sudo cp/opt/environment/redis - 5.0.9 / redis. Conf/etc /Copy the code

2. Modify the configuration file

Sudo mv /etc/redis.conf /etc/myconf sudo vim /etc/myconfCopy the code

Change daemonize to yes to enable the background boot mode and start Redis will not occupy the console all the time

If you need other IP addresses to access Redis, you need to modify the bind, protected-mode, and password authentication requirepass configurations. These configurations are specified in the configuration file and you need to configure them yourself

5. Start Redis

Redis-server /etc/myconf # redis-cli # connect to command line toolsCopy the code

test

Start-up success

Close Redis

Enter the following commands in the command line window

shutdown
Copy the code