Profile parameters are explained:
1. Redis does not run as a daemon by default, but can be modified by this configuration item to enable the daemon with yes
daemonize no
2. When Redis is running as a daemon, Redis will write pid to the /var/run/redis.pid file by default, which can be specified through the pidfile
pidfile /var/run/redis.pid
3. Specify the Redis listening port, the default port is 6379, the author explained in his blog post why 6379 is chosen as the default port, because 6379 is the number corresponding to MERZ on the mobile phone button, and MERZ is taken from the name of the Italian singer Alessia Merz
port 6379
4. The binding host address
bind 127.0.0.1
5. When the connection is closed after how long the client has been idle, if it is specified as 0, it means that the function is turned off
timeout 300
6. Specify the logging level, Redis supports a total of four levels: debug, verbose, notice, warning, and verbose by default
loglevel verbose
7. Logging mode is standard output by default, if Redis is configured to run as daemon, and here the logging method is configured as standard output, the log will be sent to /dev/null
logfile stdout
8. Set the number of databases, the default database is 0, and you can use the SELECT <dbid>command to specify the database ID on the connection
databases 16
9. Specify how long and how many update operations are performed to synchronize the data to the data file, which can be combined with multiple conditions
save <seconds> <changes>
There are three conditions available in the Redis 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 10,000 changes in 60 seconds, respectively.
10. Specify whether to compress data when storing to the local database, the default is yes, Redis uses LZF compression, if you want 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 the local database repository
dir ./
13. Set the IP address and port of the master service when the machine is a slav service, and it will automatically synchronize data from the master when Redis starts
slaveof <masterip> <masterport>
14. When the master service is password protected, the slav service connects the master's password
masterauth <master-password>
15. Set the Redis connection password, if the connection password is configured, the client needs to provide the password through the AUTH command when connecting to Redis<password>, which is disabled by default
requirepass foobared
16. Set the maximum number of client connections at the same time, the default is unlimited, the number of client connections that Redis can open at the same time is the maximum number of file descriptors that Redis process can open, if maxclients is set to 0, it means that there is no limit. When the number of client connections reaches the limit, Redis closes the new connection and returns a max number of clients reached error message to the client
maxclients 128
17. Specify the maximum memory limit of Redis, Redis will load data into memory when it starts, and after reaching the maximum memory, Redis will first try to clear the expired or expiring keys. Redis' new VM mechanism stores Keys in memory and Values in swap areas
maxmemory <bytes>
18. Specify whether to log after each update operation, Redis writes data to disk asynchronously by default, and if not turned on, it may cause data loss for a period of time when the power is lost. Because redis itself synchronizes data files according to the save conditions above, some data will only exist in memory for a period of time. The default is no
appendonly no
19. Specify the changelog file name, which defaults to appendonly.aof
appendfilename appendonly.aof
20. Specify the changelog conditions with 3 optional values:
no: Indicates that the operating system synchronizes data cache to disk (fast)
always: Indicates that fsync() is manually called after each update operation to write data to disk (slow, safe)
everysec: means syncing once per second (compromise, default)
appendfsync everysec
21. Specify whether to enable the virtual memory mechanism, the default value is no, a brief introduction, the VM mechanism stores data in pagination, and Redis swaps the pages with less visits, i.e., cold data, to the disk, and the pages with more visits are automatically replaced by the disk into memory (I will carefully analyze the VM mechanism of Redis in the next article).
vm-enabled no
22. The default value of the virtual memory file path is /tmp/redis.swap, which cannot be shared by multiple Redis instances
vm-swap-file /tmp/redis.swap
23. Store all data larger than vm-max-memory in virtual memory, no matter how small the vm-max-memory setting, all index data is stored in memory (Redis index data is keys), that is, when vm-max-memory is set to 0, all values actually exist on disk. The default value is 0
vm-max-memory 0
24. Redis swap file is divided into many pages, an object can be saved on multiple pages, but a page cannot be shared by multiple objects, vm-page-size is set according to the stored data size, the author suggests that if many small objects are stored, the page size should be set to 32 or 64bytes; If you store a large object, you can use a larger page, and if you are not sure, use the default
vm-page-size 32
25. Set the number of pages in the swap file, since the page table (a bitmap that indicates the page is free or used) is placed in memory, every 8 pages on disk will consume 1 byte of memory.
vm-pages 134217728
26. Set the number of threads accessing the swap file, preferably not exceeding the number of cores of the machine, if set to 0, then all operations on the swap file are serial, which may cause a relatively long delay. The default value is 4
vm-max-threads 4
27. Set whether to merge smaller packages into one package when answering to the client, and the default is enabled
glueoutputbuf yes
28. Specifies a special hashing algorithm when a certain number or the largest element exceeds a certain threshold
hash-max-zipmap-entries 64
hash-max-zipmap-value 512
29. Specify whether to activate the reset hash, which is on by default (introduced in detail later in the introduction of Redis' hashing algorithm)
activerehashing yes
30. Specifying that the same configuration file can be used between multiple Redis instances on the same host, and each instance has its own specific configuration file
include /path/to/local.conf