Redis configuration file Conf configuration details

1. redis. units in conf

2. redis.conf contains other configuration files

If redis.com needs to be configured To import other configuration files into conf, you need to use redos INCLUDES in conf configuration file

3. Related configuration of NETWORK

explain:

bing 127.0.0.1: bound ip. When the protection mode is enabled, only the bound ip can access the redis service

Protected mode yes: protected mode

  • no: the protection mode is turned off, and the Internet can directly access redis, which is not safe
  • yes: when the protection mode is enabled, access to the redis service needs to be through the bind bound IP or through the set password [requirepass xxxx]

Port: redis service port number. The default value is 6379. If you need to modify the access port of redis, you can modify this value

# Bound IP
bind 127.0.0.1
# Protection mode no: you can access redis directly by turning off the Internet. Yes: turn on the protection mode. When it is turned on, you can only access it through the bound ip[bind 127.0.0.1] or password authentication
protected-mode yes
# Port number for startup
port 6379

4. GENERAL configuration

Daemon No: set the operation mode of redis

  • no: the client runs, and the redis service stops when the client closes
  • yes: it runs as a daemon, that is, it runs in the background. When the client is turned off, the redis service is also running
################################# GENERAL #####################################
# Set the default value of running mode: no, which needs to be changed to yes to run as a daemon
daemonize no
# For the management of daemons, the default is no, which is generally not moved
supervised no
# The pid file of the configuration file. If you run in the background mode, you need to specify a pid file
pidfile /var/run/redis_6379.pid
# Log level settings
# Specify the server verbosity level.
# This can be one of:
# debug (a lot of information, useful for development/testing) is applicable to development environment or testing environment
# verbose (many rarely useful info, but not a mess like the debug level)
# Notice (modestly verbose, what you want in production probably) is applicable to production environment
# warning (only very important / critical messages are logged)
loglevel notice
# Log file location name
logfile ""
# Number of redis databases
databases 16
# Whether the redis LOGO is always displayed. The redis LOGO seen during startup is configured here. yes: display no: not display
always-show-logo yes

5. Configuration of snapshot

Snapshots are used for persistence, because redis is an in memory database. If persistence is not carried out, all redis data will be lost in case of power failure of the deployed server. Generally, the snapshot configuration does not need to be changed. What may need to be changed is the save configuration of the persistent policy. If the default configuration does not meet the existing requirements, you can configure your own persistent policy on the original basis or directly, and the amount of modification of the save interval. For example:

save 10 1: indicates that if at least one key is modified within 10s, the persistence operation will be triggered

################################ SNAPSHOTTING  ################################

# Persistent save policy configuration
# Within 900s, if at least one key is modified, the persistence operation will be carried out
save 900 1
# Within 300s, if at least 10 key s have been modified, the persistence operation will be carried out
save 300 10
# If at least 10000 key s are modified within 60s, the persistence operation will be carried out
save 60 10000
# If the configuration persistence fails, do you still need to continue working? yes: do you still need to continue working
stop-writes-on-bgsave-error yes
# Configure whether to compress rdb files. [if yes, certain cpu resources will be consumed]
rdbcompression yes
# Check and verify errors when saving rdb files
rdbchecksum yes
# Default persistent saved file name
dbfilename dump.rdb
# Directory where rdb files are saved
dir ./

6. Configure SECURITY

requirepass: used to configure the access password, set the method, release the configuration, and replace foobared with the password value to be configured

################################## SECURITY ###################################

# Set the password for access and login, and set requirepass your password
requirepass foobared

7. Configuration of client CLIENTS

Maxmemory policy: the processing policy after redis reaches the maximum capacity

  • volatile -lru: LRU only for key s with expiration time set (default)
  • Allkeys lru: delete the key of lru algorithm
  • Volatile random: randomly delete key s that are about to expire
  • Allkeys random: random deletion
  • Volatile TTL: delete expired
  • noeviction: never expires, return error
################################### CLIENTS ####################################

# Set the maximum number of connections of the client. The configuration generally does not need to be modified, and the default value can be used
# maxclients 10000

############################## MEMORY MANAGEMENT ################################

# Maximum memory capacity of redis configuration
# maxmemory <bytes>

# Processing strategy after reaching the memory capacity limit
# maxmemory-policy noeviction

8. Persistence policy AOF configuration

############################## APPEND ONLY MODE ###############################


# Whether to enable aof persistence mode. The default value is no. It is not enabled. The default persistence strategy of redis is edb mode
appendonly no

# Persistent file name
appendfilename "appendonly.aof"

# Persistence policy settings
# appendfsync always # Persistent operation is performed for each modification
appendfsync everysec # Persistent operations are performed once per second
# appendfsync no     # Not executing the persistence operation is equivalent to not enabling the aof persistence policy

# The default setting is yes after the new write operation is completed, and the default setting is no after the new write operation is completed
no-appendfsync-on-rewrite no

# AOF automatically overrides the configuration. The default value is 100
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb

# When Redis recovers data in AOF mode, the default value is yes
aof-load-truncated yes

# When rewriting an AOF file, redis can use the RDB preamble in the AOF file to rewrite and recover faster. When this option is enabled, the rewritten AOF file consists of two different sections: [RDB file][AOF tail]. When loading an AOF file, redis recognizes that the file is a combination of RDB and aof through the AOF file starting with the "redis" string. Redis will load the RDB part first and then the AOF part. The default value is yes
aof-use-rdb-preamble yes

In the above configuration description, there is no relevant configuration description of the cluster. The configuration of the cluster has been learned later. In addition

Tags: Redis

Posted by fontener on Mon, 18 Apr 2022 19:01:06 +0930