Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add min-slaves redis options #313

Merged
merged 2 commits into from
Apr 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@
'includes' => nil,
'data_bag_name' => nil,
'data_bag_item' => nil,
'data_bag_key' => nil
'data_bag_key' => nil,
'minslavestowrite' => nil,
'minslavesmaxlag' => nil
}

# The default for this is set inside of the "install" recipe. This is due to the way deep merge handles arrays
Expand Down
4 changes: 3 additions & 1 deletion providers/configure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,9 @@ def configure
clusterenabled: current['clusterenabled'],
clusterconfigfile: current['clusterconfigfile'],
clusternodetimeout: current['clusternodetimeout'],
includes: current['includes']
includes: current['includes'],
minslavestowrite: current['minslavestowrite'],
minslavesmaxlag: current['minslavesmaxlag']
)
not_if { ::File.exist?("#{current['configdir']}/#{server_name}.conf.breadcrumb") }
end
Expand Down
57 changes: 57 additions & 0 deletions templates/default/redis.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,63 @@ repl-backlog-ttl <%= @replbacklogttl %>
# By default the priority is 100.
slave-priority <%= @slavepriority %>

<% if @version[:major].to_i >= 3 %>
# It is possible for a master to stop accepting writes if there are less than
# N slaves connected, having a lag less or equal than M seconds.
#
# The N slaves need to be in "online" state.
#
# The lag in seconds, that must be <= the specified value, is calculated from
# the last ping received from the slave, that is usually sent every second.
#
# This option does not GUARANTEE that N replicas will accept the write, but
# will limit the window of exposure for lost writes in case not enough slaves
# are available, to the specified number of seconds.
#
# For example to require at least 3 slaves with a lag <= 10 seconds use:
#
# min-slaves-to-write 3
# min-slaves-max-lag 10
#
# Setting one or the other to 0 disables the feature.
#
# By default min-slaves-to-write is set to 0 (feature disabled) and
# min-slaves-max-lag is set to 10.
<%= "min-slaves-to-write #{@minslavestowrite}" unless @minslavestowrite.nil? %>
<%= "min-slaves-max-lag #{@minslavesmaxlag}" unless @minslavesmaxlag.nil? %>
<% end %>

<% if @version[:major].to_i >= 4 %>
# A Redis master is able to list the address and port of the attached
# slaves in different ways. For example the "INFO replication" section
# offers this information, which is used, among other tools, by
# Redis Sentinel in order to discover slave instances.
# Another place where this info is available is in the output of the
# "ROLE" command of a masteer.
#
# The listed IP and address normally reported by a slave is obtained
# in the following way:
#
# IP: The address is auto detected by checking the peer address
# of the socket used by the slave to connect with the master.
#
# Port: The port is communicated by the slave during the replication
# handshake, and is normally the port that the slave is using to
# list for connections.
#
# However when port forwarding or Network Address Translation (NAT) is
# used, the slave may be actually reachable via different IP and port
# pairs. The following two options can be used by a slave in order to
# report to its master a specific set of IP and port, so that both INFO
# and ROLE will report those values.
#
# There is no need to use both the options if you need to override just
# the port or the IP address.
#
# slave-announce-ip 5.5.5.5
# slave-announce-port 1234
<% end %>

################################## SECURITY ###################################

# Require clients to issue AUTH <PASSWORD> before processing any other
Expand Down