Redis3.2.6 Configuration file details in Chinese

  • 2020-06-12 10:57:15
  • OfStack

Redis3.2.6 The latest configuration file details the Description in Chinese. Read the description directly without saying anything


##############
#  Specify configuration file: 
################################## INCLUDES #####################################
#
# 1  Include file 
#  If you want to use a configuration file, Redis The service must begin with the path to the configuration file 1 Start with 10 parameters. Such as: ./redis-server /path/to/redis.conf
#  The unit that : Different units may be used when specifying the memory size, for example 1k , 5GB , 4M Etc., the unit meaning is given here: 
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
# 1gb => 1024*1024*1024 bytes
# s Specifies that the unit is case insensitive. Such as 1GB , 1gB , 1Gb is 1 Kind of. 
# include Use: 
#  Used for include1 Three or more profiles. 
#  When you need to in 1 Three standard common configuration templates 1 Some customization, can be used include  Keyword to include These personalization profiles. 
#  Note: Although admin  or Redis Sentinel Under the execution of" CONFIG REWRITE "The order, Redis 2.8  The imported command) overrides the configuration, but does not include the include Key words. In other words," CONFIG REWRITE "Cover" include "Related content. 
#  Due to the redis The final configuration is used as the direct configuration, so it is recommended that include Commands are placed at the front of the configuration file to prevent the configuration from being overwritten. 
#  However, if you intend to use another configuration file to override some or all of the configuration of the current file, you can include The command is placed at the end of the file. 
# Redis The principle of final validation is used here, that the last configuration resolved will be the last configuration. 
#  Format as follows: 

# include /path/to/local.conf
# include /path/to/other.conf

##############
#  Network configuration: 
#  Perform parameters related to the server network 1 A configuration. 
################################## NETWORK #####################################
#
# 1 bind The command 
#  We know that, 1 There may be multiple network interfaces on the server, so if not used bind Specify the interface, Redis Connection requests from all network interfaces on the machine will be listened for. 
#  If you just want to listen 1 Or more specified interfaces, you can use the bind "Command to specify the interface. 
#  Examples are as follows: 
# bind 192.168.1.100 10.0.0.1
# bind 127.0.0.1 ::1
# ~~~ WARNING ~~~  If you run Redis The service machine directly leaks in Internet , then binding all interfaces to is 1 A dangerous thing. Because that's what's going to happen Redis The service was leaked Internet Each of the 1 The individual. So by default, use bind 127.0.0.1 Command forces Redis Listening to the IPv4 Loop back to the interface address, that is Redis Only native client requests are accepted. 
#  The server can have 1 A network interface (usually described as a network card), or more. Suppose there are two network CARDS on a machine, respectively 192.168.205.5  and 192.168.205.6 If the bind 192.168.205.5 , then only the network card address accepts external requests, if not bound, then both network card ports accept requests. 
#  You need to log out of the command line if you need to access the outside network. In the configuration file," # "Is for comment. 
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bind 127.0.0.1
# 2  Protected mode 
#  The protective mode is Redis The security layer provided. This layer is set up to prevent the network from being closed Redis Arbitrary access to the instance. 
#  The mode needs to be turned on when: 
# 1 )   Not using" bind "The command specifies the address to bind to; 
# 2 )   Not for Redis Configure passwords. 
#  After this mode is started, the server can only be used IPv4 , IPv6 Loopback address ( 127.0.0.1 or ::1 ) and local Socket The connection request of the client. 
#  By default, protected mode is on. It is recommended only for clients that are explicitly connected without authorization or use bind The mode is only closed when a specific interface is specified. 
#  Use the following: 
protected-mode yes
# 3  port 
#  Listens on the specified port. The default is  6379 . When the port is set to 0 When, Redis Wouldn't be in TCP socket Listen on. 
#  Use the following: 
port 6379
# 4 TCP listen() backlog Set up the 
#  in 1 In an environment with high concurrency, you need to specify 1 A bigger one backlog Value to avoid slow connection situations. Pay attention to, linux The kernel will be used by default /proc/sys/net/core/somaxconn Value to reduce backlog The actual value. So in order to get the desired value, you need to make sure that it increases  somaxconn  and  tcp_max_syn_backlog  These two values. 
#  Recommended configuration: 
tcp-backlog 511
# 5 Unix socket
#  The specified Unix socket Path to listen for connections. Default is not specified, therefore redis Not in the Unix socket Listen on. 
#  The usage is as follows: 
# unixsocket /tmp/redis.sock
# unixsocketperm 700
# 6 Client timeout
#  when client In the free N After seconds, close the connection ( 0 Means no idle connection will be processed, default mode) 
#  Example: 
timeout 0
# 7 TCP keepalive time 
#  When the value is non-zero, if communication is missing, Redis Will use SO_KEEPALIVE send TCP ACKs To the client. There are some advantages to this 2 : 
# 1 ) The test has died on the opposite end. ( TCP Closing existence cannot complete 4 Handshake, such as power outage, network outage, data loss, etc.) 
# 2 ) Preserve the activity of the existing connection. 
#  in Linux , the specified time is 1 Time to send ACKs Time slice. For other kernel systems, the time slice size is related to the kernel configuration. 
# 1 A reasonable value would be 300 seconds . Redis 3.2.1 After version, this value is specified by default 300 seconds . 
#  Examples are as follows: 
tcp-keepalive 300

##############
#  General configuration: 
#  right 1 Some common parameters are configured. 
################################# GENERAL #####################################
#
# 1 daemon
#  By default, Redis Is not 1 The daemons, if needed, will Redis Set to a daemon, which can be used daemonize yes Configure. Note: when Redis As a daemon,   its pid  File for  /var/run/redis.pid . 
#  Use the following: 
daemonize no
# 2 supervision
# Redis 3.2 New command. If the machine needs to be started ( upstart model   or systemd Mode) Redis Server, which can be configured with this option Redis . 
#  Supported modes: 
# supervised no  �   No, not with supervised tree interact 
# supervised upstart  �   will Redis Server added to SIGSTOP  In the model 
# supervised systemd  �   will READY=1  write  $NOTIFY_SOCKET
# supervised auto  �   According to the environment variable UPSTART_JOB  or NOTIFY_SOCKET detection upstart  or  systemd
#  Notice, above supervision Methods ( upstart or systemd ) only "program ready" signal will not be given supervisor return ping A reply. 
#  Default is not on: 
supervised no
# 3 pid file 
#  If you specify pid File, Redis Will be written at startup pid File, which is deleted on exit. 
#  when Redis When the server is started with a daemon, the configuration file is used directly if specified, or created if not specified /var/run/redis.pid As a configuration file. 
#  Use the following: 
pidfile /var/run/redis_6379.pid
# 4  The level of logging 
#  Specify the server's verbosity Level. Redis provide 4 Different levels: 
# debug  - -  Contains a wealth of information for development and testing purposes 
# verbose  - -  contains 1 Some rare and useful information, but none debug Level of confusion 
# notice  - -  Appropriate amount of prompt information for production environment 
# warning  - -  Contains only very important and critical information 
#  The default is notice Levels: 
loglevel notice
# 5  Log file name 
#  Specify a log file name. Null will be output to a standard output device. if Redis Starts as a daemon, and when the log file name is called null, the log will be printed to  /dev/null . 
#  Default Settings are as follows: 
logfile ""
# 6  Write system log 
# 6.1 Allows writing system logs 
#  will syslog-enabled Set to yes When,   Allows you to Redis The service log is logged to the system log. In addition, 
#  More logging parameters can be used to meet specific requirements. 
#  Examples are as follows: 
# syslog-enabled no
# 6.2 Specifies the identity in the system log 
# 1 denier enable Writes to the system log to specify the identity of the service in the system log. Examples are as follows: 
# syslog-ident redis
# 6.3 Specifies the system logging capability level 
#  The system log level must be  LOCAL0  to  LOCAL7  Between (closed interval). Examples are as follows: 
# syslog-facility local0
# 7  Number of databases 
#  Set the number of databases. Use the default 0 Database no. Can be found in every 1 Use on a connection SELECT <dbid>  To specify another database, but this value must be in  0 to   ' database'-1 In between. 
#  Examples are as follows: 
databases 16

################
#  Snapshot configuration: 
# Redis Provides snapshot capability to record a 1 Data held in a time database. 
################################ SNAPSHOTTING ################################
#
# 1 DB persistence 
#  will DB Save the data to disk. Format for: save <seconds> <changes> . When within a given time seconds , if you have written to disk more than once changes , it will DB Save the data to disk. Such as save 900 1 Said in 900 In seconds, if that's right DB Carried out at least 1 For the second write operation, will DB Data is persisted to disk. 
#  Note that all can be logged off save Command or will be at all save Append after command save Empty ( save  ") command to disable save Function. Use examples: 
save 900 1
save 300 10
save 60 10000
# 2 bgsave-error
#  By default, occurs in RDB The snapshot or BGSAVE The one whose execution failed 1 Time, Redishi Perform receive write requests. This causes the user to perceive (often with difficulty) that the data is not persisted correctly to disk. Otherwise, catastrophic consequences could go undetected. 
#  When the background BGSAVE When the program can start working again, Reidis Writes are automatically allowed again. 
#  If you've already met the Server And server persistence are properly monitored, so when you disable this feature, even if there is a problem with disk, persistence, etc., Redis We can continue to provide services. 
#  Examples are as follows: 
stop-writes-on-bgsave-error yes
# 3 rdbcompression
#  By default, in dump RDB A file, Redis using LZF ( 1 A kind of efficient compression algorithm) algorithm for string object data compression, its performance is higher. although LZF The algorithm is going to consume part of it CPU Performance, but its data compression can be higher, so it is recommended not to close: 
rdbcompression yes
# 4 RDB The file name 
#  This command is used for definitions dump DB The file name of the file. Format as follows: 
dbfilename dump.rdb
# 5  Working directory 
#  The specified RDB The directory where the file is located. This directory is also AOF The directory where the file is located. Notice that this is specified 1 Not filenames, but directories. The default is the current directory in the following format: 
dir ./

##################
#  Replication configuration: 
# Redis Provide master-slave replication to ensure the reliability of data. 
################################# REPLICATION ###################################
#
# 1  The master-slave relationship is established 
# Redis Master-slave replication. In stand-alone mode, Redis Support the use of slaveof Command from the other 1 a Redis Create from a copy of the server 1 An instance. Cluster mode is used cluster replicate <master-id> Command. Redis Notes before copying and using: 
# 1 ) Redis Replication is asynchronous, but the number of connected slave nodes can be configured. 
# 2 ) When the connection is broken, Redis Slave nodes support partial resynchronization ( psync ) function to ensure master and slave data synchronization. 
# 3 ) The replication process is 1 An automated process without human intervention. When network partitioning occurs, slave nodes automatically attempt to establish a connection with the master node and attempt to synchronize. 
#  The command to establish a master-slave connection is as follows: 
# slaveof <masterip> <masterport>
# 2  Authorization code 
#  When password protection is enabled on the master node (via configuration) "requirepass"  Command), the slave node must authorize before starting replication synchronization or its request will not be accepted. 
#  The order is as follows: 
# masterauth <master-password>
#  Note that this command takes effect only if password protection is turned on by the master node. 
# 3  Whether the slave node supports dirty reads 
#  When the master and slave disconnect or the master and slave replicate, the slave nodes have two strategies: 
# 1 ) if the" slave-serve-stale-data "Parameter set to" yes "(by default), the slave node can respond to a client request, although it may recover stale or empty data if the master slave is in control 1 Second synchronization). 
# 2 ) if the" slave-serve-stale-data "Parameter set to" no ", then the slave node will be divided INFO  and SLAVEOF Returns an external command "SYNC with master in progress" Information. 
#  Default Settings are as follows: 
slave-serve-stale-data yes
# 4  Whether the slave node supports write 
#  Specifies whether the slave node supports write operations. When you need to store 1 It is useful to have slave nodes support write operations when there is some temporary data. such 1 The data that has been written to the slave node can be easily deleted through master-slave synchronization. However, if the configuration is wrong, problems such as client write errors can occur. 
#  Note that from Redis 2.6 After that, the slave nodes are read-only by default. 
#  Note that read-only slave servers are not designed to serve untrusted Internet clients. The server setup for this mode is just 1 A layer of protection against misoperation on a server instance. By default, read-only slave servers can output administrator commands, such as CONFIG ,  DEBUG And so on. If you want to restrict administrative commands that are output from read-only slave nodes, you can do so 'rename-command'  Command to hide these administrator commands or hazard commands. 
#  Improve its security so that she ACTS as 1 A shadow to carry out administrative or dangerous orders. Default Settings are as follows: 
slave-read-only yes
# 5  Replication strategy: No disk available 
#  There are two data synchronization strategies for master and slave nodes: disk synchronization and socket synchronization. 
#  -- -- -- -- -- -- -- -- -- -
# WARNING:  Diskless replication ( DISKLESS REPLICATION I It is still in the experimental stage 
#  -- -- -- -- -- -- -- -- -- -
#
#  For new connections slaves Or disconnected reconnected slaves Partial synchronization will not be possible and needs to be performed 1 Time to completely #  Step. When full synchronization occurs, the master node propagates 1 a RDB File to slave node. the RDB How the document is transmitted #  There are two: 
# 1 ) Based on disk: Redis Master node creation 1 A new process will RDB The file will be written to disk and then generated RDB Files are propagated to slave nodes. 
# 2 ) Diskless: Redis Master node creation 1 A new process will be directly transferred RDB The file write slaves In the socket of, RDB Files do not need to be dislodged. 
#  Disk-based replication, 1 denier RDB File generation, multiple slaves The file will be queued and can be Shared. No disk replication 1 Once the data is transmitted, new slaves There will be a queue when they arrive. 
#  With diskless replication, the master node will wait according to the configured time before starting to transmit synchronous data, enabling concurrent transfers of multiple slave nodes. 
#  Diskless replication is more efficient when the disk is slow and the network is fast (high bandwidth). By default, disk-free replication synchronization is turned off. The configuration is as follows: 
repl-diskless-sync no
# 6  No disk replication wait time 
#  The amount of time the primary node has to wait before it can replicate without disk. This configuration takes effect when diskless replication is enabled. 
#  Due to the 1 Denier open 1 Secondary data transfer, rest slaves Will be queued, so it is better to have the master node wait 1 Period of time, so that the primary node can match multiple slaves Concurrent propagation of data. 
#  The unit of wait is seconds ( second ), the default is 5 Seconds. 1 Once set to 0 , the master node will start the data transfer immediately. The default configuration is as follows: 
repl-diskless-sync-delay 5
# 7 slaves Timing to master send PING The time slice 
#  By default, slaves every 10 Seconds to master send 1 time PING The message. Can be set according to network and other factors. This configuration is turned off in the configuration file by default: 
# repl-ping-slave-period 10
# 8  Replication timeout threshold 
#  The replication timeout threshold is used in the following scenarios: 
# 1)  The slave node is executing SYNC The block file transfer timeout is detected 
# 2)  Slave node detection master node offline ( data , pings ) 
# 3)  Master node detection slave node offline ( REPLCONF ACK ) 
#  You must ensure that the replication timeout threshold ( repl-timeout ) is greater than the slaves Timing to master send PING Time slice ( repl-ping-slave-period ), otherwise a replication timeout will always be detected (when slave send PING When the time slice is greater than the replication timeout threshold, slave Has not been sent ping It will be characterized as a replication timeout. Use the following format: 
# repl-timeout 60
# 9 TCP_NODELAY function 
#  after SYNC After, whether to disable TCP_NODELAY . 
#  When this feature is disabled, Redis They use smaller ones that take up less bandwidth TCP Packets send data to slave nodes. But doing so will increase the delay of data transfer from the node. in Linux The disabled TCP_NODELAY The function will result in 40  Microsecond delay. 
#  When enabled, replication reduces data transfer latency but takes up more bandwidth. 
#  By default, we prefer low latency, but high latency on high-speed networks or master-slave nodes hops Path, it is recommended to disable TCP_NODELAY Function. 
#  The default open TCP_NODELAY Function. Format as follows: 
repl-disable-tcp-nodelay no
# 10  Copy the backlog buffer size 
#  Set the replication backlog buffer ( replication backlog ) size. when slaves After disconnecting from the node, Redis Records using the replication backlog buffer need not be sent to slave The data. When the slave node is reconnected, only execution is required 1 Subpartial synchronization will complete the missing data from the slave node. 
#  Copy backlog buffer ( replication backlog The greater the), Redis Supportable slave The longer you are offline. The copy backlog buffer is used for partial resynchronization. 
#  Copy buffer is only available in slave Memory is allocated when connecting. There is no slave , the memory will be freed and the default size is 1m . Format as follows: 
# repl-backlog-size 1mb
# 11  Copy the backlog buffer to release the time slice 
#  The replication backlog buffer is freed when the master node no longer has a newly connected slave node. In order to avoid frequent release and application of replication backlog buffer due to coming online after frequent disconnection from node, Redis Provide a copy backlog buffer release time slice ( repl-backlog-ttl ) parameter to ensure that the buffer will not be released by the master node within the specified time after it detects that the slave node is disconnected. 
#  A value of zero indicates that the replication backlog buffer will not be freed. 
#  In seconds, the configuration is as follows: 
# repl-backlog-ttl 3600
# 12  Slave node priority 
#  Use integers to represent slave node priority. 
#  When the master node fails to work properly, Sentinel This priority is used to select a new master node from the node. 
#  The smaller the integer value corresponding to the priority, the more likely it is to be selected as the master node. But when the priority value is zero, it means that the slave node does not have the identity of being the master node. 
# The default priority is 100 . The configuration is as follows: 
slave-priority 100
# 13  Slave node connection number and slave node delay setting 
#  When the number of connected slave nodes on the primary node is less than N And the delay of these slave nodes is greater than M Seconds, the master node will stop receiving write requests. 
#  The slave node is at" online "State, if and only if the delay (by calculating the distance over 1 Of a secondary receiving slave node ping The time interval obtained for the message) is less than the specified threshold. 
#  This option configuration is not intended to guarantee N Instead, it is intended to limit write loss when not enough slave nodes are available. 
#  At least if necessary 3 Three slave nodes are in 10s If it is available, set: 
# min-slaves-to-write 3
# min-slaves-max-lag 10
# 1 Once you have one of these two 1 Zero, the function fails. 
#  The default min-slaves-to-write  Parameters are set to 0 , the feature is not enabled by default. 
# 14  Specified by the slave node IP and port
# Redis The master node can display connected slave nodes in a number of ways IP and port . Such as Sentinel  You can use" INFO replication "Command to find slave node instances; Master You can use" ROLE The command displays the slave node IP and port Information, etc. 
# slave To obtain IP and port By: 
# IP : Automatic detection acquisition. When the slave node connects to the master node, it is obtained by checking the corresponding socket address. 
# Port : the slave node needs to be used when copying and when the master node shakes hands port . In general, port That is, when connected port . 
#  However, when port forwarding occurs ( port forwarding Forward, 1 Three network ports from 1 Three network nodes to another 1 The behavior or use of a network node NAT ( Network Address Translation The technology is that the slave nodes need to be assigned differently IP and port Can only be accessed after. 
#  The next two configurations are used to set the slave node's IP and port Is used to tell the master node what is specified IP and port So that the INFO and ROLE  To continue to return results. 
#  When you need to rewrite IP and port , you do not need to configure this option. 
#  The configuration format is as follows: 
# slave-announce-ip 5.5.5.5
# slave-announce-port 1234

##############
#  Security configuration: 
# Redis provide 1 Some security policies, try to ensure access security. 
################################## SECURITY ###################################
#
# 1  The authentication code 
# Server Before the client command can be processed, the client needs to provide an authentication password. This is useful in untrusted network environments. 
#  To reduce background execution complexity, this option 1 General will be commented out. Because most users don't need authorization. (if the user USES his own server) 
# Warning:  Due to the Redis The execution is efficient, so external users can attempt authentication every second 15w Times. In other words, the user needs to use it to avoid password breaches 1 A very complicated password. 
#  Set the authentication password in the following format: 
# requirepass foobared
# 2  Command rename 
#  Rename command. 
#  in 1 In the Shared environment, it is necessary to re-command the dangerous command, so as to avoid the abuse and uselessness of the dangerous command. 
#  If you will make CONFIG Command reset 1 A hard to guess command, so that the command is hard to use by ordinary users, but can still be used by internal tools. 
#  Such as: 
# rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52
#  Of course, sometimes you need to disable it 1 Some command. This can be achieved by leaving the command empty: 
# rename-command CONFIG ""
#  Pay attention to, 1 Make sure to avoid renaming those writes AOF File or transfer data to slaves Otherwise, it will lead to all kinds of unexpected errors. 

###########
#  Restricted configuration: 
#  right 1 Some parameter ranges are limited. 
################################### LIMITS ####################################
#
# 1  Maximum client connection number 
# Set up a 1 Number of concurrent connections to the client at time. By default, the upper limit is 1w . But if Redis The server does not have a configured process file limit , the maximum number of clients allowed to connect will be set to the minimum of the current file limit 32 ( Redis Will retain 1 Partial files to internal users). 
# 1 Once the upper limit of the connection is obtained, Redis Will close all new connections and send an error" max number of clients reached "Prompt. The connection upper limit configuration format is as follows: 
# maxclients 10000
# 2  Maximum available memory 
#  Do not use memory when you exceed the specified limit. 
#  When the memory limit is reached, Redis Will be removed based on the selected expired key policy 1 some key . 
#  If it cannot be removed according to the expired key policy 1 Some key or expired key policy is set to" noeviction "(do not enable expired key policy), then Redis To such as SET , LPUSH Such memory - using commands return errors to such as GET The wait - read command returns the result normally. 
#  This configuration is usually in the Redis As a LRU  Cache or pair to set a hard memory limit Redis Very applicable. 
# WARNING: slaves Is not in the output buffer of the primary node maxmemory In the calculation, so set maxmemory Don't be too big. If it is too large, the remaining memory on the host may be too small to reserve enough memory for creation slaves Output buffer. 
#  In short, if the current node has a connected slave node, establish the Settings 1 A smaller maxmemory Upper bound, so that the system can have excess RAM Use and create slave node output cache. When the expired key policy is set to 'noeviction' , there is no need to do so.) 
#  The format is as follows: 
# maxmemory <bytes>
# 3  Memory elimination strategy 
# MAXMEMORY POLICY:  When reach maxmemory Can be used by the memory elimination strategy. 
# Redis provide 5 Memory elimination strategy: 
# volatile-lru : LRU Algorithm removes expiration keys . 
# allkeys-lru : LRU Algorithm to remove keys . 
# volatile-random : Randomly removes expiration dates keys . 
# allkeys-random : Random removal keys . 
# volatile-ttl : According to the most recent expiration time to delete (assisted TTL ), to remove the expired ones keys . 
# noeviction : Do not remove any key , just return 1 A writing error. 
# Note:  Regardless of the above elimination strategy, when no appropriate key is removed, Redis A write error is still returned. 
#  The written commands are:  set setnx setex append
# incr decr rpush lpush rpushx lpushx linsert lset rpoplpush sadd
# sinter sinterstore sunion sunionstore sdiff sdiffstore zadd zincrby
# zunionstore zinterstore hset hsetnx hmset hincrby incrby decrby
# getset mset msetnx exec sort
#  The default memory elimination strategy is 'noeviction' . 
# 4  Maximum number of sample detections 
# LRU Algorithm and minimum TTL Algorithms are not precise algorithms, so they can be judged on the speed or accuracy of execution. 
#  By default, Redis from 5 Choose between the keys 1 Three of the most recent and most unused keys are eliminated. You can configure this selection to set the detection cardinality. 
# 1 In general, 5 A good enough result can be obtained from a sample. 10 The results of the sample are much closer LRU The algorithm, but it's going to consume more CPU . 3 High execution speed can be obtained but not accurate enough. 
#  The configuration format is as follows: 
# maxmemory-samples 5

##############
# AOF Configuration: 
# AOF Corresponding to the persistence mode 1 Some configuration. 
############################## APPEND ONLY MODE ###############################
#
# 1  Whether open AOF Persistence function 
#  By default, Redis The dataset is snapshot to disk asynchronously. Although this pattern is friendly to many applications, however Redis When a process crashes or loses power, write information is lost for a few minutes (depending on the granularity of the snapshot execution). 
# AOF As a 1 An alternative persistence strategy can provide better durability. If the default is used fsync Strategy, Redis Just get lost 1s The write message when an emergency (server power down, server process crash but OS Operating normally) 
# AOF Persistence and RDB Persistence can be enabled simultaneously. If you start Redis Time already exists AOF The file will be loaded directly AOF File (in consideration of AOF Compared to the file RDB Files have better durability). 
#  about AOF For more information see:  http://redis.io/topics/persistence
#  The default AOF Close. The configuration is as follows: 
appendonly no
# 2  The specified AOF The file name 
#  The specified AOF File name, default is appendonly.aof . The configuration is as follows: 
appendfilename "appendonly.aof"
# 3 fsync() Frequency of system function calls 
#  call fsync() System functions are used to tell OS Writes data to disk instead of waiting for data in the output buffer. There are some OS Will directly flush Data to disk, some other OS Will only try to flush . 
# Redis support 3 Kind of fsync() Invocation mode: 
# no : does not perform fsync, by OS decision flush Frequency of data. Efficient. Linux The next default is each 30s perform 1 time flush . 
# always : each write 1 time AOF Just call 1 time fsync . Slow, safest. 
# everysec : Calls per second 1 time fsync . Moderate. 
#  The default fsync The call frequency is" everysec ", which strikes a trade-off between speed of execution and data security. 
#  When one can tolerate 1 When you have a degree of data loss and expect higher performance, you can use the no The policy (determined by the operating system) flush "). Conversely, if data loss is not tolerated, use" always "For better security, although execution is slower. 
#  More and more AOF For information, please refer to: 
# http://antirez.com/post/redis-persistence-demystified.html
#  In doubt fsync It is recommended to use" everysec "Strategy. 
#  In the open AOF This configuration will not take effect until the capability is persisted. 
#  The configuration Settings are as follows: 
# appendfsync always
appendfsync everysec
# appendfsync no
# 4 AOF rewrite with fsync
#  when AOF perform fsync The strategy is always and everysec If there is 1 10 background processes ( BGSAVE A process or AOF rewrite Process) is executing a large number of I/O Operate to disk in 1 some Linux In the system, execute fsync It causes a long block. There is currently no good solution to this situation, even if executed in different threads fsync It also causes the call to be synchronized write(2) Blocking. 
#  To alleviate the above problems, you can configure the following options to avoid calls on the main thread fsync() When performing BGSAVE or  BGREWRITEAOF The obstruction caused by. 
#  That is, by default, when the child process executes BGSAVE or BGREWRITEAOF When, Redis The durability will be changed by default to "appendfsync none" . In a real world context, that would mean being lost in the worst case scenario 30s Data, even if configured fsync Call frequency is always or everysec . (By default, Linux every 30s Automatically call 1 time fsync Cache data flush To disk) 
#  Set this configuration to" yes ". Otherwise, use the default configuration (" no "), which is the safest option from a durability perspective. 
no-appendfsync-on-rewrite no
#  The above configuration is equivalent to appendfsync-on-rewrite (in the rewrite Still perform fsync ) 
# 4 AOF rewrite trigger 
#  Set up the AOF  Override the trigger condition. 
#  when AOF The log can be called when it grows in a specified proportion BGREWRITEAOF Perform automatic AOF rewrite . 
#  Working principle: Redis By contrast 1 Time to perform rewrite when AOF File size vs. current AOF File size (will not be on on restart 1 Time to perform rewrite The record will then be used startup At the time of the AOF File size) to decide whether to proceed rewrite . 
#  If the current AOF For on 1 Time to perform rewrite the AOF A file whose growth rate is greater than the specified rate will trigger 1 time rewrite . 
#  Of course, you also need to specify 1 a AOF The smallest unit of overwriting. Doing so will avoid growth rates that have reached the required but corresponding levels AOF Still a small case (in which case it is not necessary to proceed rewrite ). 
#  If you want to turn off auto AOF rewrite Functions can be carried out rewrite Required growth rate setting 0 . 
#  By default, when AOF Is greater than 64MB And compared to the above 1 time rewrite . AOF Triggers when the expansion is doubled 1 time rewrite The execution. The default configuration is as follows: 
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
# 5 AOF  Incomplete file 
#  In the AOF File loaded into memory (restart Redis ), it may come up AOF The condition of truncation. 
#  Such as when Redis The running system suddenly crashes (when ext4 The file system was not configured for sequential storage at installation AOF Truncation condition. 
#  if Redis If a program crashes or an exception occurs, but the operating system still works, it does not AOF The condition of truncation. 
#  appear AOF When it's truncated, Redis Either exit directly and return an error, or the load is truncated AOF As much data as possible (the current default). 
#  Can be achieved by aof-load-truncated Options to configure 
#  when aof-load-truncated Set to" yes ", Redis Will still be loaded 1 Student: A truncated one AOF File while reporting to the user AOF The file is truncated. If you set it to" no ", Redis Returns an error and rejects startup, when the user needs to use it "redis-check-aof" Program to repair AOF This is the only way to restart Server . 
#  Notice that if AOF File under execution 1 Half the time you have a problem, even if you set it up aof-load-truncated for   " yes ", Redis It also exits directly and returns an error. 
#  This configuration is only available in Redis Try from AOF The file reads more data but finds that not enough word counts exist to make sense. 
#  This feature is enabled by default. 
aof-load-truncated yes

#############
# LUA Script processing: 
################################ LUA SCRIPTING ###############################
#
# 1 Lua Script execution timeout threshold 
#  Set up the Lua The upper limit for script execution timeouts in milliseconds, milliseconds . 
#  when Lua Script execution timeout, Redis The result after execution of the script (after timeout) is logged and an error is returned to the query. 
#  when 1 When the maximum execution time of a long-duration script is exceeded, only SCRIPT KILL and  SHUTDOWN NOSAVE  The command is available. Stop the control of this type of script 1 The method is called 1 Non - write command. The first 2 Kind of method is shut down  this server , if it has already been sent 1 A write command but the user does not want to wait for the script to terminate naturally. 
#  If you do not want to limit the execution time of the script and do not need to return warning , you can set this parameter to 0 Or negative. 
#  The default configuration is as follows: 
lua-time-limit 5000

###############
#Redis  Cluster configuration: 
################################ REDIS CLUSTER ###############################
#
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# WARNING EXPERIMENTAL:  In spite of the current Redis Cluster The code is stable, but in order to mark this code level as" mature ", 
#  Still need to 1 Batch users apply this functionality to the production environment. namely Redis Cluster The function still needs the test of production practice. 
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# 1  Start the Redis clustering 
#  Under normal circumstances, the boot Redis The instance is non-clustered. Nodes become cluster nodes only when they are configured in cluster mode. To start in cluster mode, uncomment the following configuration: 
# cluster-enabled yes
# 2  Cluster configuration file command 
#  Each cluster node has one 1 A cluster configuration file. This file is not used for user editing, but for persisting cluster information. 
#  This file is created and updated by the cluster node. each Redis  Cluster nodes all need to have unique 1 Cluster configuration file. So in the same 1 Multiple system creations Redis The instance needs to ensure that there is no case where the configuration file name is the same (which can result in the cluster configuration file being overloaded). 
#  The cluster configuration file command format is as follows: 
# cluster-config-file nodes-6379.conf
# 3  Cluster node timeout threshold 
#  The cluster node timeout threshold is used as the maximum timeout in milliseconds for nodes that are unreachable and marked as invalid ( millisecond ) 
#  Most other internal time will be its base reference number. 
#  The setting mode is as follows: 
# cluster-node-timeout 15000
# 4  Criteria for initiating failover from a node ( slave-validity-factor ) 
#  When the master node fails, Redis Avoid failover from a slave node whose stored data is too old. 
#  There is no simple way to directly and accurately determine the data age ", can be achieved through the following two aspects of detection: 
# 1)  If there are multiple slave nodes that can initiate failover, have them exchange information to select the slave node of the data state node's master node. The slave node can pass through offset Rank and use that rank to delay the time to initiate failover. 
# 2)  Each independent slave node computes the nearest 1 The time of secondary interaction with the primary node. The interaction here can be the closest 1 time PING Recently, 1 The time of receiving the command coming to the master node and disconnecting from the master node (when the copy link has been made) down Off). If the latest 1 The secondary interaction with the master node is old enough that the slave node will give up failover. 
#  in 2) Can be set by the user. In particular, when the slave node is nearest 1 The secondary interaction with the primary node is much greater than that (node-timeout * slave-validity-factor) + repl-ping-slave-period  , the slave node will not fail over. 
#  For example, assume that node-timeout for 30 Second, slave-validity-factor Parameters for 10 . repl-ping-slave-period  for 10 Seconds, when the slave node is closest 1 The secondary interaction time with the primary node is greater than 310 Seconds ( 30*10+10 ), the slave node cannot fail over. 
# 1 Oversized slave node effective factor ( slave-validity-factor ) allows slave nodes that store older data to fail over, while 1 Too small a slave node valid factor will prevent the cluster from choosing a slave node as the new master node. 
#  Therefore, it is important to set the effective factors of slave nodes properly. 
#  For maximum availability, you can change the node availability factor ( slave-validity-factor For) an assignment 0 . In other words, the nearest distance is ignored from the node 1 The time period for secondary interaction with the master node is a direct point attempt to initiate failover. Under this strategy, however, these slave nodes will still depend on offset To delay the initiation of failover) 
#  Slave node effective factor ( slave-validity-factor ) a value of 0 Is the only 1 A value that guarantees that the cluster will continue to work even after the network partition disappears. 
#  The format is as follows: 
# cluster-slave-validity-factor 10
# 5  Migration shield factor from node ( cluster-migration-barrier ) 
# Redis Clustering supports migrating from a node to an isolated master node ( orphaned masters ), there is no master node that can work on the slave node. This feature reduces the number of cases in which the cluster has isolated master node failures but no working slave nodes for failover. 
#  A slave node can be migrated to an isolated master node if and only if the remaining working slave nodes of the original master node are greater than or equal to the specified number of working slave nodes. This number is called the migration shield factor from the node ( migration barrier ). When the migration shield factor is set to 1 Is allowed to migrate from a node to an isolated master node if and only if the master node has at least two working slave nodes ( orphaned masters ). This factor is often used to indicate the number of slave nodes that the consumer needs to configure for the primary node in the cluster. 
#  The default migration mask factor is 1 A slave node can perform a migration currently only if its master node remains at least after the node has been migrated 1 Four slave nodes). If you want to turn this feature off, simply set this parameter to 1 The maximum value is enough. 
#  Allows the migration mask factor to be set to zero. This behavior is only useful for debugging and is highly risky in a production environment. 
#  The configuration format is as follows: 
# cluster-migration-barrier 1
# 6  Whether the cluster support section is available 
#  By default, Redis The cluster will stop receiving client requests (stop service) when the cluster detects the presence of a hash slot with no responsible node. That is, if the cluster part down (if any 1 Some hash slots have no corresponding nodes), and the entire cluster will eventually become unavailable. Cluster information dissemination follows final 1 Consistency) 
#  When all slots have responsible nodes again, the cluster is automatically available again. 
#  But sometimes it is desirable that even if only a portion of the slots in the cluster have corresponding nodes, the cluster can continue to accept client requests and process corresponding key Spaces. To this end, will ecluster-require-full-coverage  Set to" no ". 
#  The configuration format is as follows: 
# cluster-require-full-coverage yes
#  Instructions for creating a cluster are provided in the http://redis.io  The website is available. 
#

############
#  Slow log configuration: 
################################## SLOW LOG ###################################
#
# 1  Command execution timeout limit 
# Redis Slow logging systems are used to record queries that take longer to execute. Here's the execution time (" execution time ") not included IO The operation time, such as receiving the request from the client, returning the result of the request, etc., but the actual execution time of the command (at this time the thread is blocked and can only execute the command, but cannot process other requests at the same time) 
#  You can configure slow logging with two parameters: 1 Parameter notification Redis Execution time timeout threshold (in microseconds, microseconds ) so that 1 Once a certain execution time exceeds the specified limit, it will be recorded in the slow log. On the other 1 The length of the slow log. Slow logging USES a ring structure to store timeout commands. (When the slow log is full and new commands are added, the oldest commands will be kicked out) 
#  The units are microseconds ( microsecond . 106 Ms is equal to the 1 Seconds). When the value is negative, it is disabled slow log Function. When the value is zero, it is mandatory slow log Record every 1 Command. 
#  Default slow logging is on, slowlog-log-slower-than The time limit is 104 Microseconds. 
slowlog-log-slower-than 10000
# 2  Slow log length 
# slow log It is stored in memory and can be set as long as there is enough memory. You can use SLOWLOG RESET Command to reset the slow log length. 
#  Default Settings are as follows: 
slowlog-max-len 128

##############
#  Delay monitoring configuration: 
################################ LATENCY MONITOR ###############################
#
# 1  Set an upper limit for operation delay determination 
# Redis  Delay-related data is collected by the system through the detection of operations during execution. 
#  Through the use of LATENCY Command, Redis Users can get delay-related graphics, reports, and other information. 
#  The delay system will only record what is set to be greater than or equal to latency-monitor-threshold The operation of a value. When the value is zero, 
#  Indicates that it is closed latency monitor . 
#
#  By default, latency monitor The feature is turned off because it is not needed in most scenarios. 
# latency monitor Can be found in Redis Run time pass "CONFIG SET latency-monitor-threshold
# <milliseconds>" Start. 
# latency monitor The format is as follows: 
latency-monitor-threshold 0

##############
#  Event notification configuration: 
############################# EVENT NOTIFICATION ##############################
#
# 1  Set event notifications 
# Redis  Those who have can be notified Pub/Sub Events that occur in the client key space. 
#  The document for this function is http://redis.io/topics/notifications
#  For example, if keyspace notification is enabled and 1 Five client pairs 0 "On database No. foo " key perform DEL Operation, so Redis Will use the Pub/Sub Send two messages: 
# PUBLISH __keyspace@0__:foo del
# PUBLISH __keyevent@0__:del foo
# Redis Notifying events are categorized by each 1 Classes use only 1 Of the following characters: 
# K  Key space ( Key ), prefixed by: __keyspace@<db>__
# E  Key events ( Event ), prefixed by: __keyevent@<db>__
#  For all command types and non-key events, lowercase letters are used and there is no prefix. 
# g 1 A command, Generic commands ), such as DEL, EXPIRE, RENAME Etc. 
# $  String ( String ) command 
# l  List ( list ) command 
# s  Set ( set ) command 
# h  Hash ( hash ) command 
# z  Ordered set ( sorted set ) command 
# x  Expired events (events generated by expired keys) 
# e  Eviction (for maxmemory And the eviction) 
# A g$lshzxe Other names for such types ( Alias ), so 1 Just come and use it "AKE" Represents all event types 
# notify-keyspace-events  You can specify a string or an empty string consisting of more than one character. An empty string represents the shutdown notification function. 
#  case 1 : In order to open List Events and Genetic Events (in terms of event name classification) can be set as follows: 
# notify-keyspace-events Elg
#  case 2 : To get information about the expired key and send it to the subscribed channel, that is __keyevent@0__:expired use Information can be set as follows: 
# notify-keyspace-events Ex
#  By default, the event notification feature is turned off because most users do not need this feature and it incurs additional performance overhead. 
#  Note that if no key space is specified ( K ) Notifications or key events ( E ), so that no event notification will be transmitted. 
#  Default Settings are as follows: 
notify-keyspace-events ""

############
#  Advanced configuration: 
############################### ADVANCED CONFIG ###############################
#
# 1 Hash type 
# Hash The underlying implementation of data types has compressed linked lists ( ziplist ) and a hash table ( hash ). If and only if the amount of data stored is less than hash-max-ziplist-entries And the capacity occupied by the node is less than hash-max-ziplist-value When using small amounts of data to store efficiently ziplist Structural storage. Otherwise, use a hash structure for storage. 
#  Thresholds can be set by following instructions: 
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
# 2 List type 
# List Types can also save space in special ways. 
#  Each of the internal list Nodes that allow storage entries The quantity can be specified as the maximum number of modified elements or the maximum number of elements. 
#  Such as specified -5 to -1 , which means: 
# -5: max size: 64 Kb < �   For normal workloads, it is not recommended 
# -4: max size: 32 Kb < �   Not recommended 
# -3: max size: 16 Kb < �   Sometimes it is not recommended 
# -2: max size: 8 Kb < �  good
# -1: max size: 4 Kb < �  good
#  Integers represent each list Nodes store exactly the specified number of elements
#  The most efficient parameter setting is -2 (8 Kb size)  or  -1 (4 Kb size)
#  However, if the requirements are specific, the parameters should be adjusted as needed: 
list-max-ziplist-size -2

# 3 List Type compression depth Settings 
# List You can compress it 
#  Compression depth is defined quicklist , ziplist Etc. list Node range at compression time. In order to go fast push/pop Operation, not right list the head and tail To compress, only the intermediate nodes are compressed. Parameters are set as follows: 
# 0:  Shut down list compression 
# 1:  Depth of 1 Means only if list add 1 Nodes (whether from head or tail The compression starts after the node is added. 
#  So for [head]->node->node-> ... ->node->[tail]
#  Compression is performed only when bold parts are added. 
# 2:  Depth of 2
#  For linked lists: [head]->[next]->node->node-> ... ->node->[prev]->[tail]
#  Not compressed head  or  head->next  or  tail->prev  or  tail And just compress the rest. 
# 3:  Depth of 3
# [head]->[next]->[next]->node->node-> ... ->node->[prev]->[prev]->[tail]
#  The format is as follows: 
list-compress-depth 0
# 4  A collection of (intset) type 
# Set The underlying implementation of the data type is by default intSet Or it could be hash . 
# Set use hash Encoding format if and only if the string consists of set It becomes base zero 10 Is an integer whose values range from 64 Bit integer. 
#  The following configuration Settings are used to specify set Thresholds that can be used in a special encoding format: 
set-max-intset-entries 512
# 5 Sorted Set type 
# Sorted Set Use the default ziplist Implement, also can pass skiplist Code implementation to save space. 
#  If and only if Sorted Set Is greater than zset-max-ziplist-value And the number of elements is greater than zset-max-ziplist-entries ", before use skiplist implementation Sorted Set . 
#  Parameters are set as follows: 
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
# 6 HyperLogLog Sparse representation 
# HyperLogLog Sparse represents a threshold. 16 bit header Some are also limit In the. When using sparse representation HyperLogLog A stored byte that exceeds a specified threshold will be converted to a dense representation. 
#  Greater than is not recommended 16000 The value of the. When less than 16000 Can obtain higher storage efficiency. 
#  The suggested value is 3000 , the value can be in less PFADD When performing sparse coding, the time complexity is O(N) ) the operation is executed with extremely high space usage benefits. when CPU When the problem is not considered, the value can be raised to 10000 But the value should not exceed  15000 . 
#  The setting mode is as follows: 
hll-sparse-max-bytes 3000
# 7 rehash To deal with 
#  Activation of rehash Take up every 100 ms 1 millisecond the CPU Time to Redis hash table Store the key-value pairs of the database hash table ) perform rehash . in Redis In the hash table Using an inert rehash In: rehashing When, hash table The more operations performed in, rehash The more steps you perform. So when server In my free time, rehash It's going to be easy, hash table There will also be more memory available. 
#  To the extent that conditions permit hash table for rehash To save memory space. By default, rehash Each function will be 100 In milliseconds 1  Milliseconds are called 1 Times. 
#  If not sure: 
#  use "activerehashing no"  If the current application environment is latency conscious, Redis Only allow 2 Millisecond delay response. 
# use "activerehashing yes"  If the current application environment is not too lazy and wants to block as much memory as possible. 
#  This function is enabled by default: 
activerehashing yes
# 8  Client output buffer 
#  The client output buffer can be used to force the disconnect of clients who cannot read server data quickly. (such as in Pub/Sub In mode, the client cannot process quickly publisher The message sent) 
#  The client type can be subdivided into 3 Class: 
# normal ->  Normal clients (including MONITOR The client) 
# slave ->  Slave node client 
# pubsub -> Subscribe to at least 1 a pubsub Channel or mode client 
# client-output-buffer-limit  The general format for setting is as follows: 
# client-output-buffer-limit <class> <hard limit> <soft limit> <soft seconds>
# 1 denier hard limit When reached, the client will disconnect directly. if soft limit  The client connection will continue soft seconds  Then disconnect. 
#  For example, when the hard limit  is  32 MB ( megabytes ), soft limit  in 10  Lasts longer than 2 seconds 16MB , if the client output buffer ( clients output buffer ) more than 32 MB  Or the client output buffer ( clients output buffer ) more than 16MB And in the following 10 Seconds are higher than 16MB The client connection will be disconnected immediately. 
#  By default, no pairs are required normal The level of clients Constrain because these clients won't accept data if they haven't asked. So, you just have to constrain the asynchronous client because the asynchronous client can have requests that are faster than the speed of the request read The velocity situation. 
#  Because the subscriber and slave nodes use push to receive data, you need to match pubsub  The client and slave The client sets the default client output buffer constraint. 
#  will hard limit  or  soft limit  Zero means to turn off the corresponding function. 
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
# 9 Redis Heart rate 
# Redis call 1 Internal functions to perform background tasks, such as in timeout Closes the client connection, clears expired keys that have never been requested, and so on. 
#  Not all of them, though tasks Both are executed at the same frequency, but Redis The detection is based on the specified frequency value tasks The execution. 
#  The default value is 10 Per second 10 Times. in Redis When the value is idle, it consumes more CPU . However, increasing this value also causes Redis Handles timeouts more accurately and detects more expired keys. 
#  This value sets the range to 1 to 500 . Setting it to greater than is not recommended 100 . Most users recommend using the default value ( 10 ), and increase the value appropriately based on the low latency requirements of the application environment (the peak value is recommended not to be greater than 100 ). 
#  Format as follows: 
hz 10
# 10 AOF Overrides synchronize with disk 
#  The child process is performing overrides AOF File, if enabled, then every data growth 32MB it 1 Secondary file disk synchronization. This feature is a great help in speeding up file synchronization to disk and avoiding large latency spikes. 
#  This feature starts by default. Format as follows: 
aof-rewrite-incremental-fsync yes

Better a bad memory than a bad pen. We must save it for a rainy day


Related articles: