From 7b7d8fc8680c4594723eaa57d80a95a1d84b58fc Mon Sep 17 00:00:00 2001 From: popsikle Date: Mon, 19 Oct 2015 15:58:17 -0400 Subject: [PATCH] enable diskless replication configuration --- README.md | 2 + attributes/default.rb | 2 + providers/configure.rb | 4 +- templates/default/redis.conf.erb | 65 ++++++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0480af83..3991cdfc 100644 --- a/README.md +++ b/README.md @@ -343,6 +343,8 @@ Available options and their defaults 'masterauth' => nil, 'slaveservestaledata' => 'yes', 'slavereadonly' => 'yes', +'repldisklesssync' => 'no', # Requires redis 2.8.18+ +'repldisklesssyncdelay' => '5', # Requires redis 2.8.18+ 'replpingslaveperiod' => '10', 'repltimeout' => '60', 'repldisabletcpnodelay => 'no', diff --git a/attributes/default.rb b/attributes/default.rb index 1d287bbd..8bdacea9 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -114,6 +114,8 @@ 'masterauth' => nil, 'slaveservestaledata' => 'yes', 'slavereadonly' => 'yes', + 'repldisklesssync' => 'no', + 'repldisklesssyncdelay' => '5', 'replpingslaveperiod' => '10', 'repltimeout' => '60', 'repldisabletcpnodelay' => 'no', diff --git a/providers/configure.rb b/providers/configure.rb index 5a4e319c..5ab75e9b 100644 --- a/providers/configure.rb +++ b/providers/configure.rb @@ -294,7 +294,9 @@ def configure clusternodetimeout: current['clusternodetimeout'], includes: current['includes'], minslavestowrite: current['minslavestowrite'], - minslavesmaxlag: current['minslavesmaxlag'] + minslavesmaxlag: current['minslavesmaxlag'], + repldisklesssync: current['repldisklesssync'], + repldisklesssyncdelay: current['repldisklesssyncdelay'] ) not_if { ::File.exist?("#{current['configdir']}/#{server_name}.conf.breadcrumb") } end diff --git a/templates/default/redis.conf.erb b/templates/default/redis.conf.erb index 5718dc4f..2f906edc 100644 --- a/templates/default/redis.conf.erb +++ b/templates/default/redis.conf.erb @@ -250,6 +250,71 @@ dir <%=@datadir%> # but to INFO and SLAVEOF. # slave-serve-stale-data <%=@slaveservestaledata%> +<% if @version[:major].to_i == 2 && @version[:minor].to_i >= 6 || @version[:major].to_i >= 3 -%> +<% ######## Redis 2.6 and higher ######## -%> + +# You can configure a slave instance to accept writes or not. Writing against +# a slave instance may be useful to store some ephemeral data (because data +# written on a slave will be easily deleted after resync with the master) but +# may also cause problems if clients are writing to it because of a +# misconfiguration. +# +# Since Redis 2.6 by default slaves are read-only. +# +# Note: read only slaves are not designed to be exposed to untrusted clients +# on the internet. It's just a protection layer against misuse of the instance. +# Still a read only slave exports by default all the administrative commands +# such as CONFIG, DEBUG, and so forth. To a limited extent you can improve +# security of read only slaves using 'rename-command' to shadow all the +# administrative / dangerous commands. +slave-read-only <%=@slavereadonly%> +<% end %> + +<% if (@version[:major].to_i == 2 && @version[:minor].to_i == 8 && @version[:tiny].to_i >= 18) or (@version[:major].to_i == 2 && @version[:minor].to_i >= 9) or @version[:major].to_i >= 3 -%> +<% ######## Redis 2.8.18 and higher ######## -%> +# Replication SYNC strategy: disk or socket. +# +# ------------------------------------------------------- +# WARNING: DISKLESS REPLICATION IS EXPERIMENTAL CURRENTLY +# ------------------------------------------------------- +# +# New slaves and reconnecting slaves that are not able to continue the replication +# process just receiving differences, need to do what is called a "full +# synchronization". An RDB file is transmitted from the master to the slaves. +# The transmission can happen in two different ways: +# +# 1) Disk-backed: The Redis master creates a new process that writes the RDB +# file on disk. Later the file is transferred by the parent +# process to the slaves incrementally. +# 2) Diskless: The Redis master creates a new process that directly writes the +# RDB file to slave sockets, without touching the disk at all. +# +# With disk-backed replication, while the RDB file is generated, more slaves +# can be queued and served with the RDB file as soon as the current child producing +# the RDB file finishes its work. With diskless replication instead once +# the transfer starts, new slaves arriving will be queued and a new transfer +# will start when the current one terminates. +# +# When diskless replication is used, the master waits a configurable amount of +# time (in seconds) before starting the transfer in the hope that multiple slaves +# will arrive and the transfer can be parallelized. +# +# With slow disks and fast (large bandwidth) networks, diskless replication +# works better. +repl-diskless-sync <%=@repldisklesssync%> + +# When diskless replication is enabled, it is possible to configure the delay +# the server waits in order to spawn the child that transfers the RDB via socket +# to the slaves. +# +# This is important since once the transfer starts, it is not possible to serve +# new slaves arriving, that will be queued for the next RDB transfer, so the server +# waits a delay in order to let more slaves arrive. +# +# The delay is specified in seconds, and by default is 5 seconds. To disable +# it entirely just set it to 0 seconds and the transfer will start ASAP. +repl-diskless-sync-delay <%=@repldisklesssyncdelay%> +<% end %> <% if @version[:major].to_i == 2 && @version[:minor].to_i >= 6 || @version[:major].to_i == 3 %> # You can configure a slave instance to accept writes or not. Writing against