Install and configure to start Redis in Linux

Install and configure to start Redis in Linux

1. Download redis

Download with command:

wget https://download.redis.io/releases/redis-6.0.10.tar.gz
ls
du sh redis-6.0.10.tar.gz

decompress

[root@node02 ~]# tar xzf redis-6.0.10.tar.gz
[root@node02 ~]# cd redis-6.0.10
[root@node02 redis-6.0.10]# ls

Install

[root@node02 redis-6.0.10]# yum install gcc-c++

compile

[root@node02 redis-6.0.10]# make

If the following error occurs when compiling:

insert image description here

solution:

Check whether the gcc version is below 5, if yes, it needs to be upgraded:

sudo yum install centos-release-scl
sudo yum install devtoolset-7-gcc*
scl enable devtoolset-7 bash

Under normal circumstances, make compiles as shown in the figure:

insert image description here

Install:

insert image description here

Check

[root@node02 ~]# ls /usr/local/redis/
[root@node02 ~]# ls /usr/local/redis/bin/

insert image description here

configuration file

[root@node02 ~]# mkdir /usr/local/redis/conf
[root@node02 ~]# ls
[root@node02 ~]# ls redis-6.0.10
[root@node02 ~]# cp redis-6.0.10/redis.conf /usr/local/redis/conf/
[root@node02 ~]# ls /usr/local/redis/conf/

insert image description here

start up

redis-server /usr/local/redis/conf/redis.conf

insert image description here

Redis starts in the foreground by default, and wants to start in the background:

nohup redis-server /usr/local/redis/conf/redis.conf &

insert image description here

[root@node02 ~]# netstat -antp | grep redis

insert image description here

[root@node02 ~]# ps -elf | grep redis

insert image description here

Operation linked database

[root@node02 ~]# redis-cli
127.0.0.1:6379> 

By default, just press Enter

insert image description here

key value pair

127.0.0.1:6379> set a 10
OK

Inquire

127.0.0.1:6379> get a
"10"

Guess you like

Origin blog.csdn.net/m0_62181310/article/details/131481648