Installing Redis6 from source code on CentOS7

Install dependencies

First we install the source code package. We need to install the C language compiler and download wget by the way:

yum install -y gcc wget

start installation

Download the installation package

We can download the installation package directly through wget:

wget https://download.redis.io/releases/redis-6.2.13.tar.gz

After downloading, it looks like this:
Insert image description here

Unzip the installation package

Directly execute the following line of commands to decompress:

tar -zxvf redis-6.2.13.tar.gz

After decompression, you can see a redis-6.2.13 folder:
Insert image description here

Compile source code

We first enter the redis-6.2.13 directory:

cd redis-6.2.13

Then we compile and install. I plan to install redis in the /opt/server/redis-6.2.13 directory, so we can install it by directly executing this line of command:

make && make install PREFIX=/opt/server/redis-6.2.13

If you see this, the installation is complete:
Insert image description here

Modify configuration file

You can see that our configuration files are all in the root directory of the compilation, oneredis.conf and onesentinel.conf. We need to copy these two files to In the installation directory:
Insert image description here

We first go to the directory /opt/server/redis-6.2.13 and then create data , conf , logs Three directories:

cd /opt/server/redis-6.2.13
mkdir data conf logs

After creation, it looks like this:
Insert image description here

Execute the following command to copy the configuration file to the conf folder:

cp /usr/local/src/redis-6.2.13/*.conf ./conf/

You can view the results after copying:
Insert image description here

We need to modify redis.conf configuration file:

vim redis.conf

The bind line around line 75 should be commented out, otherwise the remote connection will not be able to connect:
Insert image description here

The protection mode is set to no around line 94, otherwise the remote connection cannot be made:
Insert image description here

Around line 259, open the daemon process and set it to yes:
Insert image description here

Around lines 299 and 304, the log output level and log file are selectively modified:
Insert image description here

Set the data file to hard copy. Do not let dump.rdb file export. Write it to the one we created before. /opt/server/redis-6.2.13/data Directory:
Insert image description here

Start and connect

Start redis server

After we come to the root directory of the installation, we can use it directly ./bin/redis-server Follow the configuration file path to start successfully:

# 来到安装的根目录
cd /opt/server/redis-6.2.13/
# 启动redis服务器
./bin/redis-server ./conf/redis.conf

You can view the startup results:
Insert image description here

local connection

We first go to the root directory of the installation. Because we have not modified the port, it is the default port. We can directly use the following command to connect successfully:

cd /opt/server/redis-6.2.13/
./bin/redis-cli
# 或后面跟上 -p 参数端口号
./bin/redis-cli -p 6379

The connection is as shown in the figure:
Insert image description here

remote connection

We can connect remotely through some remote connection tools, such as usingIntelliJ IDEA, open any project and select the Database tab, then click the plus sign ➕ and select New Data Source, and finally selectRedis:
Insert image description here

Then fill in the content as prompted:
Insert image description here

Testing the remote connection is no problem either:
Insert image description here

Next article preview

Preview of the next few articles:

Supongo que te gusta

Origin blog.csdn.net/m0_51510236/article/details/132661137
Recomendado
Clasificación