Use of Redis configuration files

Redis basic configuration

General configuration

go to the configuration file

vi /etc/redis.conf

write configuration item

vi /etc/redis.conf
#Whether to run daemonize yes/no 
daemonize yes in the background

#Configure the port number 

port 1111

#Log file location 

logfile /var/log/ redis.log

# RDB persistent data file

dbfilename dump.rbd

#Location of persistent files 

dir /data/redis

restart redis after configuration

/application/redis/src/redis-server /etc/redis.conf #Start     under the configuration file /application/redis/src/redis - 
cli -p 1111    #Connect

 

Modify security configuration

vi   /etc/redis.conf #Go to the configuration file 

bind 10.0.0.128 127.0.0.1    #Set the remote connection IP ( 10.0.0.128 is the ip of the local machine) 

requirepass 123   #Set the password (if no password is added when logging in, just You cannot perform related operations in it, you can directly add a password when logging in, or you can enter auth + password)

restart Redis

After login with password

After editing the configuration file, remember to restart redis

 Modify configuration information online

Online modification only takes effect online, and the configuration file has not been changed. The next time you restart, the information in the configuration file will still be used;

For example, if you change the password online, the next time you restart, the password in the configuration file will be used.

Get current configuration information

CONFIG GET *

Change run configuration 

CONFIG SET requirepass 123456 #Change   password online

Redis data persistence

Redis supports two kinds of data persistence, namely RDB persistence and AOF persistence.

RDB endurance

Based on point-in-time snapshots, data persistence is performed by multiplexing;

The more commonly used method has high efficiency and relatively low security;

Can also be used for backup.

Enable RDB persistence

Add the following to /etc/redis.conf:

dbfilename dump.rbd       # rbd filename     
dir /data/redis           # path where rbd is placed   
save 900 1                # 1 change in 900 seconds (15 minutes)    
save 300 10               # 10 changes in 300 seconds (5 minutes) 
save 60 10000            #   10000 changes in 60 seconds (1 minute)
    
[root@zgc redis] #   /application/redis/src/redis-cli -a 123456 -h 10.0.0.128 -p 1111 
10.0.0.200:1111> save   #It takes save to take effect

 AOF persistence

Record all modification commands executed in redis in an append-only way;

The efficiency is relatively low and the security is high.

The configuration file is configured as follows (/etc/redis.conf):

appendonly yes/no   #Whether to enable the aof log function 
appendfsync always #Every   command is immediately synchronized to aof 
appendfsync everysec #Write once   per second 
appendfsync no #The   writing work is handed over to the operating system , and the operating system determines the buffer size, Unified write to aof.

 

Guess you like

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