1e16c0c19Santirez# Redis configuration file example. 2e16c0c19Santirez# 3e16c0c19Santirez# Note that in order to read the configuration file, Redis must be 4e16c0c19Santirez# started with the file path as first argument: 5e16c0c19Santirez# 6e16c0c19Santirez# ./redis-server /path/to/redis.conf 7ed9b544eSantirez 857c0cf8bSKashif Rasul# Note on units: when memory size is needed, it is possible to specify 972324005Santirez# it in the usual form of 1k 5GB 4M and so forth: 1072324005Santirez# 1172324005Santirez# 1k => 1000 bytes 1272324005Santirez# 1kb => 1024 bytes 1372324005Santirez# 1m => 1000000 bytes 1472324005Santirez# 1mb => 1024*1024 bytes 1572324005Santirez# 1g => 1000000000 bytes 1672324005Santirez# 1gb => 1024*1024*1024 bytes 1772324005Santirez# 1872324005Santirez# units are case insensitive so 1GB 1Gb 1gB are all the same. 1972324005Santirez 207da423f7SYubao Liu################################## INCLUDES ################################### 217da423f7SYubao Liu 227da423f7SYubao Liu# Include one or more other config files here. This is useful if you 23f62f00e0SBen# have a standard template that goes to all Redis servers but also need 247da423f7SYubao Liu# to customize a few per-server settings. Include files can include 257da423f7SYubao Liu# other files, so use this wisely. 267da423f7SYubao Liu# 277da423f7SYubao Liu# Notice option "include" won't be rewritten by command "CONFIG REWRITE" 28305d7f29Santirez# from admin or Redis Sentinel. Since Redis always uses the last processed 29305d7f29Santirez# line as value of a configuration directive, you'd better put includes 30305d7f29Santirez# at the beginning of this file to avoid overwriting config change at runtime. 31305d7f29Santirez# 32305d7f29Santirez# If instead you are interested in using includes to override configuration 33305d7f29Santirez# options, it is better to use include as the last line. 347da423f7SYubao Liu# 357da423f7SYubao Liu# include /path/to/local.conf 367da423f7SYubao Liu# include /path/to/other.conf 377da423f7SYubao Liu 3810246642Santirez################################## NETWORK ##################################### 397da423f7SYubao Liu 4010246642Santirez# By default, if no "bind" configuration directive is specified, Redis listens 4110246642Santirez# for connections from all the network interfaces available on the server. 4210246642Santirez# It is possible to listen to just one or multiple selected interfaces using 4310246642Santirez# the "bind" configuration directive, followed by one or more IP addresses. 4410246642Santirez# 4510246642Santirez# Examples: 4610246642Santirez# 4710246642Santirez# bind 192.168.1.100 10.0.0.1 4810246642Santirez# bind 127.0.0.1 ::1 4910246642Santirez# 5010246642Santirez# ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the 5110246642Santirez# internet, binding to all the interfaces is dangerous and will expose the 5210246642Santirez# instance to everybody on the internet. So by default we uncomment the 5310246642Santirez# following bind directive, that will force Redis to listen only into 5410246642Santirez# the IPv4 lookback interface address (this means Redis will be able to 5510246642Santirez# accept connections only from clients running into the same computer it 5610246642Santirez# is running). 570aa5acc8Santirez# 580aa5acc8Santirez# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES 59a8a25573Santirez# JUST COMMENT THE FOLLOWING LINE. 6010246642Santirez# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6110246642Santirezbind 127.0.0.1 62ed329fcfSLuc Heinrich 63273c49e7Santirez# Protected mode is a layer of security protection, in order to avoid that 64273c49e7Santirez# Redis instances left open on the internet are accessed and exploited. 65273c49e7Santirez# 66273c49e7Santirez# When protected mode is on and if: 67273c49e7Santirez# 68273c49e7Santirez# 1) The server is not binding explicitly to a set of addresses using the 69273c49e7Santirez# "bind" directive. 70273c49e7Santirez# 2) No password is configured. 71273c49e7Santirez# 72273c49e7Santirez# The server only accepts connections from clients connecting from the 73273c49e7Santirez# IPv4 and IPv6 loopback addresses 127.0.0.1 and ::1, and from Unix domain 74273c49e7Santirez# sockets. 75273c49e7Santirez# 76273c49e7Santirez# By default protected mode is enabled. You should disable it only if 77273c49e7Santirez# you are sure you want clients from other hosts to connect to Redis 78273c49e7Santirez# even if no authentication is configured, nor a specific set of interfaces 79273c49e7Santirez# are explicitly listed using the "bind" directive. 80273c49e7Santirezprotected-mode yes 81273c49e7Santirez 82066d7a29SItamar Haber# Accept connections on the specified port, default is 6379 (IANA #815344). 8368d6345dSantirez# If port 0 is specified Redis will not listen on a TCP socket. 84ed9b544eSantirezport 6379 85ed9b544eSantirez 86e40d3e28Santirez# TCP listen() backlog. 87e40d3e28Santirez# 88e40d3e28Santirez# In high requests-per-second environments you need an high backlog in order 89e40d3e28Santirez# to avoid slow clients connections issues. Note that the Linux kernel 90e40d3e28Santirez# will silently truncate it to the value of /proc/sys/net/core/somaxconn so 91e40d3e28Santirez# make sure to raise both the value of somaxconn and tcp_max_syn_backlog 92e40d3e28Santirez# in order to get the desired effect. 937be946fdSantireztcp-backlog 511 94d76aa96dSNenad Merdanovic 9510246642Santirez# Unix socket. 96ed9b544eSantirez# 9774da4a57Santirez# Specify the path for the Unix socket that will be used to listen for 985d10923fSPieter Noordhuis# incoming connections. There is no default, so Redis will not listen 995d10923fSPieter Noordhuis# on a unix socket when not specified. 100a5639e7dSPieter Noordhuis# 1015d10923fSPieter Noordhuis# unixsocket /tmp/redis.sock 10267c4fbedSEdgars Irmejs# unixsocketperm 700 103a5639e7dSPieter Noordhuis 1040150db36SAman Gupta# Close the connection after a client is idle for N seconds (0 to disable) 105aba4adb7Santireztimeout 0 106ed9b544eSantirez 10798b1a852Santirez# TCP keepalive. 10898b1a852Santirez# 10993ae95deSantirez# If non-zero, use SO_KEEPALIVE to send TCP ACKs to clients in absence 11093ae95deSantirez# of communication. This is useful for two reasons: 11198b1a852Santirez# 11293ae95deSantirez# 1) Detect dead peers. 11393ae95deSantirez# 2) Take the connection alive from the point of view of network 11493ae95deSantirez# equipment in the middle. 11593ae95deSantirez# 11693ae95deSantirez# On Linux, the specified value (in seconds) is the period used to send ACKs. 11793ae95deSantirez# Note that to close the connection the double of the time is needed. 11893ae95deSantirez# On other kernels the period depends on the kernel configuration. 11993ae95deSantirez# 12040cfe131Santirez# A reasonable value for this option is 300 seconds, which is the new 12140cfe131Santirez# Redis default starting with Redis 3.2.1. 12240cfe131Santireztcp-keepalive 300 12398b1a852Santirez 12410246642Santirez################################# GENERAL ##################################### 12510246642Santirez 12610246642Santirez# By default Redis does not run as a daemon. Use 'yes' if you need it. 12710246642Santirez# Note that Redis will write a pid file in /var/run/redis.pid when daemonized. 12810246642Santirezdaemonize no 12910246642Santirez 13010246642Santirez# If you run Redis from upstart or systemd, Redis can interact with your 13110246642Santirez# supervision tree. Options: 13210246642Santirez# supervised no - no supervision interaction 13310246642Santirez# supervised upstart - signal upstart by putting Redis into SIGSTOP mode 13410246642Santirez# supervised systemd - signal systemd by writing READY=1 to $NOTIFY_SOCKET 13510246642Santirez# supervised auto - detect upstart or systemd method based on 13610246642Santirez# UPSTART_JOB or NOTIFY_SOCKET environment variables 13710246642Santirez# Note: these supervision methods only signal "process is ready." 13810246642Santirez# They do not enable continuous liveness pings back to your supervisor. 13910246642Santirezsupervised no 14010246642Santirez 1411a93501fSantirez# If a pid file is specified, Redis writes it where specified at startup 1421a93501fSantirez# and removes it at exit. 1431a93501fSantirez# 1441a93501fSantirez# When the server runs non daemonized, no pid file is created if none is 1451a93501fSantirez# specified in the configuration. When the server is daemonized, the pid file 1461a93501fSantirez# is used even if not specified, defaulting to "/var/run/redis.pid". 1471a93501fSantirez# 1481a93501fSantirez# Creating a pid file is best effort: if Redis is not able to create it 1491a93501fSantirez# nothing bad happens, the server will start and run normally. 1506937f596Sbogdanvlvivpidfile /var/run/redis_6379.pid 15110246642Santirez 15281144645SDavid Celis# Specify the server verbosity level. 15381144645SDavid Celis# This can be one of: 154ed9b544eSantirez# debug (a lot of information, useful for development/testing) 15538aba9a1Santirez# verbose (many rarely useful info, but not a mess like the debug level) 156ed9b544eSantirez# notice (moderately verbose, what you want in production probably) 157ed9b544eSantirez# warning (only very important / critical messages are logged) 158c6f9ee88Santirezloglevel notice 159ed9b544eSantirez 16074da4a57Santirez# Specify the log file name. Also the empty string can be used to force 161029245feSantirez# Redis to log on the standard output. Note that if you use standard 162ed9b544eSantirez# output for logging but daemonize, logs will be sent to /dev/null 163310dbba0Santirezlogfile "" 164ed9b544eSantirez 165e1a586eeSJonah H. Harris# To enable logging to the system logger, just set 'syslog-enabled' to yes, 166e1a586eeSJonah H. Harris# and optionally update the other syslog parameters to suit your needs. 167e1a586eeSJonah H. Harris# syslog-enabled no 168e1a586eeSJonah H. Harris 169e1a586eeSJonah H. Harris# Specify the syslog identity. 170e1a586eeSJonah H. Harris# syslog-ident redis 171e1a586eeSJonah H. Harris 172e1a586eeSJonah H. Harris# Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7. 173e1a586eeSJonah H. Harris# syslog-facility local0 174e1a586eeSJonah H. Harris 175b8b553c8Santirez# Set the number of databases. The default database is DB 0, you can select 176b8b553c8Santirez# a different one on a per-connection basis using SELECT <dbid> where 177b8b553c8Santirez# dbid is a number between 0 and 'databases'-1 178ed9b544eSantirezdatabases 16 179ed9b544eSantirez 1807da423f7SYubao Liu################################ SNAPSHOTTING ################################ 181121f70cfSantirez# 182121f70cfSantirez# Save the DB on disk: 183121f70cfSantirez# 184121f70cfSantirez# save <seconds> <changes> 185121f70cfSantirez# 186121f70cfSantirez# Will save the DB if both the given number of seconds and the given 187121f70cfSantirez# number of write operations against the DB occurred. 188121f70cfSantirez# 189121f70cfSantirez# In the example below the behaviour will be to save: 190121f70cfSantirez# after 900 sec (15 min) if at least 1 key changed 191121f70cfSantirez# after 300 sec (5 min) if at least 10 keys changed 192121f70cfSantirez# after 60 sec if at least 10000 keys changed 193e7546c63Santirez# 194df484c7aSManuel Meurer# Note: you can disable saving completely by commenting out all "save" lines. 1954aac3ff2Santirez# 1964aac3ff2Santirez# It is also possible to remove all the previously configured save 1974aac3ff2Santirez# points by adding a save directive with a single empty string argument 1984aac3ff2Santirez# like in the following example: 1994aac3ff2Santirez# 2004aac3ff2Santirez# save "" 201e7546c63Santirez 20238aba9a1Santirezsave 900 1 20338aba9a1Santirezsave 300 10 20438aba9a1Santirezsave 60 10000 205121f70cfSantirez 2064d3bbf35Santirez# By default Redis will stop accepting writes if RDB snapshots are enabled 2074d3bbf35Santirez# (at least one save point) and the latest background save failed. 20874da4a57Santirez# This will make the user aware (in a hard way) that data is not persisting 2094d3bbf35Santirez# on disk properly, otherwise chances are that no one will notice and some 21074da4a57Santirez# disaster will happen. 2114d3bbf35Santirez# 2124d3bbf35Santirez# If the background saving process will start working again Redis will 2134d3bbf35Santirez# automatically allow writes again. 2144d3bbf35Santirez# 2154d3bbf35Santirez# However if you have setup your proper monitoring of the Redis server 2164d3bbf35Santirez# and persistence, you may want to disable this feature so that Redis will 21774431b80SAnurag Ramdasan# continue to work as usual even if there are problems with disk, 2184d3bbf35Santirez# permissions, and so forth. 2194d3bbf35Santirezstop-writes-on-bgsave-error yes 2204d3bbf35Santirez 221121f70cfSantirez# Compress string objects using LZF when dump .rdb databases? 222b0553789Santirez# For default that's set to 'yes' as it's almost always a win. 223b0553789Santirez# If you want to save some CPU in the saving child set it to 'no' but 224b0553789Santirez# the dataset will likely be bigger if you have compressible values or keys. 225b0553789Santirezrdbcompression yes 226121f70cfSantirez 22781144645SDavid Celis# Since version 5 of RDB a CRC64 checksum is placed at the end of the file. 22884bcd3aaSantirez# This makes the format more resistant to corruption but there is a performance 22984bcd3aaSantirez# hit to pay (around 10%) when saving and loading RDB files, so you can disable it 23084bcd3aaSantirez# for maximum performances. 23184bcd3aaSantirez# 23284bcd3aaSantirez# RDB files created with checksum disabled have a checksum of zero that will 23384bcd3aaSantirez# tell the loading code to skip the check. 23484bcd3aaSantirezrdbchecksum yes 23584bcd3aaSantirez 236121f70cfSantirez# The filename where to dump the DB 237121f70cfSantirezdbfilename dump.rdb 238121f70cfSantirez 239029245feSantirez# The working directory. 240029245feSantirez# 241029245feSantirez# The DB will be written inside this directory, with the filename specified 242029245feSantirez# above using the 'dbfilename' configuration directive. 243029245feSantirez# 24481144645SDavid Celis# The Append Only File will also be created inside this directory. 245029245feSantirez# 246029245feSantirez# Note that you must specify a directory here, not a file name. 247121f70cfSantirezdir ./ 248121f70cfSantirez 249ed9b544eSantirez################################# REPLICATION ################################# 250ed9b544eSantirez 251ed9b544eSantirez# Master-Slave replication. Use slaveof to make a Redis instance a copy of 25249c817c2Santirez# another Redis server. A few things to understand ASAP about Redis replication. 25349c817c2Santirez# 25449c817c2Santirez# 1) Redis replication is asynchronous, but you can configure a master to 25549c817c2Santirez# stop accepting writes if it appears to be not connected with at least 25649c817c2Santirez# a given number of slaves. 25749c817c2Santirez# 2) Redis slaves are able to perform a partial resynchronization with the 25849c817c2Santirez# master if the replication link is lost for a relatively small amount of 25949c817c2Santirez# time. You may want to configure the replication backlog size (see the next 26049c817c2Santirez# sections of this file) with a sensible value depending on your needs. 26149c817c2Santirez# 3) Replication is automatic and does not need user intervention. After a 26249c817c2Santirez# network partition slaves automatically try to reconnect to masters 26349c817c2Santirez# and resynchronize with them. 2643f477979Santirez# 265ed9b544eSantirez# slaveof <masterip> <masterport> 266ed9b544eSantirez 2673f477979Santirez# If the master is password protected (using the "requirepass" configuration 2683f477979Santirez# directive below) it is possible to tell the slave to authenticate before 2693f477979Santirez# starting the replication synchronization process, otherwise the master will 2703f477979Santirez# refuse the slave request. 2713f477979Santirez# 2723f477979Santirez# masterauth <master-password> 2733f477979Santirez 27481144645SDavid Celis# When a slave loses its connection with the master, or when the replication 2754ebfc455Santirez# is still in progress, the slave can act in two different ways: 2764ebfc455Santirez# 2774ebfc455Santirez# 1) if slave-serve-stale-data is set to 'yes' (the default) the slave will 27892a157eaSJérémy Bethmont# still reply to client requests, possibly with out of date data, or the 2794ebfc455Santirez# data set may just be empty if this is the first synchronization. 2804ebfc455Santirez# 281d7838604SStam He# 2) if slave-serve-stale-data is set to 'no' the slave will reply with 2824ebfc455Santirez# an error "SYNC with master in progress" to all the kind of commands 2834ebfc455Santirez# but to INFO and SLAVEOF. 2844ebfc455Santirez# 2854ebfc455Santirezslave-serve-stale-data yes 2864ebfc455Santirez 287f3fd419fSantirez# You can configure a slave instance to accept writes or not. Writing against 288f3fd419fSantirez# a slave instance may be useful to store some ephemeral data (because data 289f3fd419fSantirez# written on a slave will be easily deleted after resync with the master) but 290ba864e09Santirez# may also cause problems if clients are writing to it because of a 291ba864e09Santirez# misconfiguration. 292f3fd419fSantirez# 293f3fd419fSantirez# Since Redis 2.6 by default slaves are read-only. 294ba864e09Santirez# 295ba864e09Santirez# Note: read only slaves are not designed to be exposed to untrusted clients 296ba864e09Santirez# on the internet. It's just a protection layer against misuse of the instance. 297ba864e09Santirez# Still a read only slave exports by default all the administrative commands 298fb6b9b14SAnurag Ramdasan# such as CONFIG, DEBUG, and so forth. To a limited extent you can improve 299ba864e09Santirez# security of read only slaves using 'rename-command' to shadow all the 300ba864e09Santirez# administrative / dangerous commands. 301f3fd419fSantirezslave-read-only yes 302f3fd419fSantirez 30318de5395Santirez# Replication SYNC strategy: disk or socket. 30418de5395Santirez# 305e07dd8b3Santirez# ------------------------------------------------------- 306e07dd8b3Santirez# WARNING: DISKLESS REPLICATION IS EXPERIMENTAL CURRENTLY 307e07dd8b3Santirez# ------------------------------------------------------- 308e07dd8b3Santirez# 30918de5395Santirez# New slaves and reconnecting slaves that are not able to continue the replication 31018de5395Santirez# process just receiving differences, need to do what is called a "full 31118de5395Santirez# synchronization". An RDB file is transmitted from the master to the slaves. 31218de5395Santirez# The transmission can happen in two different ways: 31318de5395Santirez# 31418de5395Santirez# 1) Disk-backed: The Redis master creates a new process that writes the RDB 31518de5395Santirez# file on disk. Later the file is transferred by the parent 31618de5395Santirez# process to the slaves incrementally. 31718de5395Santirez# 2) Diskless: The Redis master creates a new process that directly writes the 31818de5395Santirez# RDB file to slave sockets, without touching the disk at all. 31918de5395Santirez# 32018de5395Santirez# With disk-backed replication, while the RDB file is generated, more slaves 32118de5395Santirez# can be queued and served with the RDB file as soon as the current child producing 32218de5395Santirez# the RDB file finishes its work. With diskless replication instead once 32318de5395Santirez# the transfer starts, new slaves arriving will be queued and a new transfer 32418de5395Santirez# will start when the current one terminates. 32518de5395Santirez# 32618de5395Santirez# When diskless replication is used, the master waits a configurable amount of 32718de5395Santirez# time (in seconds) before starting the transfer in the hope that multiple slaves 32818de5395Santirez# will arrive and the transfer can be parallelized. 32918de5395Santirez# 33018de5395Santirez# With slow disks and fast (large bandwidth) networks, diskless replication 33118de5395Santirez# works better. 33218de5395Santirezrepl-diskless-sync no 33318de5395Santirez 3343b9a9798Santirez# When diskless replication is enabled, it is possible to configure the delay 3356df9001dSMariano Pérez Rodríguez# the server waits in order to spawn the child that transfers the RDB via socket 3363b9a9798Santirez# to the slaves. 3373b9a9798Santirez# 3383b9a9798Santirez# This is important since once the transfer starts, it is not possible to serve 3393b9a9798Santirez# new slaves arriving, that will be queued for the next RDB transfer, so the server 3403b9a9798Santirez# waits a delay in order to let more slaves arrive. 3413b9a9798Santirez# 3423b9a9798Santirez# The delay is specified in seconds, and by default is 5 seconds. To disable 3433b9a9798Santirez# it entirely just set it to 0 seconds and the transfer will start ASAP. 3443b9a9798Santirezrepl-diskless-sync-delay 5 3453b9a9798Santirez 3468996bf77Santirez# Slaves send PINGs to server in a predefined interval. It's possible to change 3478996bf77Santirez# this interval with the repl_ping_slave_period option. The default value is 10 3488996bf77Santirez# seconds. 3498996bf77Santirez# 350f15e33a8SHerbert G. Fischer# repl-ping-slave-period 10 3518996bf77Santirez 352c9b55a29Santirez# The following option sets the replication timeout for: 353c9b55a29Santirez# 354c9b55a29Santirez# 1) Bulk transfer I/O during SYNC, from the point of view of slave. 355c9b55a29Santirez# 2) Master timeout from the point of view of slaves (data, pings). 356c9b55a29Santirez# 3) Slave timeout from the point of view of masters (REPLCONF ACK pings). 3578996bf77Santirez# 35885ccd576Santirez# It is important to make sure that this value is greater than the value 35985ccd576Santirez# specified for repl-ping-slave-period otherwise a timeout will be detected 36085ccd576Santirez# every time there is low traffic between the master and the slave. 36185ccd576Santirez# 362f15e33a8SHerbert G. Fischer# repl-timeout 60 3638996bf77Santirez 364b70b459bSantirez# Disable TCP_NODELAY on the slave socket after SYNC? 365b70b459bSantirez# 366b70b459bSantirez# If you select "yes" Redis will use a smaller number of TCP packets and 367b70b459bSantirez# less bandwidth to send data to slaves. But this can add a delay for 368b70b459bSantirez# the data to appear on the slave side, up to 40 milliseconds with 369b70b459bSantirez# Linux kernels using a default configuration. 370b70b459bSantirez# 371b70b459bSantirez# If you select "no" the delay for data to appear on the slave side will 372b70b459bSantirez# be reduced but more bandwidth will be used for replication. 373b70b459bSantirez# 374b70b459bSantirez# By default we optimize for low latency, but in very high traffic conditions 375b70b459bSantirez# or when the master and slaves are many hops away, turning this to "yes" may 376b70b459bSantirez# be a good idea. 377b70b459bSantirezrepl-disable-tcp-nodelay no 378b70b459bSantirez 37907888202Santirez# Set the replication backlog size. The backlog is a buffer that accumulates 38007888202Santirez# slave data when slaves are disconnected for some time, so that when a slave 38107888202Santirez# wants to reconnect again, often a full resync is not needed, but a partial 38207888202Santirez# resync is enough, just passing the portion of data the slave missed while 38307888202Santirez# disconnected. 38407888202Santirez# 385aa628446SJan-Erik Rediger# The bigger the replication backlog, the longer the time the slave can be 38607888202Santirez# disconnected and later be able to perform a partial resynchronization. 38707888202Santirez# 38807888202Santirez# The backlog is only allocated once there is at least a slave connected. 38907888202Santirez# 39007888202Santirez# repl-backlog-size 1mb 39107888202Santirez 39207888202Santirez# After a master has no longer connected slaves for some time, the backlog 39307888202Santirez# will be freed. The following option configures the amount of seconds that 39407888202Santirez# need to elapse, starting from the time the last slave disconnected, for 39507888202Santirez# the backlog buffer to be freed. 39607888202Santirez# 39707888202Santirez# A value of 0 means to never release the backlog. 39807888202Santirez# 39907888202Santirez# repl-backlog-ttl 3600 40007888202Santirez 401712656e8Santirez# The slave priority is an integer number published by Redis in the INFO output. 402712656e8Santirez# It is used by Redis Sentinel in order to select a slave to promote into a 403712656e8Santirez# master if the master is no longer working correctly. 404712656e8Santirez# 405712656e8Santirez# A slave with a low priority number is considered better for promotion, so 406712656e8Santirez# for instance if there are three slaves with priority 10, 100, 25 Sentinel will 40774da4a57Santirez# pick the one with priority 10, that is the lowest. 408712656e8Santirez# 409712656e8Santirez# However a special priority of 0 marks the slave as not able to perform the 410712656e8Santirez# role of master, so a slave with priority of 0 will never be selected by 411712656e8Santirez# Redis Sentinel for promotion. 412712656e8Santirez# 413712656e8Santirez# By default the priority is 100. 414712656e8Santirezslave-priority 100 415712656e8Santirez 416cbdb2153Santirez# It is possible for a master to stop accepting writes if there are less than 417cbdb2153Santirez# N slaves connected, having a lag less or equal than M seconds. 418cbdb2153Santirez# 419cbdb2153Santirez# The N slaves need to be in "online" state. 420cbdb2153Santirez# 421cbdb2153Santirez# The lag in seconds, that must be <= the specified value, is calculated from 422cbdb2153Santirez# the last ping received from the slave, that is usually sent every second. 423cbdb2153Santirez# 424f62f00e0SBen# This option does not GUARANTEE that N replicas will accept the write, but 425cbdb2153Santirez# will limit the window of exposure for lost writes in case not enough slaves 426cbdb2153Santirez# are available, to the specified number of seconds. 427cbdb2153Santirez# 428cbdb2153Santirez# For example to require at least 3 slaves with a lag <= 10 seconds use: 429cbdb2153Santirez# 430ed599d3aSantirez# min-slaves-to-write 3 431ed599d3aSantirez# min-slaves-max-lag 10 432ed599d3aSantirez# 433ed599d3aSantirez# Setting one or the other to 0 disables the feature. 434ed599d3aSantirez# 435ed599d3aSantirez# By default min-slaves-to-write is set to 0 (feature disabled) and 436ed599d3aSantirez# min-slaves-max-lag is set to 10. 437cbdb2153Santirez 438*0a45fbc3Santirez# A Redis master is able to list the address and port of the attached 439*0a45fbc3Santirez# slaves in different ways. For example the "INFO replication" section 440*0a45fbc3Santirez# offers this information, which is used, among other tools, by 441*0a45fbc3Santirez# Redis Sentinel in order to discover slave instances. 442*0a45fbc3Santirez# Another place where this info is available is in the output of the 443*0a45fbc3Santirez# "ROLE" command of a masteer. 444*0a45fbc3Santirez# 445*0a45fbc3Santirez# The listed IP and address normally reported by a slave is obtained 446*0a45fbc3Santirez# in the following way: 447*0a45fbc3Santirez# 448*0a45fbc3Santirez# IP: The address is auto detected by checking the peer address 449*0a45fbc3Santirez# of the socket used by the slave to connect with the master. 450*0a45fbc3Santirez# 451*0a45fbc3Santirez# Port: The port is communicated by the slave during the replication 452*0a45fbc3Santirez# handshake, and is normally the port that the slave is using to 453*0a45fbc3Santirez# list for connections. 454*0a45fbc3Santirez# 455*0a45fbc3Santirez# However when port forwarding or Network Address Translation (NAT) is 456*0a45fbc3Santirez# used, the slave may be actually reachable via different IP and port 457*0a45fbc3Santirez# pairs. The following two options can be used by a slave in order to 458*0a45fbc3Santirez# report to its master a specific set of IP and port, so that both INFO 459*0a45fbc3Santirez# and ROLE will report those values. 460*0a45fbc3Santirez# 461*0a45fbc3Santirez# There is no need to use both the options if you need to override just 462*0a45fbc3Santirez# the port or the IP address. 463*0a45fbc3Santirez# 464*0a45fbc3Santirez# slave-announce-ip 5.5.5.5 465*0a45fbc3Santirez# slave-announce-port 1234 466*0a45fbc3Santirez 467f2aa84bdSantirez################################## SECURITY ################################### 468f2aa84bdSantirez 469f2aa84bdSantirez# Require clients to issue AUTH <PASSWORD> before processing any other 470f2aa84bdSantirez# commands. This might be useful in environments in which you do not trust 471f2aa84bdSantirez# others with access to the host running redis-server. 472f2aa84bdSantirez# 473f2aa84bdSantirez# This should stay commented out for backward compatibility and because most 474f2aa84bdSantirez# people do not need auth (e.g. they run their own servers). 4753f477979Santirez# 4761b677732Santirez# Warning: since Redis is pretty fast an outside user can try up to 4771b677732Santirez# 150k passwords per second against a good box. This means that you should 4781b677732Santirez# use a very strong password otherwise it will be very easy to break. 4791b677732Santirez# 480f2aa84bdSantirez# requirepass foobared 481f2aa84bdSantirez 4828d3e063aSantirez# Command renaming. 4838d3e063aSantirez# 48457c0cf8bSKashif Rasul# It is possible to change the name of dangerous commands in a shared 4858d3e063aSantirez# environment. For instance the CONFIG command may be renamed into something 48681144645SDavid Celis# hard to guess so that it will still be available for internal-use tools 48781144645SDavid Celis# but not available for general clients. 4888d3e063aSantirez# 4898d3e063aSantirez# Example: 4908d3e063aSantirez# 4918d3e063aSantirez# rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52 4928d3e063aSantirez# 49381144645SDavid Celis# It is also possible to completely kill a command by renaming it into 4948d3e063aSantirez# an empty string: 4958d3e063aSantirez# 4968d3e063aSantirez# rename-command CONFIG "" 4974d629126Santirez# 4984d629126Santirez# Please note that changing the name of commands that are logged into the 4994d629126Santirez# AOF file or transmitted to slaves may cause problems. 5008d3e063aSantirez 501285add55Santirez################################### LIMITS #################################### 502285add55Santirez 50358732c23Santirez# Set the max number of connected clients at the same time. By default 50458732c23Santirez# this limit is set to 10000 clients, however if the Redis server is not 5059d09ce39Sguiquanz# able to configure the process file limit to allow for the specified limit 50658732c23Santirez# the max number of allowed clients is set to the current file limit 50758732c23Santirez# minus 32 (as Redis reserves a few file descriptors for internal uses). 50858732c23Santirez# 509285add55Santirez# Once the limit is reached Redis will close all the new connections sending 510285add55Santirez# an error 'max number of clients reached'. 5113f477979Santirez# 51258732c23Santirez# maxclients 10000 513285add55Santirez 5143fd78bcdSantirez# Don't use more memory than the specified amount of bytes. 515cebb7b92Santirez# When the memory limit is reached Redis will try to remove keys 5168534a290Santirez# according to the eviction policy selected (see maxmemory-policy). 5173fd78bcdSantirez# 518cebb7b92Santirez# If Redis can't remove keys according to the policy, or if the policy is 519cebb7b92Santirez# set to 'noeviction', Redis will start to reply with errors to commands 520cebb7b92Santirez# that would use more memory, like SET, LPUSH, and so on, and will continue 521cebb7b92Santirez# to reply to read-only commands like GET. 522144d479bSantirez# 523cebb7b92Santirez# This option is usually useful when using Redis as an LRU cache, or to set 52474da4a57Santirez# a hard memory limit for an instance (using the 'noeviction' policy). 525cebb7b92Santirez# 526cebb7b92Santirez# WARNING: If you have slaves attached to an instance with maxmemory on, 527cebb7b92Santirez# the size of the output buffers needed to feed the slaves are subtracted 528cebb7b92Santirez# from the used memory count, so that network problems / resyncs will 529cebb7b92Santirez# not trigger a loop where keys are evicted, and in turn the output 530cebb7b92Santirez# buffer of slaves is full with DELs of keys evicted triggering the deletion 531cebb7b92Santirez# of more keys, and so forth until the database is completely emptied. 5323f477979Santirez# 533f9ef912cSantirez# In short... if you have slaves attached it is suggested that you set a lower 534f9ef912cSantirez# limit for maxmemory so that there is some free RAM on the system for slave 535f9ef912cSantirez# output buffers (but this is not needed if the policy is 'noeviction'). 536f9ef912cSantirez# 5373fd78bcdSantirez# maxmemory <bytes> 5383fd78bcdSantirez 539165346caSantirez# MAXMEMORY POLICY: how Redis will select what to remove when maxmemory 54081144645SDavid Celis# is reached. You can select among five behaviors: 541165346caSantirez# 542165346caSantirez# volatile-lru -> remove the key with an expire set using an LRU algorithm 543f62f00e0SBen# allkeys-lru -> remove any key according to the LRU algorithm 544165346caSantirez# volatile-random -> remove a random key with an expire set 54596e9f8d5Squiver# allkeys-random -> remove a random key, any key 546165346caSantirez# volatile-ttl -> remove the key with the nearest expire time (minor TTL) 5475402c426Santirez# noeviction -> don't expire at all, just return an error on write operations 5485402c426Santirez# 54981144645SDavid Celis# Note: with any of the above policies, Redis will return an error on write 550f62f00e0SBen# operations, when there are no suitable keys for eviction. 5515402c426Santirez# 552be006163SMiguel Parramon# At the date of writing these commands are: set setnx setex append 5535402c426Santirez# incr decr rpush lpush rpushx lpushx linsert lset rpoplpush sadd 5545402c426Santirez# sinter sinterstore sunion sunionstore sdiff sdiffstore zadd zincrby 5555402c426Santirez# zunionstore zinterstore hset hsetnx hmset hincrby incrby decrby 5565402c426Santirez# getset mset msetnx exec sort 5575402c426Santirez# 5585402c426Santirez# The default is: 559165346caSantirez# 5605fa3248bSantirez# maxmemory-policy noeviction 561165346caSantirez 562165346caSantirez# LRU and minimal TTL algorithms are not precise algorithms but approximated 563f4da796cSantirez# algorithms (in order to save memory), so you can tune it for speed or 564f4da796cSantirez# accuracy. For default Redis will check five keys and pick the one that was 565f4da796cSantirez# used less recently, you can change the sample size using the following 566f4da796cSantirez# configuration directive. 567165346caSantirez# 568f4da796cSantirez# The default of 5 produces good enough results. 10 Approximates very closely 569f4da796cSantirez# true LRU but costs a bit more CPU. 3 is very fast but not very accurate. 570f4da796cSantirez# 571f4da796cSantirez# maxmemory-samples 5 572165346caSantirez 57344b38ef4Santirez############################## APPEND ONLY MODE ############################### 57444b38ef4Santirez 57560e2e5b5Santirez# By default Redis asynchronously dumps the dataset on disk. This mode is 57660e2e5b5Santirez# good enough in many applications, but an issue with the Redis process or 57760e2e5b5Santirez# a power outage may result into a few minutes of writes lost (depending on 57860e2e5b5Santirez# the configured save points). 57944b38ef4Santirez# 58060e2e5b5Santirez# The Append Only File is an alternative persistence mode that provides 58160e2e5b5Santirez# much better durability. For instance using the default data fsync policy 58260e2e5b5Santirez# (see later in the config file) Redis can lose just one second of writes in a 58360e2e5b5Santirez# dramatic event like a server power outage, or a single write if something 58460e2e5b5Santirez# wrong with the Redis process itself happens, but the operating system is 58560e2e5b5Santirez# still running correctly. 5860154acdcSantirez# 58760e2e5b5Santirez# AOF and RDB persistence can be enabled at the same time without problems. 58860e2e5b5Santirez# If the AOF is enabled on startup Redis will load the AOF, that is the file 58960e2e5b5Santirez# with the better durability guarantees. 59060e2e5b5Santirez# 59160e2e5b5Santirez# Please check http://redis.io/topics/persistence for more information. 59244b38ef4Santirez 5934e141d5aSantirezappendonly no 59444b38ef4Santirez 595f3b52411SPieter Noordhuis# The name of the append only file (default: "appendonly.aof") 5966d184e02Santirez 5976d184e02Santirezappendfilename "appendonly.aof" 598f3b52411SPieter Noordhuis 5994e141d5aSantirez# The fsync() call tells the Operating System to actually write data on disk 600f62f00e0SBen# instead of waiting for more data in the output buffer. Some OS will really flush 60148f0308aSantirez# data on disk, some other OS will just try to do it ASAP. 60248f0308aSantirez# 60348f0308aSantirez# Redis supports three different modes: 60448f0308aSantirez# 60548f0308aSantirez# no: don't fsync, just let the OS flush the data when it wants. Faster. 60648f0308aSantirez# always: fsync after every write to the append only log. Slow, Safest. 60760e2e5b5Santirez# everysec: fsync only one time every second. Compromise. 60848f0308aSantirez# 60981144645SDavid Celis# The default is "everysec", as that's usually the right compromise between 6106766f45eSantirez# speed and data safety. It's up to you to understand if you can relax this to 611ce6628daSdiegok# "no" that will let the operating system flush the output buffer when 6126766f45eSantirez# it wants, for better performances (but if you can live with the idea of 6136766f45eSantirez# some data loss consider the default persistence mode that's snapshotting), 6146766f45eSantirez# or on the contrary, use "always" that's very slow but a bit safer than 6156766f45eSantirez# everysec. 6166766f45eSantirez# 61760e2e5b5Santirez# More details please check the following article: 61860e2e5b5Santirez# http://antirez.com/post/redis-persistence-demystified.html 61960e2e5b5Santirez# 6206766f45eSantirez# If unsure, use "everysec". 62148f0308aSantirez 6226766f45eSantirez# appendfsync always 6236766f45eSantirezappendfsync everysec 6244e141d5aSantirez# appendfsync no 62548f0308aSantirez 626d5d23dabSantirez# When the AOF fsync policy is set to always or everysec, and a background 627d5d23dabSantirez# saving process (a background save or AOF log background rewriting) is 628d5d23dabSantirez# performing a lot of I/O against the disk, in some Linux configurations 629d5d23dabSantirez# Redis may block too long on the fsync() call. Note that there is no fix for 630d5d23dabSantirez# this currently, as even performing fsync in a different thread will block 631d5d23dabSantirez# our synchronous write(2) call. 632d5d23dabSantirez# 633d5d23dabSantirez# In order to mitigate this problem it's possible to use the following option 634d5d23dabSantirez# that will prevent fsync() from being called in the main process while a 635d5d23dabSantirez# BGSAVE or BGREWRITEAOF is in progress. 636d5d23dabSantirez# 63781144645SDavid Celis# This means that while another child is saving, the durability of Redis is 63881144645SDavid Celis# the same as "appendfsync none". In practical terms, this means that it is 63981144645SDavid Celis# possible to lose up to 30 seconds of log in the worst scenario (with the 640d5d23dabSantirez# default Linux settings). 641d5d23dabSantirez# 642d5d23dabSantirez# If you have latency problems turn this to "yes". Otherwise leave it as 643d5d23dabSantirez# "no" that is the safest pick from the point of view of durability. 6446d184e02Santirez 645d5d23dabSantirezno-appendfsync-on-rewrite no 646d5d23dabSantirez 647b333e239Santirez# Automatic rewrite of the append only file. 648b333e239Santirez# Redis is able to automatically rewrite the log file implicitly calling 64981144645SDavid Celis# BGREWRITEAOF when the AOF log size grows by the specified percentage. 650b333e239Santirez# 651b333e239Santirez# This is how it works: Redis remembers the size of the AOF file after the 65281144645SDavid Celis# latest rewrite (if no rewrite has happened since the restart, the size of 653b333e239Santirez# the AOF at startup is used). 654b333e239Santirez# 655b333e239Santirez# This base size is compared to the current size. If the current size is 656b333e239Santirez# bigger than the specified percentage, the rewrite is triggered. Also 657b333e239Santirez# you need to specify a minimal size for the AOF file to be rewritten, this 658b333e239Santirez# is useful to avoid rewriting the AOF file even if the percentage increase 659b333e239Santirez# is reached but it is still pretty small. 660b333e239Santirez# 66157c0cf8bSKashif Rasul# Specify a percentage of zero in order to disable the automatic AOF 662b333e239Santirez# rewrite feature. 663b333e239Santirez 664b333e239Santirezauto-aof-rewrite-percentage 100 665b333e239Santirezauto-aof-rewrite-min-size 64mb 666b333e239Santirez 66731f79a46Santirez# An AOF file may be found to be truncated at the end during the Redis 66831f79a46Santirez# startup process, when the AOF data gets loaded back into memory. 66931f79a46Santirez# This may happen when the system where Redis is running 67031f79a46Santirez# crashes, especially when an ext4 filesystem is mounted without the 67131f79a46Santirez# data=ordered option (however this can't happen when Redis itself 67231f79a46Santirez# crashes or aborts but the operating system still works correctly). 67331f79a46Santirez# 67431f79a46Santirez# Redis can either exit with an error when this happens, or load as much 67531f79a46Santirez# data as possible (the default now) and start if the AOF file is found 67631f79a46Santirez# to be truncated at the end. The following option controls this behavior. 67731f79a46Santirez# 67831f79a46Santirez# If aof-load-truncated is set to yes, a truncated AOF file is loaded and 67931f79a46Santirez# the Redis server starts emitting a log to inform the user of the event. 68031f79a46Santirez# Otherwise if the option is set to no, the server aborts with an error 68131f79a46Santirez# and refuses to start. When the option is set to no, the user requires 68231f79a46Santirez# to fix the AOF file using the "redis-check-aof" utility before to restart 68331f79a46Santirez# the server. 68431f79a46Santirez# 68531f79a46Santirez# Note that if the AOF file will be found to be corrupted in the middle 68631f79a46Santirez# the server will still exit with an error. This option only applies when 68731f79a46Santirez# Redis will try to read more data from the AOF file but not enough bytes 68831f79a46Santirez# will be found. 68931f79a46Santirezaof-load-truncated yes 69031f79a46Santirez 691eeffcf38Santirez################################ LUA SCRIPTING ############################### 692eeffcf38Santirez 693eeffcf38Santirez# Max execution time of a Lua script in milliseconds. 694115e3ff3Santirez# 695115e3ff3Santirez# If the maximum execution time is reached Redis will log that a script is 69657c0cf8bSKashif Rasul# still in execution after the maximum allowed time and will start to 697115e3ff3Santirez# reply to queries with an error. 698115e3ff3Santirez# 699f62f00e0SBen# When a long running script exceeds the maximum execution time only the 7000b14e441Santirez# SCRIPT KILL and SHUTDOWN NOSAVE commands are available. The first can be 7010b14e441Santirez# used to stop a script that did not yet called write commands. The second 702f62f00e0SBen# is the only way to shut down the server in the case a write command was 703f62f00e0SBen# already issued by the script but the user doesn't want to wait for the natural 7040b14e441Santirez# termination of the script. 705115e3ff3Santirez# 706115e3ff3Santirez# Set it to 0 or a negative value for unlimited execution without warnings. 707115e3ff3Santirezlua-time-limit 5000 708eeffcf38Santirez 70907c152a7Santirez################################ REDIS CLUSTER ############################### 71007c152a7Santirez# 71142357668Santirez# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 71242357668Santirez# WARNING EXPERIMENTAL: Redis Cluster is considered to be stable code, however 71342357668Santirez# in order to mark it as "mature" we need to wait for a non trivial percentage 71442357668Santirez# of users to deploy it in production. 71542357668Santirez# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 71642357668Santirez# 71781144645SDavid Celis# Normal Redis instances can't be part of a Redis Cluster; only nodes that are 71807c152a7Santirez# started as cluster nodes can. In order to start a Redis instance as a 71907c152a7Santirez# cluster node enable the cluster support uncommenting the following: 72007c152a7Santirez# 72107c152a7Santirez# cluster-enabled yes 72207c152a7Santirez 72307c152a7Santirez# Every cluster node has a cluster configuration file. This file is not 72407c152a7Santirez# intended to be edited by hand. It is created and updated by Redis nodes. 72507c152a7Santirez# Every Redis Cluster node requires a different cluster configuration file. 726f62f00e0SBen# Make sure that instances running in the same system do not have 72707c152a7Santirez# overlapping cluster configuration file names. 72807c152a7Santirez# 72907c152a7Santirez# cluster-config-file nodes-6379.conf 73007c152a7Santirez 731e5864c73Santirez# Cluster node timeout is the amount of milliseconds a node must be unreachable 73205fa4f40Santirez# for it to be considered in failure state. 733e5864c73Santirez# Most other internal time limits are multiple of the node timeout. 73405fa4f40Santirez# 735e5864c73Santirez# cluster-node-timeout 15000 73605fa4f40Santirez 73739603a7eSantirez# A slave of a failing master will avoid to start a failover if its data 73839603a7eSantirez# looks too old. 73939603a7eSantirez# 74039603a7eSantirez# There is no simple way for a slave to actually have a exact measure of 74139603a7eSantirez# its "data age", so the following two checks are performed: 74239603a7eSantirez# 74339603a7eSantirez# 1) If there are multiple slaves able to failover, they exchange messages 74439603a7eSantirez# in order to try to give an advantage to the slave with the best 74539603a7eSantirez# replication offset (more data from the master processed). 74639603a7eSantirez# Slaves will try to get their rank by offset, and apply to the start 74739603a7eSantirez# of the failover a delay proportional to their rank. 74839603a7eSantirez# 74939603a7eSantirez# 2) Every single slave computes the time of the last interaction with 75039603a7eSantirez# its master. This can be the last ping or command received (if the master 75139603a7eSantirez# is still in the "connected" state), or the time that elapsed since the 75239603a7eSantirez# disconnection with the master (if the replication link is currently down). 75339603a7eSantirez# If the last interaction is too old, the slave will not try to failover 75439603a7eSantirez# at all. 75539603a7eSantirez# 75639603a7eSantirez# The point "2" can be tuned by user. Specifically a slave will not perform 75739603a7eSantirez# the failover if, since the last interaction with the master, the time 75839603a7eSantirez# elapsed is greater than: 75939603a7eSantirez# 76039603a7eSantirez# (node-timeout * slave-validity-factor) + repl-ping-slave-period 76139603a7eSantirez# 76239603a7eSantirez# So for example if node-timeout is 30 seconds, and the slave-validity-factor 76339603a7eSantirez# is 10, and assuming a default repl-ping-slave-period of 10 seconds, the 76439603a7eSantirez# slave will not try to failover if it was not able to talk with the master 76539603a7eSantirez# for longer than 310 seconds. 76639603a7eSantirez# 76739603a7eSantirez# A large slave-validity-factor may allow slaves with too old data to failover 76839603a7eSantirez# a master, while a too small value may prevent the cluster from being able to 76939603a7eSantirez# elect a slave at all. 77039603a7eSantirez# 77139603a7eSantirez# For maximum availability, it is possible to set the slave-validity-factor 77239603a7eSantirez# to a value of 0, which means, that slaves will always try to failover the 77339603a7eSantirez# master regardless of the last time they interacted with the master. 77439603a7eSantirez# (However they'll always try to apply a delay proportional to their 77539603a7eSantirez# offset rank). 77639603a7eSantirez# 77739603a7eSantirez# Zero is the only value able to guarantee that when all the partitions heal 77839603a7eSantirez# the cluster will always be able to continue. 77939603a7eSantirez# 78039603a7eSantirez# cluster-slave-validity-factor 10 78139603a7eSantirez 782a7d30681Santirez# Cluster slaves are able to migrate to orphaned masters, that are masters 783a7d30681Santirez# that are left without working slaves. This improves the cluster ability 784a7d30681Santirez# to resist to failures as otherwise an orphaned master can't be failed over 785a7d30681Santirez# in case of failure if it has no working slaves. 786a7d30681Santirez# 787a7d30681Santirez# Slaves migrate to orphaned masters only if there are still at least a 788a7d30681Santirez# given number of other working slaves for their old master. This number 789cbfdd13bSantirez# is the "migration barrier". A migration barrier of 1 means that a slave 790a7d30681Santirez# will migrate only if there is at least 1 other working slave for its master 791a7d30681Santirez# and so forth. It usually reflects the number of slaves you want for every 792a7d30681Santirez# master in your cluster. 793a7d30681Santirez# 794a7d30681Santirez# Default is 1 (slaves migrate only if their masters remain with at least 795b8bfbf46Santirez# one slave). To disable migration just set it to a very large value. 796a7d30681Santirez# A value of 0 can be set but is useful only for debugging and dangerous 797a7d30681Santirez# in production. 798a7d30681Santirez# 799a7d30681Santirez# cluster-migration-barrier 1 800a7d30681Santirez 801c89afc8eSantirez# By default Redis Cluster nodes stop accepting queries if they detect there 802c89afc8eSantirez# is at least an hash slot uncovered (no available node is serving it). 803c89afc8eSantirez# This way if the cluster is partially down (for example a range of hash slots 804c89afc8eSantirez# are no longer covered) all the cluster becomes, eventually, unavailable. 805c89afc8eSantirez# It automatically returns available as soon as all the slots are covered again. 806c89afc8eSantirez# 807c89afc8eSantirez# However sometimes you want the subset of the cluster which is working, 808c89afc8eSantirez# to continue to accept queries for the part of the key space that is still 809c89afc8eSantirez# covered. In order to do so, just set the cluster-require-full-coverage 810c89afc8eSantirez# option to no. 811c89afc8eSantirez# 812c89afc8eSantirez# cluster-require-full-coverage yes 813c89afc8eSantirez 81407c152a7Santirez# In order to setup your cluster make sure to read the documentation 81507c152a7Santirez# available at http://redis.io web site. 81607c152a7Santirez 81735a60441Santirez################################## SLOW LOG ################################### 81835a60441Santirez 81935a60441Santirez# The Redis Slow Log is a system to log queries that exceeded a specified 82035a60441Santirez# execution time. The execution time does not include the I/O operations 82135a60441Santirez# like talking with the client, sending the reply and so forth, 82235a60441Santirez# but just the time needed to actually execute the command (this is the only 82335a60441Santirez# stage of command execution where the thread is blocked and can not serve 82435a60441Santirez# other requests in the meantime). 82535a60441Santirez# 82635a60441Santirez# You can configure the slow log with two parameters: one tells Redis 82735a60441Santirez# what is the execution time, in microseconds, to exceed in order for the 82835a60441Santirez# command to get logged, and the other parameter is the length of the 82935a60441Santirez# slow log. When a new command is logged the oldest one is removed from the 83035a60441Santirez# queue of logged commands. 83135a60441Santirez 832de32c37cSantirez# The following time is expressed in microseconds, so 1000000 is equivalent 833de32c37cSantirez# to one second. Note that a negative number disables the slow log, while 834de32c37cSantirez# a value of zero forces the logging of every command. 83535a60441Santirezslowlog-log-slower-than 10000 836de32c37cSantirez 837de32c37cSantirez# There is no limit to this length. Just be aware that it will consume memory. 838de32c37cSantirez# You can reclaim memory used by the slow log with SLOWLOG RESET. 839d3701d27Santirezslowlog-max-len 128 84035a60441Santirez 841e173f7a0Santirez################################ LATENCY MONITOR ############################## 842e173f7a0Santirez 843e173f7a0Santirez# The Redis latency monitoring subsystem samples different operations 844e173f7a0Santirez# at runtime in order to collect data related to possible sources of 845e173f7a0Santirez# latency of a Redis instance. 846e173f7a0Santirez# 847e173f7a0Santirez# Via the LATENCY command this information is available to the user that can 848e173f7a0Santirez# print graphs and obtain reports. 849e173f7a0Santirez# 850e173f7a0Santirez# The system only logs operations that were performed in a time equal or 851e173f7a0Santirez# greater than the amount of milliseconds specified via the 852e173f7a0Santirez# latency-monitor-threshold configuration directive. When its value is set 853e173f7a0Santirez# to zero, the latency monitor is turned off. 854e173f7a0Santirez# 855e173f7a0Santirez# By default latency monitoring is disabled since it is mostly not needed 856e173f7a0Santirez# if you don't have latency issues, and collecting data has a performance 857e173f7a0Santirez# impact, that while very small, can be measured under big load. Latency 8586df9001dSMariano Pérez Rodríguez# monitoring can easily be enabled at runtime using the command 859e173f7a0Santirez# "CONFIG SET latency-monitor-threshold <milliseconds>" if needed. 860e173f7a0Santirezlatency-monitor-threshold 0 861e173f7a0Santirez 8622b3eba05SMasahiko Sawada############################# EVENT NOTIFICATION ############################## 8634cdbce34Santirez 8644cdbce34Santirez# Redis can notify Pub/Sub clients about events happening in the key space. 865c90af7cdSvps# This feature is documented at http://redis.io/topics/notifications 8664cdbce34Santirez# 8674cdbce34Santirez# For instance if keyspace events notification is enabled, and a client 8684cdbce34Santirez# performs a DEL operation on key "foo" stored in the Database 0, two 8694cdbce34Santirez# messages will be published via Pub/Sub: 8704cdbce34Santirez# 8714cdbce34Santirez# PUBLISH __keyspace@0__:foo del 8724cdbce34Santirez# PUBLISH __keyevent@0__:del foo 8734cdbce34Santirez# 874fce016d3Santirez# It is possible to select the events that Redis will notify among a set 875fce016d3Santirez# of classes. Every class is identified by a single character: 876fce016d3Santirez# 877fce016d3Santirez# K Keyspace events, published with __keyspace@<db>__ prefix. 878fce016d3Santirez# E Keyevent events, published with __keyevent@<db>__ prefix. 879fce016d3Santirez# g Generic commands (non-type specific) like DEL, EXPIRE, RENAME, ... 880fce016d3Santirez# $ String commands 881fce016d3Santirez# l List commands 882fce016d3Santirez# s Set commands 883fce016d3Santirez# h Hash commands 884fce016d3Santirez# z Sorted set commands 885fce016d3Santirez# x Expired events (events generated every time a key expires) 886fce016d3Santirez# e Evicted events (events generated when a key is evicted for maxmemory) 887fce016d3Santirez# A Alias for g$lshzxe, so that the "AKE" string means all the events. 888fce016d3Santirez# 889fce016d3Santirez# The "notify-keyspace-events" takes as argument a string that is composed 890f62f00e0SBen# of zero or multiple characters. The empty string means that notifications 891f62f00e0SBen# are disabled. 892fce016d3Santirez# 893fce016d3Santirez# Example: to enable list and generic events, from the point of view of the 894fce016d3Santirez# event name, use: 895fce016d3Santirez# 896fce016d3Santirez# notify-keyspace-events Elg 897fce016d3Santirez# 898fce016d3Santirez# Example 2: to get the stream of the expired keys subscribing to channel 899fce016d3Santirez# name __keyevent@0__:expired use: 900fce016d3Santirez# 901fce016d3Santirez# notify-keyspace-events Ex 902fce016d3Santirez# 903fce016d3Santirez# By default all notifications are disabled because most users don't need 904fce016d3Santirez# this feature and the feature has some overhead. Note that if you don't 905fce016d3Santirez# specify at least one of K or E, no events will be delivered. 906fce016d3Santireznotify-keyspace-events "" 9074cdbce34Santirez 908ed9b544eSantirez############################### ADVANCED CONFIG ############################### 909ed9b544eSantirez 910d3ea4c86SPieter Noordhuis# Hashes are encoded using a memory efficient data structure when they have a 911d3ea4c86SPieter Noordhuis# small number of entries, and the biggest entry does not exceed a given 912d3ea4c86SPieter Noordhuis# threshold. These thresholds can be configured using the following directives. 913d3ea4c86SPieter Noordhuishash-max-ziplist-entries 512 914d3ea4c86SPieter Noordhuishash-max-ziplist-value 64 915b3f83f12SJeremy Zawodny 91602bb515aSMatt Stancliff# Lists are also encoded in a special way to save a lot of space. 91702bb515aSMatt Stancliff# The number of entries allowed per internal list node can be specified 91802bb515aSMatt Stancliff# as a fixed maximum size or a maximum number of elements. 91902bb515aSMatt Stancliff# For a fixed maximum size, use -5 through -1, meaning: 92002bb515aSMatt Stancliff# -5: max size: 64 Kb <-- not recommended for normal workloads 92102bb515aSMatt Stancliff# -4: max size: 32 Kb <-- not recommended 92202bb515aSMatt Stancliff# -3: max size: 16 Kb <-- probably not recommended 92302bb515aSMatt Stancliff# -2: max size: 8 Kb <-- good 92402bb515aSMatt Stancliff# -1: max size: 4 Kb <-- good 92502bb515aSMatt Stancliff# Positive numbers mean store up to _exactly_ that number of elements 92602bb515aSMatt Stancliff# per list node. 92702bb515aSMatt Stancliff# The highest performing option is usually -2 (8 Kb size) or -1 (4 Kb size), 92802bb515aSMatt Stancliff# but if your use case is unique, adjust the settings as necessary. 92902bb515aSMatt Stanclifflist-max-ziplist-size -2 93002bb515aSMatt Stancliff 93102bb515aSMatt Stancliff# Lists may also be compressed. 93202bb515aSMatt Stancliff# Compress depth is the number of quicklist ziplist nodes from *each* side of 93302bb515aSMatt Stancliff# the list to *exclude* from compression. The head and tail of the list 93402bb515aSMatt Stancliff# are always uncompressed for fast push/pop operations. Settings are: 93502bb515aSMatt Stancliff# 0: disable all list compression 93602bb515aSMatt Stancliff# 1: depth 1 means "don't start compressing until after 1 node into the list, 93702bb515aSMatt Stancliff# going from either the head or tail" 93802bb515aSMatt Stancliff# So: [head]->node->node->...->node->[tail] 93902bb515aSMatt Stancliff# [head], [tail] will always be uncompressed; inner nodes will compress. 94002bb515aSMatt Stancliff# 2: [head]->[next]->node->node->...->node->[prev]->[tail] 94102bb515aSMatt Stancliff# 2 here means: don't compress head or head->next or tail->prev or tail, 94202bb515aSMatt Stancliff# but compress all nodes between them. 94302bb515aSMatt Stancliff# 3: [head]->[next]->[next]->node->node->...->node->[prev]->[prev]->[tail] 94402bb515aSMatt Stancliff# etc. 94502bb515aSMatt Stanclifflist-compress-depth 0 9466a246b1eSantirez 9476a246b1eSantirez# Sets have a special encoding in just one case: when a set is composed 948f62f00e0SBen# of just strings that happen to be integers in radix 10 in the range 9496a246b1eSantirez# of 64 bit signed integers. 9506a246b1eSantirez# The following configuration setting sets the limit in the size of the 9516a246b1eSantirez# set in order to use this special memory saving encoding. 9526a246b1eSantirezset-max-intset-entries 512 9536a246b1eSantirez 9543ea204e1SPieter Noordhuis# Similarly to hashes and lists, sorted sets are also specially encoded in 9553ea204e1SPieter Noordhuis# order to save a lot of space. This encoding is only used when the length and 9563ea204e1SPieter Noordhuis# elements of a sorted set are below the following limits: 9573ea204e1SPieter Noordhuiszset-max-ziplist-entries 128 9583ea204e1SPieter Noordhuiszset-max-ziplist-value 64 9593ea204e1SPieter Noordhuis 960402110f9Santirez# HyperLogLog sparse representation bytes limit. The limit includes the 961402110f9Santirez# 16 bytes header. When an HyperLogLog using the sparse representation crosses 96212e435d2SKevin Menard# this limit, it is converted into the dense representation. 963402110f9Santirez# 964402110f9Santirez# A value greater than 16000 is totally useless, since at that point the 965402110f9Santirez# dense representation is more memory efficient. 966402110f9Santirez# 967402110f9Santirez# The suggested value is ~ 3000 in order to have the benefits of 968402110f9Santirez# the space efficient encoding without slowing down too much PFADD, 96912e435d2SKevin Menard# which is O(N) with the sparse encoding. The value can be raised to 970402110f9Santirez# ~ 10000 when CPU is not a concern, but space is, and the data set is 971402110f9Santirez# composed of many HyperLogLogs with cardinality in the 0 - 15000 range. 972402110f9Santirezhll-sparse-max-bytes 3000 973402110f9Santirez 9748ca3e9d1Santirez# Active rehashing uses 1 millisecond every 100 milliseconds of CPU time in 9758ca3e9d1Santirez# order to help rehashing the main Redis hash table (the one mapping top-level 97657c0cf8bSKashif Rasul# keys to values). The hash table implementation Redis uses (see dict.c) 97774da4a57Santirez# performs a lazy rehashing: the more operation you run into a hash table 97857c0cf8bSKashif Rasul# that is rehashing, the more rehashing "steps" are performed, so if the 9798ca3e9d1Santirez# server is idle the rehashing is never complete and some more memory is used 9808ca3e9d1Santirez# by the hash table. 9818ca3e9d1Santirez# 9828ca3e9d1Santirez# The default is to use this millisecond 10 times every second in order to 983f62f00e0SBen# actively rehash the main dictionaries, freeing memory when possible. 9848ca3e9d1Santirez# 9858ca3e9d1Santirez# If unsure: 9868ca3e9d1Santirez# use "activerehashing no" if you have hard latency requirements and it is 987f62f00e0SBen# not a good thing in your environment that Redis can reply from time to time 9888ca3e9d1Santirez# to queries with 2 milliseconds delay. 9898ca3e9d1Santirez# 9908ca3e9d1Santirez# use "activerehashing yes" if you don't have such hard requirements but 9918ca3e9d1Santirez# want to free memory asap when possible. 9928ca3e9d1Santirezactiverehashing yes 9938ca3e9d1Santirez 994c8a607f2Santirez# The client output buffer limits can be used to force disconnection of clients 995c8a607f2Santirez# that are not reading data from the server fast enough for some reason (a 996c8a607f2Santirez# common reason is that a Pub/Sub client can't consume messages as fast as the 997c8a607f2Santirez# publisher can produce them). 998c8a607f2Santirez# 999c8a607f2Santirez# The limit can be set differently for the three different classes of clients: 1000c8a607f2Santirez# 100156d26c23Santirez# normal -> normal clients including MONITOR clients 100256d26c23Santirez# slave -> slave clients 10036d5fa2e0SYubao Liu# pubsub -> clients subscribed to at least one pubsub channel or pattern 1004c8a607f2Santirez# 1005c8a607f2Santirez# The syntax of every client-output-buffer-limit directive is the following: 1006c8a607f2Santirez# 10073cbce4f4Santirez# client-output-buffer-limit <class> <hard limit> <soft limit> <soft seconds> 1008c8a607f2Santirez# 1009c8a607f2Santirez# A client is immediately disconnected once the hard limit is reached, or if 1010c8a607f2Santirez# the soft limit is reached and remains reached for the specified number of 1011c8a607f2Santirez# seconds (continuously). 1012c8a607f2Santirez# So for instance if the hard limit is 32 megabytes and the soft limit is 1013c8a607f2Santirez# 16 megabytes / 10 seconds, the client will get disconnected immediately 1014c8a607f2Santirez# if the size of the output buffers reach 32 megabytes, but will also get 1015c8a607f2Santirez# disconnected if the client reaches 16 megabytes and continuously overcomes 1016c8a607f2Santirez# the limit for 10 seconds. 1017c8a607f2Santirez# 1018c8a607f2Santirez# By default normal clients are not limited because they don't receive data 1019c8a607f2Santirez# without asking (in a push way), but just after a request, so only 1020c8a607f2Santirez# asynchronous clients may create a scenario where data is requested faster 1021c8a607f2Santirez# than it can read. 1022c8a607f2Santirez# 1023c8a607f2Santirez# Instead there is a default limit for pubsub and slave clients, since 1024c8a607f2Santirez# subscribers and slaves receive data in a push fashion. 1025c8a607f2Santirez# 102681144645SDavid Celis# Both the hard or the soft limit can be disabled by setting them to zero. 1027c8a607f2Santirezclient-output-buffer-limit normal 0 0 0 1028c8a607f2Santirezclient-output-buffer-limit slave 256mb 64mb 60 1029c8a607f2Santirezclient-output-buffer-limit pubsub 32mb 8mb 60 1030c8a607f2Santirez 1031f1481d4aSantirez# Redis calls an internal function to perform many background tasks, like 103274da4a57Santirez# closing connections of clients in timeout, purging expired keys that are 1033f1481d4aSantirez# never requested, and so forth. 1034f1481d4aSantirez# 103581144645SDavid Celis# Not all tasks are performed with the same frequency, but Redis checks for 1036f62f00e0SBen# tasks to perform according to the specified "hz" value. 1037f1481d4aSantirez# 1038f1481d4aSantirez# By default "hz" is set to 10. Raising the value will use more CPU when 1039f1481d4aSantirez# Redis is idle, but at the same time will make Redis more responsive when 1040f1481d4aSantirez# there are many keys expiring at the same time, and timeouts may be 1041f1481d4aSantirez# handled with more precision. 1042f1481d4aSantirez# 1043f1481d4aSantirez# The range is between 1 and 500, however a value over 100 is usually not 1044f1481d4aSantirez# a good idea. Most users should use the default of 10 and raise this up to 1045f1481d4aSantirez# 100 only in environments where very low latency is required. 1046f1481d4aSantirezhz 10 1047f1481d4aSantirez 1048d264122fSantirez# When a child rewrites the AOF file, if the following option is enabled 1049d264122fSantirez# the file will be fsync-ed every 32 MB of data generated. This is useful 1050d264122fSantirez# in order to commit the file to the disk more incrementally and avoid 1051d264122fSantirez# big latency spikes. 1052d264122fSantirezaof-rewrite-incremental-fsync yes 1053