redis is an open source, high performance bond - value storage (Store key-value), and the like memcached, redis often referred to as a key-value memory database or memory storage system, and because it supports rich data structure, also known as a server, a data structure (data structure server).
After compiling Redis, its configuration file in the source directory redis.conf, copy it to the working directory to use, the following detailed explanation of the parameters redis.conf:
1 daemonize no
By default, redis is not running in the background, if you need to run in the background, to change the value of the item to yes.
2 pidfile /var/run/redis.pid
When Redis running in the background, Redis will default pid file on /var/run/redis.pid, you can configure to another address. When running multiple redis service, you need to specify a different pid files and port
3 port
Listening port, default to 6379
4 #bind 127.0.0.1
Redis specified only receives requests from the IP address, if not set, then process all requests, is preferably provided to the safety in a production environment. Comment out the default, do not open
5 timeout 0
When the timeout setting client connection seconds. When the client does not issue any command during this time, then close the connection
6 tcp-keepalive 0
Specify whether the TCP connection is a persistent connection, "detective" signal has a server-side maintenance. The default is 0. disables
7 loglevel notice
log divided into three grades 4, debug, verbose, notice, and warning. Production environment in general turned notice
8 logfile stdout
Configuration log file address, the standard default output, i.e., printing on the window displayed on the terminal, to modify the log file directory
9 databases 16
Set the number of the database, you can use the SELECT command to switch the database. Database used by default is 0 library. 16 default library
10
save 900 1
save 300 10
save 60 10000
Save data snapshot frequency, data persistence is about to frequency dump.rdb file. Used to describe "how many seconds at least during the operation of changing the number of" trigger snapshot data storage operation
The default setting, which means:
if (10,000 keys when a change has occurred within 60 seconds) {
Mirrored backup
} Else if (there are 10 keys in a changed within 300 seconds) {
Mirrored backup
} Else if (there is a change in the keys 900 seconds) {
Mirrored backup
}
11 stop-writes-on-bgsave-error yes
When a persistent error, whether still continue to work, whether to terminate all client write requests. The default setting "yes" means the end of, once the snapshot data retention faults, then the server is read-only service. If "no", then the snapshot will fail, but the next snapshot will not be affected, but if a failure occurs, the data can be restored only to "the nearest point of a successful"
12 rdbcompression yes
During data image backup, whether to enable rdb file compression tool, the default is yes. Compression may require additional spending cpu, but it can effectively reduce the large rdb file is conducive to storage / backup / transfer / data recovery
13 rdbchecksum yes
Read and write time, lose 10% performance
14 rdbchecksum yes
Whether checksums, CRC64 checking on whether to use rdb file and the default is "yes", then the end will append the contents of each file rdb CRC checksum, which will help third-party verification tools detect file integrity
15 dbfilename dump.rdb
Filename image backup file, the default is dump.rdb
16 you ./
Rdb database mirroring backup file AOF file placement path /. Here the path with the file name you want to configure separate Redis is because when doing a backup, first the current status of the database is written to a temporary file, such as when the backup is complete, then replaced the above-specified file temporary file, and here's configured temporary files and backup files are placed above the specified path among
17 # slaveof
Set the database to other databases from the database, and assign master information.
18 masterauth
When the master database connection requires password authentication, here designated
19 slave-serve-stale-data yes
When the primary master server or hang from the master copy is performed, whether still allow customers to access data may be outdated. In the "yes" case, slave read-only continue to provide services to the client, then the data may have expired; in "no", any data sent to the server of this service request (including a client and a server in this slave) will be informed of "error"
20 slave-read-only yes
slave is "read only", it is strongly recommended to "yes"
21 # repl-ping-slave-period 10
slave sending ping messages to the designated master time interval (in seconds), default is 10
22 # repl-timeout 60
slave and master communication, the maximum idle time, default 60 seconds timeout will cause the connection is closed
23 repl-disable-tcp-nodelay no
slave connected to the master, and whether to disable TCP nodelay option. "Yes" to disable, then the data in socket communication will be sent to the packet mode (packet size by the socket buffer limit).
Can improve the efficiency of communications socket (tcp number of interactions), but the data will be small buffer, will not be sent immediately, there may be a delay for the recipient. "No" indicates turning tcp nodelay option, any data will be sent immediately, timeliness is good, but less efficient, it is recommended to NO
24-Slave-priority 100
Applicable Sentinel module (unstable, MS cluster management and monitoring), additional profile support. Weight values slave, the default 100. When the master fails, Sentinel will find the lowest weight value from the slave list (> 0) of the slave, and promoted to master. If the weight value of 0 indicates that the slave as an "observer", does not participate in master election
25 # requirepass foobared
Any other specified password before you want to use the client connection settings. Warning: Because redis very fast, so in a better server, an external user can password attempts 150K times in one second, which means you need to specify very, very strong password to prevent brute force.
26 # rename-command CONFIG 3ed984507a5dcd722aeade310065ce5d (方式:MD5(‘CONFIG^!’))
Rename instructions, instructions related to some of the "server" control, you may not want a remote client (non-admin user) are free to use links, then you can put these instructions renamed to "difficult to read" the other strings
27 # maxclients 10000
Limit the number of simultaneous client connections. When the number exceeds this value, other Redis will no longer receive the connection request, the client tries to receive an error message when connected. The default is 10000, to consider the system file descriptor limit should not be too large, a waste of file descriptors, depending on how many specific circumstances
28 # maxmemory
redis-cache can use the maximum memory (bytes), the default is 0, which means "unlimited", the final OS is determined by the size of physical memory (if physical memory, it is possible to use the swap). This value as not more than the machine's physical memory size, from the viewpoint of performance and implementation considerations, physical memory may be 3/4. This configuration requires and "maxmemory-policy" with the use of the memory when the data reaches redis maxmemory, trigger a "clear strategy." When "Out of Memory", any write operation (such as set, lpush, etc.) will trigger a "clear strategy" of execution. In a real environment, it is recommended that all physical hardware configuration of the machine redis consistent (the same memory), while ensuring that master / slave in "maxmemory" "policy" consistent configuration.
When the memory is full time, if it receives the set command, redis will first try to eliminate the key information set off expire, regardless of whether the key expiration time has not yet arrived. When you delete,
Will be deleted in accordance with the expiration time, the first to be expired key will be the first to be removed. If the key expire with the light of information are deleted, memory is not enough, then the error is returned. In this way, redis will no longer receive a write request, receive only get request. maxmemory setting more suitable for the redis as similar to memcached cache to use.
29 # maxmemory-policy volatile-lru
Out of Memory ", the data clear strategy, the default is" volatile-lru ".
volatile-lru -> data "outdated collection" of taking LRU (least recently used) algorithm if you specify the expiration time using the "expire" instruction key, then the key will be added to "Expired sets'. Would have expired / LRU priority data removed if "expired sets' remove all memory still can not meet demand, the OOM..
AllKeys-the LRU -> all data, using LRU algorithm
volatile-random -> to" Expired a collection of "data taken" randomly chosen "algorithm, and remove selected KV, until the" expiration enough memory collection "remove remove all in all still can not meet the OOM" far if if. "
AllKeys-Random -> All data taken "randomly selected" algorithm, and remove selected KV, until "enough memory" until the
volatile-ttl -> data "outdated collection" of taking TTL algorithm (minimum survival time), is about to be removed outdated data.
noeviction -> operation without any interference, direct return OOM abnormal
in addition, if the data is not expired on the "system" to bring an exception, and the operating system write-intensive, recommended "allkeys-lru"
30 # maxmemory-samples 3
Default 3, and above the minimum TTL LRU strategy is not strict policy value, but about the estimated manner, it is possible to select the sample values to check
31 appendonly no
By default, redis in the background of the asynchronous database mirroring backup to disk, but the backup is a very time-consuming, and not very frequent backups. So redis provides another more efficient database backup and disaster recovery mode. After the turn append only mode, the received redis will each write request appendonly.aof are appended to the file when redis restart, before the state will recover from the file. But this will cause appendonly.aof file is too large, so redis also supported BGREWRITEAOF instructions for appendonly.aof be rearranged. If you do not frequent data migration operations, practices in the production environment is recommended to close the mirror, turn appendonly.aof, and you can choose to appendonly.aof rewritten once a day visit in less time.
In addition, to master the machine, is responsible for writing, it is recommended to use AOF, for the slave, is responsible for reading and pick out 1-2 sets open AOF, the rest of the proposed closure
32 # appendfilename appendonly.aof
aof file name, the default is appendonly.aof
33
# appendfsync always
appendfsync everysec
# appendfsync no
Set appendonly.aof frequency synchronization of files. always represent every write operations are synchronized, everysec told accumulated write operation, synchronization once per second. no no initiative fsync, done by the OS itself. This needs to be configured according to the actual business scenarios
34 no-appendfsync-on-rewrite no
During aof rewrite, whether to suspend the use of file synchronization strategy append aof a new record, the main consideration expenses and disk IO request blocking time. The default is no, means "not suspend", the new record will still be aof Sync Now
35 auto-aof-rewrite-percentage 100
When the ratio exceeds the specified Aof log growth, rewriting log file, set to 0 not log Aof automatically rewritten, rewriting is kept to a minimum in order to make aof volume, while ensuring the best preserved data.
36 auto-aof-rewrite-min-size 64mb
Triggered aof rewrite minimum file size
Taking time-limit 37 5000
The maximum time lua script to run
38 slowlog-log-slower-than 10000
"Slow operation log" records, unit: microseconds (millionths of a second, 1000 * 1000), if the operation time exceeds this value, the command information will "record" up (memory, non-file). The "operating time" does not include network IO expenses, time request includes only "memory implementation" after reaching the server. "0" indicates the entire operation of the recording
39 slowlog-max-len 128
The maximum number of "slow operation log" reserved "record" will be queued, if more than this length, the old record will be removed. You can view recorded by slow "SLOWLOG args" information (SLOWLOG get 10, SLOWLOG reset)
40
hash-max-ziplist-entries 512
hash types of data structures may be used in coding ziplist and hashtable. ziplist feature is file storage (memory and storage) less space required, when the content is small, performance and hashtable almost the same. Therefore redis take ziplist type of hash default. If the number of entries in the hash entry or length reaches a threshold value, will be reconstructed as hashtable.
This parameter is the maximum number of entries allowed ziplist stored default ,, 512, recommendations 128
the hash-value 64-max-ziplist
ziplist allows entry value the maximum value of the number of bytes, default is 64, 1024 recommendations
41
list-max-ziplist-entries 512
list-max-ziplist-value 64
For list type, we will take ziplist, linkedlist two encoding types. She explained above.
42 set-max-intset-entries 512
The maximum number of entries allowed IntSet saved if the threshold is reached, will be reconstructed as IntSet Hashtable
43 is
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
zset ordered set, there are two types of encoding: ziplist, skiplist. Because the "Sort" will consume extra performance, when more data zset, it will be reconstructed as skiplist.
44 activerehashing yes
Whether to open the top-level function rehash data structures, if memory allows, turn. rehash can greatly improve the efficiency of KV access
45
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
The client buffer control. Interaction with the client for the server, each connection will be associated with a buffer, this buffer for client queue of waiting to be received response information. If the client does not promptly respond to consumer information, the buffer will be constantly brought backlog memory pressure to server. If the buffer data reaches a threshold in the backlog will result in the connection is closed, buffer is removed.
buffer control type comprising: normal -> conventional connector; slave - the connection between> and the slave; pubsub -> pub / sub type connector, this type of connection, such a problem tends to occur; pub terminal will release information because intensive , but the sub side may be insufficient consumption.
instruction format: client-output-buffer-limit <class> <hard> <soft> <seconds>"
wherein represents a hard buffer maximum, once the threshold is reached immediately close the connection;
soft represents "tolerance value", and seconds with it, if the value exceeds the buffer duration reaches a soft and seconds the, will close the connection immediately, but if it exceeds the after seconds the soft, a soft buffer data is less than, the connection will be retained.
wherein the hard and soft are set to 0, then the control disables buffer usually greater than hard soft.
46 hz 10
Frequency Redis server perform background tasks, default is 10, this value indicates the larger of the number of executions redis "intermittent task" is more frequently (times / second). "Intermittent task" comprising "Expired set" test, close the "idle timeout" and the like are connected, this value must be greater than 0 and less than 500. This value is too small to mean more cpu cycles consumed, the number of background task polled more frequently. This means that the value is too large "memory-intensive" poor. The default value is recommended.
47
# include /path/to/local.conf
# include /path/to/other.conf
Additional load profile.
Transfer: https://blog.csdn.net/neubuffer/article/details/17003909