Redis.conf parameter configuration file detailed

Source: Internet
Author: User
Tags failover redis version syslog password protection redis cluster

Redis is a high-performance Key-value database with a wide range of applications, similar to memcached, but more powerful!
In this paper, according to different functional modules, the configuration parameters of each function module are described in detail.

General

./redis-server/path/to/redis.confStart with the specified configuration file
include/path/to/other.confInclude other Redis profiles
daemonize YesEnable background daemon run mode
Pidfile/var/run/redis.pidProcess ID after redis boot save file
Port 6379Specify the port number to use
bind IPListens on the specified network interface
Unixsocket/tmp/redis.sockSpecifies the listening socket for the UNIX environment
Timeout NThe client disconnects after n seconds of inactivity, and parameter 0 indicates that it is not enabled
loglevel NoticeSpecifies the level at which the server information is displayed, with 4 parameters debug\verbose\notice\warning
logfile ""Specifies the log file, which defaults to using the system's standard output
syslog-enabled NoWhether logging to the System log feature is enabled, default is not enabled
syslog-ident RedisIf logging is enabled, you need to set the identity of the log record
syslog-facility local0If logging is enabled, you need to set the log facility with a value range of LOCAL0~LOCAL7 to indicate different log levels
databasesSet the number of databases, use DB0 by default when starting, use "select <dbid>"Database can be replaced
Tcp-backlog 511This parameter determines the length of the completed queue (after 3 handshake) in a TCP connection and should be less than the/proc/sys/net/core/somaxconn value of the Linux system, which defaults to 511, while the Somaxconn default value for Linux is 128. These two parameters can be improved at the same time when the concurrency is large and the client is slow to respond.
tcp-keepalive 0Specifies a time period of acks, in seconds, and a value other than 0 that indicates whether the periodic detection client is available and the default value is 60 seconds.

Snapshotting

Data Save frequency:
Save 1 is saved after 900 seconds, and at least 1 keys are changed before triggering
save after 300 seconds, at least 10 keys are changed to trigger
Save 10000 after 60 seconds, at least 10,000 keys are changed to trigger

Stop-writes-on-bgsave-error Yes the last save operation failed to stop the write operation
rdbcompression Yes to enable compression
rdbchecksum Yes enables the CRC64 checksum, which, of course, affects a part of the performance
dbfilename Dump.rdb Specifies the file name where the data is stored
dir./ Specify working directory, RDB file and aof file will be stored in this directory, the default is that the current directory

SECURITY

Requirepass foobared If a password verification is required for a slave-side connection

LIMITS

maxclients 10000   Maximum number of clients connections at the same time, more than a number of connections will return an error message  
maxmemory <bytes>   set maximum memory  
If memory usage reaches the maximum memory setting, there are 6 ways to handle it:

volatile-lru -> remove the key with an expire set using  An lru algorithmallkeys-lru -> remove any key according to the  lru algorithmvolatile-random -> remove a random key with an  expire setallkeys-random -> remove a random key, any  Keyvolatile-ttl -> remove the key with the nearest expire time   (Minor ttl) Noeviction -> don ' T expire at all, just return  an error on write operations123456123456 

The default setting is maxmemory-policy noeviction
Maxmemory-samples 5 Number of keys checked by LRU algorithm

APPEND only MODE

appendonly Yes enable AOF mode
appendfilename "Appendonly.aof" sets the file name of the AOF record

The frequency of data brush writes to disk, there are 3 options:  
always   New data is written immediately, slow but high reliability  
everysec   Write once per second, compromise method, so-called Redis can only lose 1 seconds of data is derived from here  
no   Follow the OS's own brush-write policy for the fastest  
use options to set   appendfsync everysec

No-appendfsync-on-rewrite No when the main process is writing to disk, other Fsync calls will be blocked
auto-aof-rewrite-percentage The percentage of automatic rewrite triggered by the aof file, and a value of 0 means that automatic rewrite is disabled
auto-aof-rewrite-min-size 64mb aof file triggers the smallest file size for automatic rewrite
aof-load-truncated Yes whether to load an incomplete aof file to start

LUA SCRIPTING

Lua-time-limit The maximum run time of the Lua script is set in milliseconds

EVENT NOTIFICATION

notify-keyspace-events "" event notification, default is not enabled, specific parameters to view the configuration file

REPLICATION

Redis's master-slave replication takes place asynchronously.
If the slave terminal is temporarily disconnected from the master end while synchronizing the connection, the connection is resumed allowing the slave to be partially resynchronized with the master side.
Master-slave replication is automated and does not require user intervention, and the slave will automatically attempt to re-connect the master and synchronize the data.
slaveof <master ip> <master port>Set the IP and port information on the master side
masterauth <master-password>If password protection is enabled on the master side (Requirepass), the slave side needs to configure this option
Slave-serve-stale-data YesWhen the slave end is disconnected from master during the master-slave replication process, there are 2 ways to do this: one is to continue to service even though the data may not be up to date, and the other is to return an error message to the request, and the default configuration is to continue serving
slave-read-only YesStarting with Redis version 2.6, the slave side defaults to ReadOnly

Master-Slave synchronization supports two strategies, disk and socket (socket is not perfect, still in the experimental phase).
The new slave end and the salve end of the re-connection are not allowed to continue the synchronization process, which is called "Full Synchronization".
An Rdb file is uploaded from the master to the slave end, in two cases:
1, support Disk:master end will be the Rdb file written to disk, and later transferred to the slave end;
2, no disk diskless:master side directly to the Rdb file to the slave socket, do not need to interact with disk.
The diskless disk-less approach is suitable for environments where disk reads and writes are slow but network bandwidth is high.
Repl-diskless-sync NoDiskless synchronization is not used by default
Repl-diskless-sync-delay 5A disk-less diskless method has a time delay before the data is passed so that the slave can proceed to the destination queue to be delivered, which is 5 seconds by default
Repl-ping-slave-period TenSlave sends the pings time interval setting to the server side, which defaults to 10 seconds
Repl-timeoutSetting the time-out period
Repl-disable-tcp-nodelay NoWhether to enable Tcp_nodelay, if enabled, uses a small amount of TCP packets and bandwidth to transfer data to the slave side, which of course is slower and, if not enabled, is faster, but consumes more bandwidth.
repl-backlog-size 1MBTo set the backlog size, the backlog is a buffer that holds the data to be synchronized to the slave at the slave end, so when a slave is to be re-connected, it is often not necessary to fully synchronize, and performing local synchronization is sufficient. The larger the backlog is set, the longer the slave can lose the connection.
Repl-backlog-ttl 3600If no slave is connected to master after a period of time, the memory of the backlog size will be freed. A value of 0 means that the partial memory is never freed.
slave-prioritySlave the priority setting of the end, the value is an integer, the smaller the number, the higher the priority. When Master fails, it will select the slave side for recovery by priority, and if the value is set to 0, the slave will never be selected.
Min-slaves-to-write 3
Min-slaves-max-lag TenSet when the available slave on a master side are less than N and the delay time is greater than m seconds, the write operation is not received.

REDIS CLUSTER

A normal Redis instance cannot be a node of a redis cluster unless it is started as a cluster node. &NBSP
cluster-enabled Yes   Configure Redis as a cluster node to start  
Cluster-config-file Node-6379.conf   Each cluster node has a cluster configuration file that does not need to be edited and is created and updated by the Redis node. The cluster configuration file for each Redis node cannot be the same. &NBSP
cluster-node-timeout 15000   Sets the cluster node timeout, which is considered to be a failed state, in milliseconds, if it exceeds the specified time-out and is still unreachable.

Now there is no simple way to solve the problem of how to determine the timeliness of a slave-side data, so you can perform the following two choices:  
1, if there are multiple slave available for failover, They exchange information in order to select an optimal master-slave copy of the Offset,slave end will try to get the rank of each slave based on offset, so that the use of each slave when starting failover is proportional to the slave side of rank.  
2, the last time each slave end interacts with its master, which may be the most recent ping or instruction receive time, or the stale time since it was lost to the master end. If the recent interaction time is too long, slave will not attempt to failover.  
2nd can be adjusted by the user to make clear that a slave does not failover. Since the most recent interaction with the master side, the obsolescence time has a calculation formula:  
(Node-timeout * slave-validity-factor) +repl-ping-slave-period  
A larger slave-validity-factor parameter allows the slave to failover its master side with older data, while a smaller value may prevent the cluster from selecting the slave side.  
to get maximum availability, you can set the value of Slave-validity-factor to 0, which means that the slave side will always try to failover its master side regardless of the last interaction time it has with the master side. &NBSP
cluster-slave-validity-factor   default value is

The slave in the cluster can be migrated to the master side of the slave that are not available, which increases the ability of the cluster to handle failures. After all, a master end without slave if there is a failure, there is no way to carry out the failover.
To migrate a slave to another master, you must have at least a given number of available slave on the original master side of this slave to migrate, given the number set by the migration barrier parameter, the default value is 1, The original master side of the slave that is to be migrated should have at least 1 available slave to allow it to be migrated, and to disable this feature you only need to set this parameter to a very large value.
Cluster-migration-barrier 1

By default, when a Redis cluster node discovers that at least one hashslot has not been covered, it stops receiving queries.
In this case, if one part of the cluster is down, the entire cluster will become unusable.
The cluster will be automatically recovered after all the slots have been re-covered.
Set the parameter to no if you want to set the cluster to continue to receive queries when some key space is not cover completed.
Cluster-require-full-coverage Yes

SLOW LOG

Redis's slow log is a record query made by the System OS, which exceeds the specified execution time. The execution time does not include I/O operations such as interacting with the client or sending a reply, it is just the time of the actual execution of the instruction.
There are 2 parameters that can be configured, one to tell the Redis execution time, this time is microsecond (1 seconds =1000000 microseconds), this is to not omit the command. Another parameter is to set the length of the Slowlog, and when a new command is recorded, the oldest command will be removed from the command record queue.
Slowlog-log-slower-than 10000
Slowlog-max-len
You can use theslowlog resetcommand to free the memory that Slowlog occupies.

LATENCY MONITOR

Latency-monitor-threshold 0 Latency Monitoring, which records actions equal to or exceeding a specified time, is turned off by default, which is a value of 0.

Advanced CONFIG

When the number of entries is small and the maximum does not exceed the given threshold, the hash encoding uses a very efficient memory data structure that is configured with the following parameters.
hash-max-ziplist-entries
Hash-max-ziplist-value 64

Similar to hashing, a small amount of lists is encoded in a specified way to save more space, and its thresholds are configured with the following parameters.
list-max-ziplist-entries
List-max-ziplist-value 64

The set sets in a particular case when there is a specified encoding, which is the case that the collection consists of a set of numbers in the range of 64-bit signed integers that are 10 binary. The following options set the size limit for the collection to use this special encoding.
Set-max-intset-entries 512

Like hashes and lists, ordered collections also use a special encoding to save space, and this particular encoding is used only when the length of the ordered set and the elements are below the values set by the following parameters.
zset-max-ziplist-entries
Zset-max-ziplist-value 64

hll-sparse-max-bytes Set Hyeperloglog byte limit, this value is usually between 0~15000, the default is 3000, basically no more than 16000
activerehashing Yes Redis will extract 10 milliseconds per second to re-hash the main dictionary, which helps to free up memory as much as possible

For some reason, the client cannot read the data from the server fast enough, and the client's output cache limit may cause the client to be lost, which can be used for 3 different types of clients: normal, slave, and pubsub.
The format of the settings is as follows:

Client-output-buffer-limit <class>

If the hard limit is reached, the client will lose its connection immediately.
If the soft limit is reached, the client will lose its connection after soft seconds seconds.
Parameters Soft Limit < hard limit.
client-output-buffer-limit Normal 0 0 0
client-output-buffer-limit slave 256mb 64MB
Client-output-buffer-limit pubsub 32MB 8MB 60

Redis uses an internal program to handle background tasks, such as closing a timed-out client connection, clearing expired keys, and so on. It does not handle all tasks at the same time, and Redis checks and executes tasks by specifying the Hz parameters.
The Hz default is set to 10, increasing its value will take up more CPU, of course, the corresponding Redis will be faster processing of many key at the same time, and more accurate to handle timeouts.
The range of Hz values is 1~500, which is usually not recommended for more than 100, and can be raised to 100 only if the request delay is very low.
Hz 10

When a subprocess is to overwrite the aof file, if the following options are enabled, the file will be synchronized each time the 32MB data is generated, so that a larger delay can be avoided when committing the delta file to disk.
Aof-rewrite-incremental-fsync Yes


This article is from the "Dream to Reality" blog, please be sure to keep this source http://lookingdream.blog.51cto.com/5177800/1883867

Redis.conf parameter configuration file detailed

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.