Install and set up background running redis-6.2.1 under centos7

1. Download Redis 6.2.1 redis-6.2.1.tar.gz from the official website: https://redis.io/, you can also go to https://download.redis.io/releases/ to download, the speed is quite slow

2. Enter the /opt directory

cd /opt

3. Unzip redis-6.2.1.tar.gz

tar -zxvf redis-6.2.1.tar.gz

4. Install the c language environment (you can skip it if you have already installed it)

yum install centos-release-scl scl-utils-build
yum install -y devtoolset-8-toolchain
scl enable devtoolset-8 bash

Test gcc version

gcc --version

image-20211010202134794

5. Enter the redis-6.2.1 directory

cd redis-6.2.1

6. compile

make

7. Execute the installation

make install

image-20211010202651293

8. Enter the bin directory and use the foreground to start the test to see if the installation is successful

cd /bin
redis-server

image-20211010203010224

This interface appears even if it is successful, use control+c to stop the redis process

9. Set background startup

(1) Enter the redis-6.2.1 directory

cd /opt/redis-6.2.1

(2) Copy the redis.conf file to the /etc directory

cp redis.conf /etc/redis.conf

(3) Enter the /etc folder

cd /etc

(4) Modify the redis.conf file

vi redis.conf

(5) Change daemonize no to yes in the background startup setting, and you can search for this statement by typing /dae

image-20211010204625406

Find daemonize no and change it to yes

image-20211010204811127

Save changes

(6) Enter the /usr/local/bin directory

cd /usr/local/bin

(7) Enter redis-server /etc/redis.conf to start redis in the background

redis-server /etc/redis.conf

image-20211010205124156

At this point, you can enter redis-cli for client access

image-20211010205256276

Enter ping, return PONG to indicate that the connection has been normal

image-20211010205403233

(8) In redis-cli state, enter shutdown to close redis

image-20211010205519946
Finish

Guess you like

Origin blog.csdn.net/weixin_42195126/article/details/120692193