Skip to content

Commit

Permalink
Add repl-backlog-size, repl-backlog-ttl, and aof-load-truncated options
Browse files Browse the repository at this point in the history
  • Loading branch information
msaffitz committed Jun 11, 2016
1 parent 6f7c909 commit 0431533
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 17 deletions.
3 changes: 3 additions & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@
'replpingslaveperiod' => '10',
'repltimeout' => '60',
'repldisabletcpnodelay' => 'no',
'replbacklogsize' => '1mb',
'replbacklogttl' => 3600,
'slavepriority' => '100',
'requirepass' => nil,
'rename_commands' => nil,
Expand All @@ -119,6 +121,7 @@
'noappendfsynconrewrite' => 'no',
'aofrewritepercentage' => '100',
'aofrewriteminsize' => '64mb',
'aofloadtruncated' => 'yes',
'luatimelimit' => '5000',
'slowloglogslowerthan' => '10000',
'slowlogmaxlen' => '1024',
Expand Down
3 changes: 3 additions & 0 deletions providers/configure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ def configure
:replpingslaveperiod => current['replpingslaveperiod'],
:repltimeout => current['repltimeout'],
:repldisabletcpnodelay => current['repldisabletcpnodelay'],
:replbacklogsize => current['replbacklogsize'],
:replbacklogttl => current['replbacklogttl'],
:slavepriority => current['slavepriority'],
:requirepass => current['requirepass'],
:rename_commands => current['rename_commands'],
Expand All @@ -229,6 +231,7 @@ def configure
:noappendfsynconrewrite => current['noappendfsynconrewrite'],
:aofrewritepercentage => current['aofrewritepercentage'] ,
:aofrewriteminsize => current['aofrewriteminsize'],
:aofloadtruncated => current['aofloadtruncated'],
:luatimelimit => current['luatimelimit'],
:slowloglogslowerthan => current['slowloglogslowerthan'],
:slowlogmaxlen => current['slowlogmaxlen'],
Expand Down
95 changes: 78 additions & 17 deletions templates/default/redis.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,18 @@ dir <%=@datadir%>
################################# REPLICATION #################################

# Master-Slave replication. Use slaveof to make a Redis instance a copy of
# another Redis server. Note that the configuration is local to the slave
# so for example it is possible to configure the slave to save the DB with a
# different interval, or to listen to another port, and so on.
# another Redis server. A few things to understand ASAP about Redis replication.
#
# 1) Redis replication is asynchronous, but you can configure a master to
# stop accepting writes if it appears to be not connected with at least
# a given number of slaves.
# 2) Redis slaves are able to perform a partial resynchronization with the
# master if the replication link is lost for a relatively small amount of
# time. You may want to configure the replication backlog size (see the next
# sections of this file) with a sensible value depending on your needs.
# 3) Replication is automatic and does not need user intervention. After a
# network partition slaves automatically try to reconnect to masters
# and resynchronize with them.
#
# slaveof <ip> <port>
<%= "slaveof #{@slaveof['address']} #{@slaveof['port']}" unless @slaveof.nil? %>
Expand Down Expand Up @@ -266,6 +275,28 @@ repl-timeout <%=@repltimeout%>
repl-disable-tcp-nodelay <%= @repldisabletcpnodelay %>
<% end %>

# Set the replication backlog size. The backlog is a buffer that accumulates
# slave data when slaves are disconnected for some time, so that when a slave
# wants to reconnect again, often a full resync is not needed, but a partial
# resync is enough, just passing the portion of data the slave missed while
# disconnected.
#
# The bigger the replication backlog, the longer the time the slave can be
# disconnected and later be able to perform a partial resynchronization.
#
# The backlog is only allocated once there is at least a slave connected.
#
repl-backlog-size <%= @replbacklogsize %>

# After a master has no longer connected slaves for some time, the backlog
# will be freed. The following option configures the amount of seconds that
# need to elapse, starting from the time the last slave disconnected, for
# the backlog buffer to be freed.
#
# A value of 0 means to never release the backlog.
#
repl-backlog-ttl <%= @replbacklogttl %>

# The slave priority is an integer number published by Redis in the INFO output.
# It is used by Redis Sentinel in order to select a slave to promote into a
# master if the master is no longer working correctly.
Expand Down Expand Up @@ -390,21 +421,23 @@ slave-priority <%= @slavepriority %>

############################## APPEND ONLY MODE ###############################

# By default Redis asynchronously dumps the dataset on disk. If you can live
# with the idea that the latest records will be lost if something like a crash
# happens this is the preferred way to run Redis. If instead you care a lot
# about your data and don't want to that a single record can get lost you should
# enable the append only mode: when this mode is enabled Redis will append
# every write operation received in the file appendonly.aof. This file will
# be read on startup in order to rebuild the full dataset in memory.
# By default Redis asynchronously dumps the dataset on disk. This mode is
# good enough in many applications, but an issue with the Redis process or
# a power outage may result into a few minutes of writes lost (depending on
# the configured save points).
#
# The Append Only File is an alternative persistence mode that provides
# much better durability. For instance using the default data fsync policy
# (see later in the config file) Redis can lose just one second of writes in a
# dramatic event like a server power outage, or a single write if something
# wrong with the Redis process itself happens, but the operating system is
# still running correctly.
#
# Note that you can have both the async dumps and the append only file if you
# like (you have to comment the "save" statements above to disable the dumps).
# Still if append only mode is enabled Redis will load the data from the
# log file at startup ignoring the dump.rdb file.
# AOF and RDB persistence can be enabled at the same time without problems.
# If the AOF is enabled on startup Redis will load the AOF, that is the file
# with the better durability guarantees.
#
# IMPORTANT: Check the BGREWRITEAOF to check how to rewrite the append
# log file in background when it gets too big.
# Please check http://redis.io/topics/persistence for more information.

<%if (@backuptype == 'aof' || @backuptype == 'both')%>
appendonly yes
Expand All @@ -426,7 +459,7 @@ appendfilename appendonly-<%=@name%>.aof
#
# no: don't fsync, just let the OS flush the data when it wants. Faster.
# always: fsync after every write to the append only log. Slow, Safest.
# everysec: fsync only if one second passed since the last fsync. Compromise.
# everysec: fsync only one time every second. Compromise.
#
# The default is "everysec", as that's usually the right compromise between
# speed and data safety. It's up to you to understand if you can relax this to
Expand All @@ -436,6 +469,9 @@ appendfilename appendonly-<%=@name%>.aof
# or on the contrary, use "always" that's very slow but a bit safer than
# everysec.
#
# More details please check the following article:
# http://antirez.com/post/redis-persistence-demystified.html
#
# If unsure, use "everysec".

# appendfsync always
Expand All @@ -461,6 +497,7 @@ appendfilename appendonly-<%=@name%>.aof
#
# If you have latency problems turn this to "yes". Otherwise leave it as
# "no" that is the safest pick from the point of view of durability.

no-appendfsync-on-rewrite <%=@noappendfsynconrewrite%>

# Automatic rewrite of the append only file.
Expand All @@ -483,6 +520,30 @@ no-appendfsync-on-rewrite <%=@noappendfsynconrewrite%>
auto-aof-rewrite-percentage <%=@aofrewritepercentage%>
auto-aof-rewrite-min-size <%=@aofrewriteminsize%>

# An AOF file may be found to be truncated at the end during the Redis
# startup process, when the AOF data gets loaded back into memory.
# This may happen when the system where Redis is running
# crashes, especially when an ext4 filesystem is mounted without the
# data=ordered option (however this can't happen when Redis itself
# crashes or aborts but the operating system still works correctly).
#
# Redis can either exit with an error when this happens, or load as much
# data as possible (the default now) and start if the AOF file is found
# to be truncated at the end. The following option controls this behavior.
#
# If aof-load-truncated is set to yes, a truncated AOF file is loaded and
# the Redis server starts emitting a log to inform the user of the event.
# Otherwise if the option is set to no, the server aborts with an error
# and refuses to start. When the option is set to no, the user requires
# to fix the AOF file using the "redis-check-aof" utility before to restart
# the server.
#
# Note that if the AOF file will be found to be corrupted in the middle
# the server will still exit with an error. This option only applies when
# Redis will try to read more data from the AOF file but not enough bytes
# will be found.
aof-load-truncated <%= @aofloadtruncated %>

################################ LUA SCRIPTING ###############################

# Max execution time of a Lua script in milliseconds.
Expand Down

0 comments on commit 0431533

Please sign in to comment.