redis - profile resolution conf

1. Where


2. Units


Configure the size unit. Some basic measurement units are defined at the beginning. Only bytes but not bit s are supported

Case insensitive

3. INCLUDES contains

Similar to our struts 2 configuration file, redis. Can be included through includes Conf can be used as the main gate, including other

4. General (general)


Represents turning on daemon mode. In this mode, redis will run in the background (even if the terminal is disconnected after the terminal is started, it will switch to the background) and write the process pid number to redis The conf option is in the file set by pidfile. At this time, redis will always run unless you manually kill the process



Path to process pipeline id


3) Port (the new version is in the network area)


4) TCP backlog (the new version is in the network area)

TCP backlog is a connection queue

Total backlog queue = queue with three incomplete handshakes + queue with three completed handshakes

In a high concurrency environment, you need a high backlog value to avoid slow client connection problems. Note that the Linux kernel will reduce this value to the value of / proc/sys/net/core/somaxconn, so confirm to increase somaxconn and tcp_max_syn_backlog two values to achieve the desired effect

5) Bind (the new version is in the network area)

The local binding ip is If you want to connect to the remote client, you need to add the linux server ip

6) Timeout (the new version is in the network area)

Connection time. The default is 0, which is the off state

7) TCP keepalive (the new version is in the network area)

Heartbeat, that is, keep the server connected when clustering.

The unit is seconds. If it is set to 0, Keepalive detection will not be performed. It is recommended to set it to 60


There are four log levels for redis by default: debug > verbose > notice > warning



Log name


Whether to output the system log to syslog. It is off by default



System log name. What does it start with? redis is the default


Specify the syslog device. The value can be USER or LOCAL0-LOCAL7



The number of redis default databases is 16

5. Snapshot (snapshot) snapshot


6. Security (Security)

The default password is blank

Set password

7. Replication

8. Limits (limits) limits

1) maxclients (the new version is in the CLIENTS area)

maximum connection

Set how many clients redis can connect to at the same time. 10000 clients by default

2) maxmemory (the new version is in the CLIENTS area)

redis maximum memory used

Set the amount of memory redis can use. Once the memory usage limit is reached, redis will attempt to remove the internal data. The removal rule can be specified through maxmemory policy. If redis is unable to remove the data in memory according to the removal rules, or set "no removal allowed"

3) maxmemory policy (the new version is in the MEMORY MANAGEMENT area)

Cache expiration clearing policy, which never expires by default

# volatile-lru -> Evict using approximated LRU, only keys with an expire set.
# allkeys-lru -> Evict any key using approximated LRU.
# volatile-lfu -> Evict using approximated LFU, only keys with an expire set.
# allkeys-lfu -> Evict any key using approximated LFU.
# volatile-random -> Remove a random key having an expire set.
# allkeys-random -> Remove a random key, any key.
# volatile-ttl -> Remove the key with the nearest expire time (minor TTL)
# noeviction -> Don't evict anything, just return an error on write operations.


 (1)volatile-lru: use LRU Algorithm removal key,Only for keys with expiration time set 
(2)allkeys-lru: use LRU Algorithm removal key 
(3)volatile-random: Remove random from expired collection key,Only for keys with expiration time set 
(4)allkeys-random: Remove random key 
(5)volatile-ttl: Remove those TTL Minimum value key,That is, those that will expire recently key 
(6)noeviction: No removal. For write operations, only error messages are returned 


4) Maxmemory samples (the new version is in the MEMORY MANAGEMENT area)

Set the number of samples. LRU algorithm and minimum TTL algorithm are not accurate algorithms, but estimated values, so you can set the size of samples,

redis will check so many key s by default and select the LRU

The system defaults to 5



10. Common configuration redis Conf introduction

Parameter description 
redis.conf The configuration items are described as follows: 
1. Redis It does not run as a daemon by default. You can modify it through this configuration item and use it yes Enable Daemons 
  daemonize no 
2. When Redis When running as a daemon, Redis By default pid write in/var/run/ File, you can pidfile appoint 
  pidfile /var/run/ 
3. appoint Redis The default listening port is 6379. In a blog post, the author explained why 6379 is selected as the default port, because 6379 is on the mobile phone button MERZ Corresponding number, and MERZ From Italian singer Alessia Merz Name of 
  port 6379 
4. Bound host address 
5.When the client is idle for how long, close the connection. If 0 is specified, it means that the function is closed 
  timeout 300 
6. Specify the logging level, Redis Four levels are supported: debug,verbose,notice,warning,Default to verbose 
  loglevel verbose 
7. The logging mode is standard output by default. If configured Redis If it runs in daemon mode, and the logging mode is configured here as standard output, the log will be sent to/dev/null 
  logfile stdout 
8. Set the number of databases. The default database is 0. You can use SELECT <dbid>Command specifies the database on the connection id 
  databases 16 
9. Specify how long and how many update operations will synchronize the data to the data file. Multiple conditions can be matched 
  save <seconds> <changes> 
  Redis Three conditions are provided in the default configuration file: 
  save 900 1 
  save 300 10 
  save 60 10000 
  It means 1 change in 900 seconds (15 minutes), 10 changes in 300 seconds (5 minutes) and 10000 changes in 60 seconds respectively. 
10. Specifies whether to compress data when storing to the local database. The default is yes,Redis use LZF Compression, if in order to save CPU Time, you can turn off this option, but it will cause the database file to become huge 
  rdbcompression yes 
11. Specify the local database file name. The default value is dump.rdb 
  dbfilename dump.rdb 
12. Specify local database storage directory 
  dir ./ 
13. Set when this machine is slav When servicing, set master Service IP Address and port, in Redis When started, it will automatically start from master Data synchronization 
  slaveof <masterip> <masterport> 
14. When master When the service is password protected, slav Service connection master Password for 
  masterauth <master-password> 
15. set up Redis Connection password. If the connection password is configured, the client is connected Redis Need to pass AUTH <password>The command provides a password, which is off by default 
  requirepass foobared 
16. Set the maximum number of client connections at the same time. It is unlimited by default, Redis The number of client connections that can be opened at the same time is Redis The maximum number of file descriptors that the process can open, if set maxclients 0,Indicates no restriction. When the number of client connections reaches the limit, Redis The new connection is closed and returned to the client max number of clients reached error message 
  maxclients 128 
17. appoint Redis Maximum memory limit, Redis The data will be loaded into memory at startup. When the maximum memory is reached, Redis Will first try to clear expired or about to expire Key,After this method is processed, the maximum memory setting is still reached, and the write operation can no longer be carried out, but the read operation can still be carried out. Redis new vm Mechanism, will Key Store memory, Value Will be stored in swap area 
  maxmemory <bytes> 
18. Specifies whether to log after each update operation, Redis By default, data is written to disk asynchronously. If it is not turned on, it may cause data loss for a period of time in case of power failure. because redis Synchronize the data file itself according to the above save Conditions to synchronize, so some data will only exist in memory for a period of time. Default to no 
  appendonly no 
19. Specifies the name of the update log file. The default is appendonly.aof 
   appendfilename appendonly.aof 
20. Specify the update log condition. There are three optional values:  
  no: Indicates that the operating system performs data cache synchronization to disk (fast)  
  always: Indicates that it is called manually after each update operation fsync()Write data to disk (slow, safe)  
  everysec: Indicates one synchronization per second (compromise, default) 
  appendfsync everysec 
21. Specifies whether the virtual memory mechanism is enabled. The default value is no,For a brief introduction, VM The data is stored in pages by the mechanism Redis The page with less access, that is, cold data swap To the disk, the pages accessed more are automatically swapped out from the disk to the memory (I will analyze it carefully in the later article) Redis of VM (mechanism) 
   vm-enabled no 
22. Virtual memory file path, the default value is/tmp/redis.swap,Not more than one Redis Instance sharing 
   vm-swap-file /tmp/redis.swap 
23. All greater than vm-max-memory Data stored in virtual memory,whether vm-max-memory How small is the setting,All index data is stored in memory(Redis The index data is keys),in other words,When vm-max-memory When set to 0,It's all value All exist on disk. The default value is 0 
   vm-max-memory 0 
24. Redis swap The documents are divided into many page,An object can be saved in multiple page Up there, but one page Cannot be shared by multiple objects, vm-page-size It should be set according to the size of the stored data. The author suggests that if many small objects are stored, page The size should preferably be set to 32 or 64 bytes;If you store large objects, you can use larger objects page,If you are not sure, use the default value 
   vm-page-size 32 
25. set up swap In file page Quantity, due to the page table (a table that indicates that the page is free or in use bitmap)It is placed in memory, every 8 on disk pages Will consume 1 byte Memory. 
   vm-pages 134217728 
26. Set access swap Number of threads in the file,It is best not to exceed the number of cores of the machine,If set to 0,So all right swap File operations are serial, which may cause a long delay. The default value is 4 
   vm-max-threads 4 
27. Set whether to combine smaller packets into one packet for sending when answering to the client. It is on by default 
  glueoutputbuf yes 
28. Specifies that a special hash algorithm is used when the number of elements exceeds a certain number or the maximum element exceeds a critical value 
  hash-max-zipmap-entries 64 
  hash-max-zipmap-value 512 
29. Specifies whether to activate reset hash. It is on by default (described later) Redis The hash algorithm of is described in detail) 
  activerehashing yes 
30. Specify to include other configuration files, which can be multiple on the same host Redis The same configuration file is used between instances, and each instance has its own specific configuration file 
  include /path/to/local.conf 


Keywords: Redis Configuration

Added by pplexr on Tue, 25 Jan 2022 01:14:07 +0200