Install redis under Linux

1. Download the redis installation package from the official website, the version selected here is redis-4.0.9.tar.gz

2. Upload the installation package to the linux server, and decompress the installation package to /software/redis-4.0.9

$ tar -xvzf redis-4.0.9.tar.gz /software/redis-4.0.9

3. Enter the redis folder and compile the redis program

$ cd /software/redis-4.0.9/

$ make

After the compilation is successful, src, conf and other folders will be generated

4. Go to the src folder and install redis

$ cd /software/redis-4.0.9/src/

$ make install

The following errors may occur during installation

The reason is that the permissions of the /usr/local/bin/ folder are insufficient, and the permissions need to be changed before installation.

5.   First of all, for the convenience of management, move the conf configuration file and common commands in the Redis file to the unified file

1)  Create bin and etc folders

$ mkdir /software/redis-4.0.9/bin

$ mkdir /software/redis-4.0.9/etc

2) Move files

$ cd /software/redis-4.0.9/

$ mv redis.conf /software/redis-4.0.9/etc

$ cd src/

$ mv mkreleasehdr.sh redis-benchmark redis-check-aof redis-cli redis-server /software/redis-4.0.9/bin

6.   Set background startup (optional)

Switch to the /software/redis-4.0.9/etc directory and edit the redis.conf file

$ cd/software/redis-4.0.9/etc/

$vi redis.conf

Change the daemonize property to yes (indicating that it needs to run in the background)

7. Set up remote access

$ cd/software/redis-4.0.9/etc/

$vi redis.conf

comment out bind

8. Turn off the password authentication protection module

$ cd/software/redis-4.0.9/etc/

$vi redis.conf

Change protected-mode to no

9.   Set startup operation (optional)

$ vi /etc/rc.local

Add content in it: /software/redis-4.0.9/bin /redis-server /software/redis-4.0.9/etc /redis.conf ( meaning to call this command to start redis at boot)

10.  Start the redis service

$ /software/redis-4.0.9/bin/redis-server /software/redis-4.0.9/etc/redis.conf

11. Common commands

1)   After the server starts successfully, execute redis-cli to start the Redis client

$ redis-cli

2)   Stop the service

/usr/local/redis/bin/redis-cli shutdown

or

pkill redis-server

12. Several key files of redis ( /software/redis-4.0.9/bin/ )

redis-benchmark: redis performance testing tool

redis-check-aof: tool to check aof logs

redis-check-dump: tool for checking rdb logs

redis-cli: client for connection

redis-server: redis service process

13.  Introduction to conf configuration items

daemonize: If you need to run in the background, change the value of this item to yes

pdifile: put the pid file in /var/run/redis.pid, which can be configured to other addresses

bind: Specifies that redis only receives requests from this IP. If it is not set, all requests will be processed. It is best to set this item in the production process

port: listening port, the default is 6379

timeout: Set the timeout time when the client connects, in seconds

loglevel: The level is divided into 4 levels, debug, revbose, notice and warning. In the production environment, the notice is generally turned on

logfile: Configure the address of the log file. By default, the standard output is used, that is, it is printed on the port of the command line terminal.

database: set the number of databases, the default database is 0

save: set the frequency of database mirroring by redis

rdbcompression: Whether to perform compression during image backup

dbfilename: The filename of the mirror backup file

dir: the path where the files of the database mirroring backup are placed

slaveof: Set the database as the slave database of other databases

masterauth: set here when the master database connection requires password authentication

requirepass: Set the password to be used before any other specification is made after the client is connected

maxclients: limit the number of clients connected at the same time

maxmemory: Set the maximum memory that redis can use

appendonly: After enabling appendonly mode, redis will append each write operation received to appendonly.aof file, when redis restarts, it will restore the previous state from the file

appendfsync: Set the frequency of synchronization of appendonly.aof files

vm_enabled: Whether to enable virtual memory support

vm_swap_file: Set the path of the virtual memory swap file

vm_max_momery: Set the maximum physical memory size that redis will use after virtual memory is enabled, the default is 0

vm_page_size: Set the size of virtual memory pages

vm_pages: Set the total number of pages in the swap file

vm_max_thrrads: Set the number of threads used by vm IO at the same time

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324688457&siteId=291194637