Home >Database >Redis >Detailed introduction to Redis configuration items

Detailed introduction to Redis configuration items

coldplay.xixi
coldplay.xixiforward
2021-01-14 09:51:392310browse

Detailed introduction to Redis configuration items

Recommended (free): Redis Tutorial

Today we will take a look at Redis. What are the functions of the conf configuration items? If you want to use a tool well, the configuration content is the basis.

  1. daemonize no
    Redis does not run as a daemon process by default. You can modify this configuration item and use yes to enable the daemon process (Windows does not support the daemon process configuration as no)
  2. pidfile /var/run/redis.pid
    When Redis runs as a daemon, Redis will write the pid to the /var/run/redis.pid file by default. You can specify it through pidfile
  3. port 6379
    Specify the Redis listening port. The default port is 6379. The author explained in one of his blog posts why 6379 was chosen as the default port because 6379 is the number corresponding to MERZ on the phone button, and MERZ is taken from the Italian singer Alessia Merz. Name
  4. bind 127.0.0.1
    Bind host address
  5. timeout 300
    The number of seconds when the client is idle to close the connection. If it is specified as 0, it means to turn off this function
  6. loglevel notice
    Specify the logging level. Redis supports a total of four levels: debug, verbose, notice, and warning. The default is notice
  7. logfile stdout
    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 (representing an empty device file, which is equivalent to a write-only file, all Anything written to it will be lost forever. If you try to read from it, nothing will be read.)
  8. databases 16
    Set the number of databases, the default database is 0, you can use the SELECT command Specify the database id on the connection
  9. save
    Specify the period of time and how many update operations there are to synchronize the data to the data file. It can be multiple Condition matching
    Three conditions are provided in the Redis default configuration file:
    save 900 1 means there is 1 change within 900 seconds (15 minutes)
    save 300 10 means there are 10 changes within 300 seconds (5 minutes) Changes
    save 60 10000 means there are 10,000 changes within 60 seconds
  10. rdbcompression yes
    Specifies whether to compress the data when storing it in the local database. The default is yes. Redis uses 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
  11. dbfilename dump.rdb
    Specify the local database file name, the default value is dump.rdb
  12. dir ./
    Specify the local database storage directory
  13. slaveof
    Set when the local machine serves the slave service, set the IP address and port of the master service. When Redis starts, It will automatically synchronize data from the master
  14. masterauth
    When the master service sets password protection, the password for the slave service to connect to the master
  15. requirepass foobared
    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. It is closed by default
  16. maxclients 128
    Set the maximum client connections at the same time Number, unlimited by default. 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 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
  17. maxmemory
    Specifies the maximum memory limit of Redis, Redis is Data will be loaded into memory at startup. After reaching the maximum memory, Redis will first try to clear expired or expiring keys. After this method is processed, the maximum memory setting is still reached, and writing operations will no longer be possible. But read operations are still possible. Redis's new vm mechanism will store Key in memory and Value in swap area
  18. appendonly no
    Specify whether to log after each update operation. Redis is asynchronous by default. Data is written to disk, and if it is not turned on, it may cause data loss for a period of time during a power outage. Because redis's own synchronized data files are synchronized according to the above save conditions, some data will only exist in memory for a period of time. The default is no
  19. appendfilename appendonly.aof
    Specifies the update log file name, the default is appendonly.aof
  20. appendfsync everysec
    Specifies the update log conditions, there are 3 optional values:
    no: means waiting for the operating system to synchronize the data cache to the disk (fast)
    always: means manually calling fsync() after each update operation to write the data to the disk (slow, safe)
    everysec: means Synchronize once per second (compromise, default value)
  21. vm-enabled no
    Specifies whether to enable the virtual memory mechanism, the default value is no, a brief introduction, the VM mechanism stores data in pages, and Redis will Pages with less access are swapped to the disk as cold data, and pages with more access are automatically swapped out from the disk to memory (I will carefully analyze the VM mechanism of Redis in a later article)
  22. vm-swap- file /tmp/redis.swap
    Virtual memory file path, the default value is /tmp/redis/swap, cannot be shared by multiple Redis instances
  23. vm-max-memory 0
    Store all data larger than vm-max-memory in virtual memory. No matter how small the vm-max-memory setting is, all index data is stored in memory (the index data of Redis is keys). That is to say, when vm-max When -memory is set to 0, all values ​​actually exist on the disk. The default value is 0
  24. vm-page-size 32
    The Redis swap file is divided into many pages. One object can be saved on multiple pages, but one page cannot be shared by multiple objects. vm -page-size should be set according to the size of the stored data. The author recommends that if you store many small objects, the page size is best set to 32 or 64 bytes; if you store many large objects, you can use a larger page. If not OK, use the default value
  25. vm-pages 134217728
    Set the number of pages in the swap file. Since the page table (a bitmap indicating that the page is free or used) is placed in the memory, in Every 8 pages on the disk will consume 1 byte of memory
  26. vm-max-threads 4
    Set the number of threads to access the swap file. It is best not to exceed the number of cores of the machine. If set to 0, then all Operations on swap files are all serial and may cause a long delay. The default value is 4
  27. glueoutputbuf yes
    Sets whether to combine smaller packets into one packet and send them when responding to the client. The default is to enable
  28. hash-max-zipmap- entries 64 hash-max-zipmap-value 512
    Specify a special hash algorithm to be used when a certain number is exceeded or the largest element exceeds a certain critical value
  29. activerehashing yes
    Specify Whether to activate the reset hash, the default is on
  30. include /path/to/local.conf
    Specifies to include other configuration files, and the same configuration can be used between multiple Redis instances on the same host file, and each instance has its own specific configuration file
    Detailed introduction to Redis configuration items

The above is the detailed content of Detailed introduction to Redis configuration items. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete