Installing Redis is a few simple steps

  • 2020-06-23 02:13:50
  • OfStack

During this period, I was working on my own website, which used redis service. redis's water was very deep, and I couldn't find the bottom for a minute and a half. This article starts with installation, showing you how to quickly install and use redis by hand.

Redis is one kind of the relational database (NoSQL), NoSQL is stored in the form of key - value, and traditional relational databases don't 1 kind, not to follow the traditional database of 1 some basic requirements, such as SQL standards, ACID properties, table structure, and so on, this kind of database mainly has the following features: the non-relational, distributed, open source, extensible.

NoSQL usage scenarios: high concurrent read and write to data, efficient storage and access to massive data, high scalability and high availability of data. My website also puts a lot of homepage data into redis to reduce the pressure on the database.

For efficiency, the data is cached in memory, so redis is fast. It can also periodically write updated data to disk or modify operations to an appended record file. What are the other benefits of Redis? Here's a simple example:

The Redis cluster and Mysql are synchronized, first getting data from redis and then from mysql if redis hangs so that the site doesn't hang. It also relieves the pressure on the database.

Here's how to install redis.

1. Install gcc to compile

Since redis will need to be compiled later, you need to install gcc first. gcc has been installed on Aliyun host by default. If it is a virtual machine installed by yourself, you need to install 1 gcc first:

yum install gcc-c++

2. Download redis

There are two ways to download the installation package: one is to go to the official website to download the installation package and then test it into CentOS; the other is to use wget to download directly.


If you have not installed wget, you can do so by following the following command.

yum install wget

3. Unzip installation

Unzipping the installation package is easy, not to mention.

tar �vzxf redis-3.2.9.tar.gz

After unzipping, there will be an ES68en-3.2.9 folder. Enter this folder and execute make command to complete the installation. If the installation fails, try the following command to install.

make MALLOC=libc
make install

4. Modify the configuration file

After successful installation, 1 configuration file needs to be modified, including ip which is allowed to access, allowing background execution, setting password and so on. redis configuration file is redis. conf file under ES77en-3.2.9 directory, open the file.

Enter /bind to find bind configuration in command mode, press n to find the next one, after finding the configuration, configure bind to, allowing any server to access redis, that is:


Using the same method, change daemonize to yes (default is no) to allow redis to execute in the background.

Turn on the requirepass comment and set the password such as 123456 (the password is set yourself).

5. Start redis

In es104EN-3.2.9, specify the newly modified configuration file ES105en.conf to start redis:

redis-server ./redis.conf

Since background startup is set up, there will be no prompt message. After startup, you can use the following command to see if redis started successfully.

ps -ef | grep redis

If you see 1 redis-ES120en, you have started successfully. Then we start the redis client.


Since we have a password, after starting the client, enter auth 123456 to log in to the client. Then let's test 1 and insert 1 data into redis.

set name CSDN

Then get name

get name

If CSDN can be obtained normally, then there is no problem.

6. Close the redis

To close the redis service, simply use the following command.

pkill redis-server

You can also turn off the redis service using the shutdown command on the redis client.


Related articles: