A list,

Redis is an open source, network-enabled, memory-based and persistent-based, logging, key-value, high-performance database written in ANSI C and compliant with THE BSD protocol. Redis has the following three characteristics compared to other key-value caching products:

  1. Support data persistence, you can save the data in the memory to the disk, restart can be loaded again for use.
  2. Supports simple key-value data and stores data structures such as List, Set, Zset, and Hash.
  3. Supports data backup, namely, data backup in master-slave mode.

Second, the installation

  1. Download:

Redis’s website is: Redis. IO you can also view the Chinese website: www.redis.cn is 6.0.9 Redis the latest version at present, address is: download. Redis. IO/releases/re… This article USES the 3.2.11, address is: download. Redis. IO/releases/re…

wget http:/ / download. Redis. IO/releases/redis - 3.2.11. Tar. Gz
Copy the code

  1. Extract:
tar -zxf redis-3.211..tar.gz
Copy the code

  1. Compile:

GCC is installed if the following figure is displayed.

gcc -v
Copy the code

If not, install the GCC environment first. After the installation, check again.

yum install gcc-c++
Copy the code

If GCC is already installed, go to the redis file directory and run the make command to compile.

cd redis-3.211.
make
Copy the code

Redis-benchmark; redis-check-aof; redis-check-rdb; redis-cli; redis-sentinel; redis-server;

  • Redis-server: indicates the Redis server
  • Redis -cli: redis command line client
  • Redis-benchmark: Redis performance test tool
  • Redis-check-aof: aOF file repair tool
  • Redis-check-rdb: RDB file checking tool

Three, start,

First, we go to the installation directory of the Redis file

Find the redis-server command (default: redis-3.2.11/ SRC) and run this command to start the Redis service

./redis-server 
Copy the code

Note: starting Redis this way, when we close the command window, the redis-server program also ends, which is obviously not friendly, so we need to modify the redis.config file to start Redis as a daemon. To avoid damaging the original Redis configuration file, we usually make a copy and modify the copied configuration file and specify the Redis configuration file when starting the Redis service.

mkdir config  
cp -p redis.conf config/
Copy the code

Vim redis.config Edits the configuration file./redis-server.. / config/redis. Conf configuration file specified start redis ps - ef | grep redis view redis service is startedCopy the code

We installed Redis, but this way is very insecure, because there is no password, so any user connected to the Redis server can perform operations on Redis, so let’s talk about setting a password for Redis. Conf, go to the “requirePass” section, open the closed comment, and replace it with the password you want:

There are two ways to authorize login:

redis-cli -h 127.0. 01. -p 6379 -a 1234
redis-cli -h 127.0. 01. -p 6379, the auth1234
Copy the code

The command sent to Redis will return “(error) NOAUTH Authentication required.” if the password is configured and no authorization is performed.

Four, shut down

  1. Redis -cli shutdown: safely shutdown. If you have a password, add -a {password}. It is recommended to shutdown in this way to generate persistent files and prevent data loss.
  2. Kill -9 PID: forcibly disable the command. Redis memory data may be lost (not recommended).

The blogger has opened a new wechat public account: Welcome to pay attention to ‘Balding Record’, smart enough to go black.