Parameter Description
The redis.conf configuration items are described as follows:
Redis does not run as a daemon process by default, you can modify it through this configuration item, use yes to enable the
daemonize noWhen Redis runs in daemon mode, Redis will write pid to /var/run/redis.pid file by default, which can be specified by pidfile.
Specifies the listening port for Redis. The default port is 6379.
port 6379The bind host address.
bind 127.0.0.1When the client is idle for a long time, the connection is closed. If it is specified as 0, it means to close the function.
timeout 300Specify the logging level. Redis supports a total of four levels: debug, verbose, notice, warning. The default is verbose.
loglevel verboseLogging 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 stdoutSet the number of databases, the default database is 0, you can use the SELECT command to specify the database id on the connection.
databases 16Specify how many update operations in a period of time and synchronize the data to the data file. You can use multiple conditions with
save seconds changes
. Redis provides three conditions in the 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.Specifies whether to compress data when storing it in 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 yesSpecify the local database file name, the default value is dump.rdb.
dbfilename dump.rdbSpecify the local database storage directory
dir ./Set the IP address and port of the master service when the machine is the slave service. When Redis starts, it will automatically synchronize data from the master.
slaveof masterip masterportWhen the master service is password protected, the slav service connects to the master password
masterauth master-passwordSet 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. By default,
requirepass foobared is disabled.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 128Specify the maximum memory limit of Redis. Redis will load data into memory when it starts up. 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 setting is still reached. Write operations will no longer be possible, but read operations will still be possible. The new vm mechanism of Redis will store the Key in memory and the Value in the swap area.
maxmemory bytesSpecifies 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. Defaults to no
appendonly noSpecify the update log file name, the default is appendonly.aof
appendfilename appendonly.aofSpecify the update log condition, there are 3 optional values:
no : Indicates that the operating system synchronizes the data cache to the disk (fast)
always : Indicates that fsync() is manually called after each update operation to write the data to the disk (slow, safe)
everysec : means sync once per second (compromise, default)
appendfsync everysecSpecifies whether to enable the virtual memory mechanism. The default value is no. To briefly introduce, the VM mechanism stores data in pages. Redis swaps the pages with less access, that is, cold data, to the disk, and the pages that are accessed more are automatically swapped out from the disk. into memory (in a later article I will carefully analyze the VM mechanism of Redis)
vm-enabled noVirtual memory file path, the default value is /tmp/redis.swap, multiple Redis instances cannot share
vm-swap-file /tmp/redis.swapStore all data larger than vm-max-memory in 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-max When -memory is set to 0, all values actually exist on disk. Default is 0
vm-max-memory 0The 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 should be set according to the size of the stored data. The author recommends that if To 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 32Set the number of pages in the swap file. Since the page table (a kind of bitmap indicating page free or used) is placed in memory, every 8 pages on disk will consume 1byte of memory.
vm-pages 134217728Set 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 4Set whether to combine smaller packets into one packet when replying to the client, the default is to enable
glueoutputbuf yes
Specifies to use a special hash algorithm hash-max-zipmap-entries 64 hash-max-zipmap-value 512 when it exceeds a certain number or the largest element exceeds a certain threshold
Specifies whether to activate rehashing, the default is
activerehashing yesSpecify 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
include /path/to/local.conf