Transferred from: http://www.jb51.net/article/60627.htm
Reids Configuration Parameters Detailed
#daemonize No by default, Redis is not running in the background, and if it needs to be run in the background, change the value of the item to Yes
Daemonize Yes
# when Redis runs in the background, Redis defaults to placing the PID file in/var/run/redis.pid, which you can configure to a different address.
# when running multiple Redis services, you need to specify a different PID file and port
Pidfile/var/run/redis_6379.pid
# Specify the port on which Redis runs, default is 6379
Port 6379
# in a high-concurrency environment, to avoid slow client connection problems, you need to set up a high-speed background log
Tcp-backlog 511
# Specifies that Redis receives only requests from that IP address, and if not set, all requests are processed
# bind 192.168.1.100 10.0.0.1
# bind 127.0.0.1
# Sets the time-out period in seconds for client connections. When the client has not issued any instructions during this time, the connection is closed
# 0 is to turn off this setting
Timeout 0
# TCP KeepAlive
# on Linux, specify the time that the value (in seconds) is used to send the ACKs. Note that it takes twice as long to close the connection. The default is 0.
Tcp-keepalive 0
# Specify logging level, production environment recommended notice
# Redis supports a total of four levels: Debug, verbose, notice, warning, default = verbose
# Debug logs A lot of information for development and testing
# Varbose useful information, not as much as debug will record
# Notice common verbose, often used in production environments
# warning only very important or serious information will be recorded in the log
LogLevel Notice
# Configure log file address
# The default value is stdout, standard output, if the background mode is output to/dev/null.
Logfile/var/log/redis/redis.log
# Number of available databases
# The default value is 16, the default database is 0, and the database range is between 0-(database-1)
Databases 16
################################ Snapshot #################################
# Save data to disk in the following format:
# Save
# indicates how many times the update operation will synchronize the data to the data file RDB.
# equivalent to conditional trigger fetch snapshot, this can be combined with multiple conditions
# For example settings in the default profile, three conditions are set
# Save 900 1 900 seconds at least 1 keys have been changed
# Save 300 10 300 seconds at least 300 keys have been changed
# Save 60 10000 60 seconds at least 10,000 keys have been changed
# Save 900 1
# Save 300 10
# Save 60 10000
# Background Store error stopped writing.
Stop-writes-on-bgsave-error Yes
# Whether to compress data when storing to a local database (persisted to an RDB file), by default Yes
Rdbcompression Yes
# RDB file is direct idol Chcksum
Rdbchecksum Yes
# Local Persistent database file name, default value is Dump.rdb
Dbfilename Dump.rdb
# working Directory
# The path to the file placement of the database mirroring backup.
# The path here is configured separately from the file name because Redis writes the status of the current database to a temporary file when it is being backed up,
# Replace the temporary file with the file specified above, and the temporary file and the backup file configured above will be placed in the specified path.
# AOF files will also be stored under this directory
# Note that a directory, not a file, must be developed here
dir/var/lib/redis-server/
################################# Copy #################################
# Master-slave replication. Set the database from the database for the other database.
# Set the IP address and port of the master service when this machine is a Slav service, and it will automatically synchronize data from master when Redis boots
# slaveof
# When the master service is password protected (password set with Requirepass)
# Slave The password of the service connection master
# Masterauth
# When a connection is lost from the library to the host or the replication is in progress, there are two modes of operation from the hangar:
# 1) If Slave-serve-stale-data is set to Yes (the default setting), the library will continue to respond to requests from the client
# 2) If slave-serve-stale-data refers to no, any request outside the INFO and SLAVOF commands will return a
# error "SYNC with Master in progress"
Slave-serve-stale-data Yes
# Configures whether the slave instance accepts write. Writing slave is useful for storing ephemeral data (which can be easily deleted after synchronizing with master data), but without configuration, client write may send a problem.
# after Redis2.6, the default slave is Read-only
Slaveread-only Yes
# The library will send PINGs to the main library at a time interval. This time interval can be set by Repl-ping-slave-period, which is 10 seconds by default
# Repl-ping-slave-period 10
# Repl-timeout Set the main library bulk data transfer time or ping reply interval, the default value is 60 seconds
# Make sure Repl-timeout is greater than repl-ping-slave-period
# Repl-timeout 60
# disable tcp_nodelay after slave socket SYNC
# if "Yes" is selected, Redis will send data to slave using a smaller number of TCP packets and less bandwidth, but this may cause the data to be sent to the slave end with a delay of 40 milliseconds if it is the default configuration of the Linux kernel.
# if "No" is selected, the delay in sending data to the slave side will decrease, but more bandwidth will be used for replication.
Repl-disable-tcp-nodelay No
# Set the background log size for replication.
# The larger the background log that is copied, the longer it takes for slave to disconnect and later possibly perform partial replication.
# The background log is allocated only once when there is at least one slave connection.
# repl-backlog-size 1MB
# after Master is no longer connected to slave, the background log will be released. The following configuration defines the time (in seconds) to be released after disconnecting from the last slave.
# 0 means never release the background log
# Repl-backlog-ttl 3600
# if master no longer works, then in more than one slave, one slave with the lowest priority value is promoted to master, and a priority value of 0 indicates that it cannot be promoted to master.
Slave-priority 100
# If there are fewer than N slave connections, and the delay time is <=m seconds, Master can be configured to stop accepting write operations.
# For example, you need at least 3 slave connections and delay the configuration of <=10 seconds:
# Min-slaves-to-write 3
# Min-slaves-max-lag 10
# Set 0 To disable
# default min-slaves-to-write is 0 (disabled), Min-slaves-max-lag is 10
################################## Safety ###################################
# Set the password to be used before any other specified client connection is made.
# Warning: Because the Redis speed is quite fast, under a better server, an external user can make a 150K password attempt in a second, which means you need to specify a very strong password to prevent brute force.
# Requirepass Foobared
# command renamed.
# in a shared environment, you can rename a relatively dangerous command. For example, the name of CONFIG is a character that is not easy to guess.
For example
# Rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52
# If you want to delete a command, simply rename it to a null character "", as follows:
# Rename-command CONFIG ""
################################### constraint ###################################
#设置同一时间最大客户端连接数, the default is unlimited,
#Redis the number of client connections that can be opened at the same time is the maximum number of file descriptors that the Redis process can open.
#如果设置 maxclients 0, indicating no restrictions.
#当客户端连接数到达限制时, Redis closes the new connection and returns the max number of clients reached error message to the client
# maxclients 10000
# Specify Redis maximum memory limit, Redis will load data into memory at boot time, after reaching maximum memory, Redis tries to purge expired keys according to purge policy
# if Redis does not provide enough space after the policy is cleared, or if the policy is set to "noeviction", commands that use more space will get an error, such as set, Lpush, and so on. However, the read operation is still possible
Note: Redis's new VM mechanism will store the Key in memory, and Value will be stored in the swap area.
# This option is useful for LRU policies.
# MaxMemory's settings are more appropriate for using Redis as a memcached-like cache than for a real DB.
# when using Redis as a real database, memory usage will be a big expense
# MaxMemory
# What data does Redis choose to delete when the memory reaches its maximum value? There are five different ways to choose
# VOLATILE-LRU using the LRU algorithm to remove key (LRU: Most recently used Least recentlyused) with set expiration time
# ALLKEYS-LRU using the LRU algorithm to remove any key
# volatile-random, removing the random key set over expiration time
# allkeys->random, remove a randomkey, any key
# Volatile-ttl Remove Expiring key (minor TTL)
# noeviction not remove any can, just return a write error
Note: For the above policy, if no appropriate key can be removed, Redis will return an error when writing
# default is: VOLATILE-LRU
# Maxmemory-policy VOLATILE-LRU
# LRU and minimal TTL algorithms are not accurate algorithms, but relatively accurate algorithms (in order to save memory), optionally you can choose the sample size to detect.
# Redis Default Gray Select 3 samples for detection, you can set through Maxmemory-samples
# Maxmemory-samples 3
############################## aof###############################
# By default, Redis backs up database mirroring to disk asynchronously in the background, but the backup is very time-consuming and cannot be backed up very often, resulting in a wide range of data loss if such conditions as power cuts, unplug, etc. occur.
# so Redis offers another more efficient way to database backup and disaster recovery.
# when append only mode is turned on, Redis appends every write request received to the Appendonly.aof file, and when Redis restarts, the previous state is recovered from the file.
# But this will cause the appendonly.aof file to be too large, so Redis also supports the BGREWRITEAOF instructions and re-organizes the appendonly.aof.
# You can open asynchronous dumps and AOF at the same time
AppendOnly No
# AOF file name (default: "Appendonly.aof")
# Appendfilename Appendonly.aof
# Redis supports three different policies for synchronizing AOF files:
# No: Do not synchronize, the system to operate. Faster.
# always:always indicates that each write operation is synchronized. Slow, safest.
# Everysec: Indicates that the write operation is cumulative and synchronized once per second. Compromise.
# default is "Everysec", according to speed and security compromise this is the best.
# If you want Redis to run more efficiently, you can set it to "no" and let the OS decide when to execute
# or on the contrary to make the data more secure you can also set it to "always"
# use "Everysec" if you're not sure.
# Appendfsync Always
Appendfsync everysec
# Appendfsync No
# When the AOF policy is set to always or EVERYSEC, the background processing process (background save or AOF log rewrite) performs a number of I/O operations
# in some Linux configurations, too long Fsync () requests are blocked. Note that there is now no fix, even if fsync is processing on another thread
# to mitigate this problem, you can set the following parameter No-appendfsync-on-rewrite
No-appendfsync-on-rewrite No
# AOF Auto Rewrite
# Redis can call bgrewriteaof to rewrite log files when the AOF file grows to a certain size
# It works like this: Redis remembers the size of the file after the last log (if it hasn't been rewritten since the boot, the day size is determined at boot time)
# The base size is compared with the current size. If the size is now larger than the base size, the override feature will start
# at the same time you need to specify a minimum size for AOF overrides, which prevents the file from being rewritten even though it is small but grows very large AOF
# set percentage to 0 to turn off this feature
Auto-aof-rewrite-percentage 100
Auto-aof-rewrite-min-size 64MB
################################ luascripting #############################
# The maximum execution time for a Lua script is 5000 milliseconds (5 seconds), and if 0 or negative numbers indicate an infinite execution time.
Lua-time-limit 5000
############################### #LOW log################################
# Redis Slow log records commands that exceed a specific execution time. Execution time does not include I/O calculations such as connecting clients, returning results, etc., just the command execution time
# Slow log can be set by two parameters: one is to tell Redis how much time is logged for the parameters Slowlog-log-slower-than (subtle),
# The other is the length of the slow log. The oldest command is removed from the queue when a new command is recorded
# The following time is in subtle units, so 1000000 represents one second.
Note Specifying a negative number turns off slow logging, and setting to 0 forces each command to be logged
Slowlog-log-slower-than 10000
# There is no limit to the log length, just be aware that it consumes memory
# memory consumed by slow logs can be reclaimed by Slowlog RESET
# The default value of 128 is recommended, and when the slow log exceeds 128, the record that first enters the queue is kicked out
Slowlog-max-len 128
################################ Event Notification #############################
# When an event occurs, Redis can notify the Pub/sub client.
# You can select the type of event that Redis will notify in the following table. The event type is identified by a single character:
# K Keyspace event, published in [email protected]_ prefix mode
# E KeyEvent event, published in [email protected]_ prefix mode
# G General events (not specified type), like DEL, EXPIRE, RENAME, ...
# $ String Command
# s Set command
# h Hash Command
# Z ordered set command
# x Expiration events (generated each time the key expires)
# e Cleanup event (generated when key is cleared in memory)
# A G$lshzxe's nickname, so "AKE" means all the events
# notify-keyspace-events with a string parameter consisting of 0 to more than one character. An empty string means that the notification is disabled.
# Example: Enable list and common events:
# notify-keyspace-events ELG
# notifications that are used by default are disabled because the user typically does not need to change the feature, and the feature has a performance loss.
Note If you do not specify at least one of the K or E, no events will be sent.
Notify-keyspace-events ""
############################## Advanced Configuration ###############################
# When the hash contains more than the specified number of elements and the largest element does not exceed the critical,
# hash will be stored in a special coding way (greatly reduced memory usage), where you can set both thresholds
# Redis Hash corresponds to Value inside is actually a HashMap, actually there will be 2 different implementations,
# This Hash of the members relatively young Redis in order to save memory will be similar to a one-dimensional array of compact storage, without the use of real HASHMAP structure, the corresponding Valueredisobject encoding is ZIPMAP,
# when the number of members increases, it automatically turns into a real HashMap, at which time encoding is HT.
Hash-max-zipmap-entries 512
Hash-max-zipmap-value 64
# As with Hash, multiple small lists are encoded in a specific way to save space.
# The list data type node value size is less than how many bytes are in compact storage format.
List-max-ziplist-entries 512
List-max-ziplist-value 64
# Set data type internal data if all are numeric, and how many nodes are included the following are stored in a compact format.
Set-max-intset-entries 512
# As with Hashe and list, the ordered set is stored in the specified length in the specified encoding to save space
# Zsort data Type node value size is less than how many bytes are in a compact storage format.
Zset-max-ziplist-entries 128
Zset-max-ziplist-value 64
# Redis will use 1 milliseconds of CPU time every 100 milliseconds to re-hash the Redis hash table, which can reduce the use of memory
# When you have a very strict real-time requirement in your usage scenario, you cannot accept Redis's occasional 2 millisecond delay for requests, and configure this as No.
# If you don't have such strict real-time requirements, you can set it to Yes so that you can free up memory as quickly as possible
activerehashing Yes
# The client's output buffer is limited because, for some reason, the client is not fast enough to read data from the server,
# can be used to force a disconnection (a common reason is that a publish/subscribe client consumes messages at a rate that cannot catch up with the speed at which they are produced).
# can be set in three different ways for clients:
# Normal Client
# slave-Slave and MONITOR client
# PubSub has subscribed to at least one pubsub channel or pattern client
# each CLIENT-OUTPUT-BUFFER-LIMIT syntax:
# Client-output-buffer-limit
# Once the hard limit is reached, the client immediately disconnects, or reaches the soft limit and maintains the specified number of seconds (continuous).
# For example, if the hard limit is 32 gigabytes and the soft limit is 16 megabytes/10 seconds, the client will immediately disconnect
# If the output buffer size reaches 32 megabytes, the client reaches 16 megabytes and the limit is exceeded for 10 seconds, the connection will also be disconnected.
# The default normal client does not restrict, because they do not receive data after a request (in a push).
# only an async client may have a scene that requests data faster than it can read.
# set both hard and soft limits to zero to disable this feature
Client-output-buffer-limit Normal 0 0 0
Client-output-buffer-limit slave 256MB 64mb60
Client-output-buffer-limit pubsub 32MB 8mb60
# Redis calls internal functions to perform many background tasks, such as closing a client timeout connection, purging expired keys, and so on.
# Not all tasks are performed at the same frequency, but Redis performs the check task according to the specified "Hz" value.
# By default, "Hz" is set to 10.
# Increasing this value will use more CPUs when Redis is idle, but at the same time when multiple keys expire at the same time will make redis more responsive, and timeouts can be handled more precisely.
# range is between 1 and 500, but a value of more than 100 is usually not a good idea.
# Most users should use this default value of 10, and it is necessary to increase the maximum to 100 in case of very low latency.
Hz 10
# When a child node overrides the AOF file, if the following option is enabled, the file is synchronized for each 32M data generated.
Aof-rewrite-incremental-fsync Yes
Reids Configuration Parameters Detailed