Install redis
Install required dependencies
yum install -y wget gcc
Download redis 5.0.14 installation package
The download address is https://download.redis.io/releases/redis-5.0.14.tar.gz . You can also use the command to download:
cd /usr/local/src/
wget https://download.redis.io/releases/redis-5.0.14.tar.gz
Unzip the installation package
Unzip the installation package in the corresponding directory
tar -zxvf redis-5.0.14.tar.gz
Compile source code and install
First we have to go to the redis directory
cd redis-5.0.14
Then compile and install redis, where /opt/server/redis-5.0.14 is the directory where redis needs to be installed.
make
make install PREFIX=/opt/server/redis-5.0.14
Configure redis
Get the configuration file and back it up
Go to the compiled directory and create several folders
cd /opt/server/redis-5.0.14/
mkdir conf data logs
The purpose of several directories created is:
- conf: directory where redis configuration files are stored
- data: the storage directory of redis data
- logs: redis log storage directory
Then go to the conf directory and copy the configuration file to this folder
cd conf
cp /usr/local/src/redis-5.0.14/*.conf .
After completion, we can see that there are two configuration files below this
Back up the redis.conf configuration file
cp redis.conf redis.conf.bak
Modify configuration file
We need to modify the configuration file of redis.conf
vi redis.conf
Then you need to change the binding of the redis IP address and whether it is in protected mode (protected mode needs to be cancelled)
Enable running redis in daemon thread mode
Modify the storage path of the log
Modify the path where the data files are stored
Start redis
Start redis with command
First we go to the directory of the specified installed redis
cd /opt/server/redis-5.0.14
Start redis using the command
./bin/redis-server ./conf/redis.conf
Press Enter to start successfully.
Operation redis
Use the command to enter redis
./bin/redis-cli
Then operate redis
Okay, we're done here.