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:
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:
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:
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:
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:
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:
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:
The protection mode is set to no around line 94, otherwise the remote connection cannot be made:
Around line 259, open the daemon process and set it to yes:
Around lines 299 and 304, the log output level and log file are selectively modified:
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:
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:
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:
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
:
Then fill in the content as prompted:
Testing the remote connection is no problem either:
Next article preview
Preview of the next few articles:
- Use redis6 to build a multi-master and multi-slave cluster:https://blog.csdn.net/m0_51510236/article/details/132684529
- Use SpringBoot to connect to the clusterhttps://blog.csdn.net/m0_51510236/article/details/132712724
- Use Kubernetes to deploy a multi-master and multi-slave cluster (expected 2023-09-07)