Redis configuration items detailed introduction

Tip : This is my personal IT resource website. All resources are free. You can see the password after registering and logging in. You can choose what you need!
Today we will take a look at what the configuration items of Redis.conf do. If you want to use a tool well, the configuration content is the basis.

  1. daemonize no
    Redis does not run as a daemon by default, it can be modified through this configuration item, and use yes to enable the daemon (Windows does not support the configuration of the daemon as no)
  2. pidfile /var/run/redis.pid
    When Redis is running as a daemon, Redis will write the pid to the /var/run/redis.pid file by default, which can be specified by pidfile
  3. port 6379
    specifies the Redis listening port. The default port is 6379. The author explained in a blog post why 6379 was selected as the default port, because 6379 is the number corresponding to MERZ on the phone button, and MERZ is taken from the name of the Italian singer Alessia Merz
  4. bind 127.0.0.1
    bind host address
  5. timeout 300
    When the client is idle for many seconds, the connection will be closed. If 0 is specified, the function will be closed
  6. loglevel notice
    specifies the logging level, Redis supports a total of four levels: debug, verbose, notice, warning, the default is notice
  7. logfile stdout
    logging mode, the default is standard output, if Redis is configured to run as a daemon, and the logging mode is configured as standard output here, the log will be sent to /dev/null (representing an empty device file, it etc. It is equivalent to just writing to a file, all the content written to it will be lost forever. Trying to read the content from it will not read anything.)
  8. databases 16
    set the number of databases, the default database is 0, you can use the SELECT command to specify the database id on the connection
  9. save <seconds> <changes>
    specifies how long and how many update operations to synchronize the data to the data file. Multiple conditions can be used in conjunction with the
    Redis default configuration file. Three conditions are provided:
    save 900 1 means 900 seconds 1 change in (15 minutes)
    save 300 10 means 10 changes in 300 seconds (5 minutes)
    save 60 10000 means 10000 changes in 60 seconds
  10. rdbcompression yes
    specifies 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
  11. dbfilename dump.rdb
    specifies the name of the local database file, the default value is dump.rdb
  12. dir ./
    Specify the local database storage directory
  13. slaveof <masterip> <masterport>
    setting When this machine is 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 <master-password>
    When the master service is set to password protection, the password for the slave service to connect to the master
  15. requirepass foobared
    sets 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 closed by default
  16. maxclients 128
    sets 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 can be opened by the Redis process. If maxclients 0 is set, it means that there is no limit. When the number of client connections reaches the limit, Redis will close the new connection and return a max number of clients reached error message to the client
  17. maxmemory <bytes>
    Specify the maximum memory limit of Redis. Redis will load the data into the memory when it starts. After the maximum memory is reached, Redis will first try to clear the expired or expired keys. After this method is processed, it still reaches With the maximum memory setting, write operations can no longer be performed, but read operations can still be performed. Redis’s new vm mechanism will store Key in memory, and Value will be stored in the swap area
  18. appendonly no
    specifies whether to log 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 when the power is off. Because redis itself synchronizes data files 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 name of the update log file, the default is appendonly.aof
  20. appendfsync everysec
    specifies the update log condition. There are 3 optional values:
    no: means waiting for the operating system to synchronize data cache to disk (fast)
    always: means manually calling fsync() after each update operation to write data to disk (slow, Security)
    everysec: means sync once every second (compromise, default value)
  21. vm-enabled no
    specifies whether to enable the virtual memory mechanism. The default value is no. A brief introduction is that the VM mechanism stores data in pages. Redis will swap the less-visited pages, that is, cold data, to disk, and the more visited pages are from the disk. Automatically swap out to memory (I will carefully analyze Redis's VM mechanism 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
    stores all data larger than vm-max-memory in virtual memory. No matter how small the vm-max-memory is set, all index data is stored in memory (Redis index data is keys), that is Say, when vm-max-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. An object can be stored on multiple pages, but one page cannot be shared by multiple objects. The vm-page-size should be set according to the size of the stored data. Certainly, the author suggests that if you store a lot of small objects, the page size is best set to 32 or 64bytes; if you store a lot of large objects, you can use a larger page, if you are not sure, use the default value
  25. vm-pages 134217728
    sets the number of pages in the swap file. Since the page table (a bitmap that indicates that the page is free or used) is placed in memory, every 8 pages on the disk will consume 1 byte of memory.
  26. vm-max-threads 4
    Set the number of threads accessing the swap file. It is best not to exceed 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 longer delay. The default value is 4
  27. Glueoutputbuf yes
    sets whether to combine smaller packages into one package and send when replying to the client, the default is on
  28. hash-max-zipmap-entries 64 hash-max-zipmap-value 512
    specifies that when a certain number or the largest element exceeds a certain critical value, a special hash algorithm is used
  29. activerehashing yes
    specifies whether to activate reset hashing, the default is on
  30. include /path/to/local.conf
    specifies to include 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
    Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_45345374/article/details/112463545