redis.conf configuration file parameter description

The redis.conf configuration items are described as follows:

1. Redis does not run as a daemon process by default, you can modify it through this configuration item and use yes to enable the daemon process

  daemonize no

2. When Redis runs as a daemon process, Redis will write the pid to the /var/run/redis.pid file by default, which can be specified by pidfile

  pidfile /var/run/redis.pid

3. Specify the Redis listening port. The default port is 6379. The author explained why 6379 was chosen as the default port in his blog post, because 6379 is the number corresponding to MERZ on the phone button, and MERZ is taken from the name of Italian singer Alessia Merz

  port 6379

4. Binding host address

  bind 127.0.0.1

5. When the client is idle for how long, the connection is closed. If it is specified as 0, it means that the function is closed.

  timeout 300

6. Specify the logging level, Redis supports a total of four levels: debug, verbose, notice, warning, the default is verbose

  loglevel verbose

7. Logging mode, the default is standard output. If Redis is configured to run in daemon mode, and the logging mode 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, you can use the SELECT <dbid> command to specify the database id on the connection

  databases 16

9. Specify how many update operations in a period of time and synchronize the data to the data file, which can be matched with multiple conditions

  save <seconds> <changes>

  Three conditions are provided in the Redis default configuration file:

  save 900 1

  save 300 10

  save 60 10000

  Respectively means 1 change in 900 seconds (15 minutes), 10 changes in 300 seconds (5 minutes), and 10000 changes in 60 seconds.

10. Specify whether to compress the 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 storage directory

  to you ./

13. Set the IP address and port of the master service when the machine is the slav service. When Redis starts, it will automatically synchronize data from the master

  slaveof <masterip><masterport>

14. When the master service is password protected, the password for the slave service to connect to the master

  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 <password> command when connecting to Redis, 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 the 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 will close the new connection and return the max number of clients reached error message to the client

  maxclients 128

17. Specify the maximum memory limit of Redis. Redis will load the data into the memory when it starts. After reaching the maximum memory, Redis will first try to clear the keys that have expired or are about to expire. After this method is processed, the maximum memory is still reached. set, write operations are no longer possible, but read operations are still possible. The new vm mechanism of Redis will store the Key in memory and the Value in the swap area

  maxmemory <bytes>

18. Specify whether to perform logging after each update operation. Redis writes data to disk asynchronously by default. If it is not turned on, it may cause data loss for a period of time during power failure. Because redis itself synchronizes data files according to the above save conditions, some data will only exist in memory for a period of time. Default is no

  appendonly no

19. Specify the update log file name, the default is appendonly.aof

   appendfilename appendonly.aof

20. Specify the update log condition, there are 3 optional values: 

  no: Indicates waiting for the operating system to synchronize the data cache to the disk (fast) 

  always: Indicates that fsync() is manually called to write data to disk after each update operation (slow, safe) 

  everysec: means sync once per second (compromise, default)

  appendfsync everysec

21. Specify whether to enable the virtual memory mechanism. The default value is no. To briefly introduce, the VM mechanism stores data in pages, and Redis swaps the pages with less access, that is, cold data, to the disk, and the pages that are accessed more are automatically stored by the disk. Swap out to memory (I will analyze Redis' VM mechanism carefully in a later article)

   vm-enabled no

22. The virtual memory file path, the default value 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 into virtual memory, no matter how small vm-max-memory is set, all index data are stored in memory (Redis index data is keys), that is, when vm When -max-memory is set to 0, all values ​​actually exist on disk. Default value is 0

   vm-max-memory 0

24. The Redis swap file is divided into many pages. An object can be stored on multiple pages, but a page cannot be shared by multiple objects. The vm-page-size is set according to the size of the stored data. The author It is recommended that if you store many small objects, the page size is best set to 32 or 64 bytes; if you store very large objects, you can use a larger page, if you are not sure, use the default value

   vm-page-size 32

25. Set the number of pages in the swap file. Since the page table (a bitmap indicating page free or used) is placed in memory, every 8 pages on the disk will consume 1byte of memory.

   vm-pages 134217728

26. Set the number of threads accessing the swap file, preferably not more than the number of cores of the machine. If it is set to 0, then all operations on the swap file are serial, which may cause a long delay. Default is 4

   vm-max-threads 4

27. Set whether to combine smaller packets into one packet to send when replying to the client, the default is ON

  glueoutputbuf yes

28. Specify a special hash algorithm to be used 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, the default is ON (the details will be introduced later when the Redis hash algorithm is introduced)

  activerehashing yes

30. Specify other configuration files, you can use the same configuration file between multiple Redis instances on the same host, and each instance has its own specific configuration file

  include /path/to/local.conf

Guess you like

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