Installation steps


1. Download the Redis

The version given here is 5.0.5, you can also go to the official website to download the tar package of other versions

Wget HTTP: / / http://download.redis.io/releases/redis-5.0.5.tar.gzCopy the code

2. Unzip

The tar - ZXVF redis - 5.0.5. Tar. GzCopy the code

3. Move the directory

Sudo mv. / redis - 5.0.5 / usr /local/redis/
Copy the code

4. Access the directory

cd /usr/local/redis/
Copy the code

Generated by 5.

sudo make
Copy the code

Test 6.

It’s going to take a long time

sudo make test
Copy the code

7. Install

Install redis commands into the /usr/local/bin/ directory

sudo make install
Copy the code

8. The installation is complete

Go to the /usr/local/bin directory

cd /usr/local/bin
ls -all
Copy the code

  • Redis-server Redis: indicates a server
  • Redis -cli Redis: indicates the command line client
  • Redis – Benchmark Redis: performance testing tool
  • Redis-check-aof aOF: file repair tool
  • Redis-check-rdb RDB: a file search tool

9. Move the configuration file to the /etc/directory

The directory where the system configuration files are stored. We usually put the commonly used configuration files here. To facilitate future configuration ~

sudo cp /usr/local/redis/redis.conf /etc/redis/
Copy the code

Installation FaQs


1. Error: “cc” : command not found

The make command returns the following error:

GCC is not installed because Redis is implemented in C and requires GCC to compile

Solutions:

Install GCC in Linux

yum install gcc -y
Copy the code

Error: “make[1]:***[adlist.o] error 1”

Solutions:

When executing the make command, add the following options

make CFLAGS="-march=x86-64"
Copy the code

Common Configuration Options


Bind IP: Comment this line or bind a real IP if remote access is required

The bind 127.0.0.1

Port number. The default is 6379

. port 6379

Whether to run as a daemon

If run as a daemon, it does not block at the command line, similar to a service

If running as a non-daemon process, the current terminal is blocked

If the value is set to yes, it indicates a daemon process. If the value is set to no, it indicates a non-daemon process

daemonize yes

The data file

dbfilename dump.rdb

Path for storing data files

dir /var/lib/redis

The log file

logfile /var/log/redis/redis-server.log

Database, 16 by default

database 16

A master-slave replication is similar to a two-node backup.

slaveof

Service startup and shutdown


1. Enable the Redis-server service

Sudo redis-server /etc/redis/redis.conf Specifies the loaded configuration fileCopy the code

2. Disable the Redis-server service

Ps - ef | grep redis sudo / / first to check the redis server processkill-9 PID // Determine the PID and kill the Redis serverCopy the code

3. Enable client redis-CLI

You can view the help documentation using help

redis-cli --help
Copy the code

Connect the redis

redis-cli
Copy the code

Run the test command

ping
Copy the code

Switch database, database has no name, default 16, identified by 0-15, connect to redis default select the first database

select n
Copy the code

You can test remote connections using Redis Desktop Manager


See this link for details:

Download and Install Redis Desktop Manager

www.jianshu.com/p/6895384d2…

More Redis operation commands


Redis Command Center: www.redis.cn/commands.ht…