1.1. What is redis
Redis is an open source high-performance key-value database developed in C language. It adapts to storage requirements in different scenarios by providing a variety of key-value data types. So far, the key-value data types supported by Redis are as follows:
String type
hash type
List type
Collection type
Sorted collection type.
1.2. Application scenarios of redis
Cache (data query, short connection, news content, commodity content, etc.). (most used)
Session separation in a distributed cluster architecture.
List of online friends for chat rooms.
task queue. (Seckill, panic buying, 12306, etc.)
App leaderboard.
Website visit statistics.
Data expiration processing (can be accurate to milliseconds)
1.3.redis stand-alone installation
(1) Because redis is developed in C language, if you want to run on linux, you need gcc-c++ environment. Then we have to first see if gcc-c++ is installed. If not, we need to install the gcc-c++ environment on the virtual machine
First, you need to check whether the operating environment is available on linux. Enter the command: rpm -qa | grep gcc-c++
This environment is installed on my linux, and the result after entering the command is: gcc-c++-4.4.7-17.el6.i686
If there is no such environment on linux, then you need to install the environment. The command for network installation is as follows: yum install gcc-c++
(2) Download http://download.redis.io/releases/redis-3.2.11.tar.gz from the official website, and copy redis-3.2.11.tar.gz to the /user/local directory,
(3) Decompress the source code: tar -zxvf redis-3.2.11.tar.gz
(4) Enter the decompressed directory cd /usr/local/redis-3.2.11, and then compile: make
(5) Install to the specified directory make PREFIX=/usr/local/redis install
(6) Copy the configuration file to the installation directory cp /usr/local/redis-3.2.11/redis.conf /usr/local/redis/bin
1.4. Start redis
(1), front-end mode startup
Running directly in the /usr/local/redis/bin directory./redis-server is the foreground startup. After closing the running window, redis will also be closed. This method is not recommended. In order not to close redis after closing the window, you need to use the background start up.
(2), back-end mode startup
Modify the no of daemonize of redis.conf to yes, directly execute ./redis-server ./redis.conf in the /usr/local/redis/bin directory to start redis, and execute ./redis-cli to enter the redis client