Browse Source

Adding support for a second instance !

Redis cluster needs 6 hosts for work ... it's a lot.
To trick him each node can be Master and slave for another node.

;)
Philippe Caseiro 1 year ago
parent
commit
2031ec7d64
5 changed files with 1007 additions and 23 deletions
  1. 3
    0
      creolefuncs/redis.py
  2. 135
    12
      dicos/90_redis.xml
  3. 26
    8
      postservice/90-redis-init
  4. 9
    3
      tmpl/redis-cluster.conf
  5. 834
    0
      tmpl/redis-slave.conf

+ 3
- 0
creolefuncs/redis.py View File

@@ -6,3 +6,6 @@
6 6
 #
7 7
 def add(num1, num2):
8 8
     return str(int(num1) + int(num2)).decode("utf-8")
9
+
10
+def intAdd(num1, num2):
11
+    return int(num1) + int(num2)

+ 135
- 12
dicos/90_redis.xml View File

@@ -3,12 +3,16 @@
3 3
     <files>
4 4
         <!-- System configuration -->
5 5
         <file filelist='redis' name='/etc/redis/redis.conf' mkdir='True' rm='True'/>
6
+        <file filelist='redisSlave' name='/etc/redis/redis-slave.conf' mkdir='True' rm='True'/>
6 7
         <file filelist='redisCl' name='/etc/redis/cluster.conf' source='redis-cluster.conf' mkdir='True' rm='True'/>
7 8
         <service servicelist="svredis">redis-server</service>
9
+        <service servicelist="svredisSlave">redis2-server</service>
8 10
         <service_access service='redis-server'>
9 11
             <port service_accesslist='saRedis' protocol='tcp' port_type='SymLinkOption'>redisPort</port>
10 12
             <port service_accesslist='saRedis' protocol='tcp' port_type='SymLinkOption'>redisClPort</port>
11
-			<tcpwrapper>redis-server</tcpwrapper>
13
+            <port service_accesslist='saRedisSlave' protocol='tcp' port_type='SymLinkOption'>redisPortSlave</port>
14
+            <port service_accesslist='saRedisSlave' protocol='tcp' port_type='SymLinkOption'>redisClPortSlave</port>
15
+            <tcpwrapper>redis-server</tcpwrapper>
12 16
         </service_access>
13 17
         <service_restriction service='redis-server'>
14 18
                <ip interface='auto' netmask='rdClmask' netmask_type='SymLinkOption' ip_type='SymLinkOption'>rdClIP</ip>
@@ -24,10 +28,15 @@
24 28
             <variable name='redisMode' type='string' description="Mode d'utilisation de Redis">
25 29
                 <value>Local</value>
26 30
             </variable>
27
-            <variable name='redisPort' type='string' description="Port d'écoute du service Redis">
31
+            <variable name='redisSlaveInstance' type='oui/non' description="Voulez-vous lancer une instance esclave Redis sur ce serveur ?">
32
+                <value>non</value>
33
+            </variable>
34
+            <!-- Instance Principale-->
35
+            <variable name='redisInstanceName' type='string' description="Nom de l'instance secondaire"/>
36
+            <variable name='redisPort' type='number' description="Port d'écoute du service Redis">
28 37
                 <value>6379</value>
29 38
             </variable>
30
-            <variable name='redisClPort' type='string' description="Port d'écoute du service Cluster Redis"/>
39
+            <variable name='redisClPort' type='number' description="Port d'écoute du service Cluster Redis"/>
31 40
             <variable name='redisMaxMemory' type='number' description="Quantité de mémoire utilisable par Redis en Mo">
32 41
                 <value>512</value>
33 42
             </variable>
@@ -37,6 +46,23 @@
37 46
             <variable name='redisTCPKeepAlive' type='number' description="Intervalle entre le dernier envoi de paquet TCP et la réponse ACK (en secondes)">
38 47
                 <value>60</value>
39 48
             </variable>
49
+            <!-- Instance Secondaire -->
50
+            <variable name='redisSlaveInstanceName' type='string' description="Nom de l'instance secondaire"/>
51
+            <variable name='redisSlaveInstanceMaster' type='string' description="Nom du noeud a répliquer sur l'instance secondaire"/>
52
+            <variable name='redisPortSlave' type='number' description="Port d'écoute du service Redis">
53
+                <value>6379</value>
54
+            </variable>
55
+            <variable name='redisClPortSlave' type='number' description="Port d'écoute du service Cluster Redis"/>
56
+            <variable name='redisMaxMemorySlave' type='number' description="Quantité de mémoire utilisable par Redis en Mo">
57
+                <value>512</value>
58
+            </variable>
59
+            <variable name='redisMemoryPolicySlave' type='string' description='Méthode de libération de mémoire lorsque la maximum est atteint '>
60
+                <value>noeviction</value>
61
+            </variable>
62
+            <variable name='redisTCPKeepAliveSlave' type='number' description="Intervalle entre le dernier envoi de paquet TCP et la réponse ACK (en secondes)">
63
+                <value>60</value>
64
+            </variable>
65
+            <!-- Autorisations d'accès -->
40 66
             <variable name='rdClIP' type='ip' description="Adresse IP réseau autorisée a utiliser le service Redis" multi='True'/>
41 67
             <variable name='rdClmask' type='ip' description="Masque de sous réseau"/>
42 68
 
@@ -46,11 +72,23 @@
46 72
             </variable>
47 73
             <variable name='rdClMember' type='string' description="Nom du noeud" multi='True'/>
48 74
             <variable name='rdClMemberIP' type='ip' description="Adresse IP du noeud" multi='True'/>
49
-            <variable name='rdClMemberPort' type='number' description="Port d'écoute du noeud" multi='True'/>
75
+            <variable name='rdClMemberPort' type='number' description="Port d'écoute du noeud" multi='True'>
76
+                <value>6379</value>
77
+            </variable>
50 78
             <variable name='rdClMemberRole' type='ip' description="Rôle du membre"/>
51
-            <variable name='rdClMemberMaster' type='string' description="Noeud source des données pour ce membre"/>
79
+            <variable name='rdClMemberMaster' type='string' description="Nom du neoud a répliquer sur ce membre"/>
80
+            <variable name='rdClMemberAsSlave' type='oui/non' description="Ce noeud dispose de 2 instances ?">
81
+                <value>non</value>
82
+            </variable>
83
+            <variable name='rdClMemberSlaveName' type='string' description="Nom de l'instance secondaire"/>
84
+            <variable name='rdClMemberSlaveIP' type='ip' description="IP de l'instance secondaire"/>
85
+            <variable name='rdClMemberSlavePort' type='number' description="Port de l'instance secondaire"/>
86
+            <variable name='rdClMemberSlaveRole' type='string' description="Rôle de l'instance secondaire" hidden='True'/>
87
+            <variable name='rdClMemberSlaveMaster' type='string' description="Noeud du noeud répliquer sur cette instance secondaire"/>
52 88
         </family>
53 89
         <separators>
90
+            <separator name='redisInstanceName'>Instance Principale</separator>
91
+            <separator name='redisSlaveInstanceName'>Instance Secondaire</separator>
54 92
             <separator name='rdClIP'>Autorisation d'accès au service Redis</separator>
55 93
             <separator name='redisRole'>Grappe Redis</separator>
56 94
             <separator name='rdClMemberIP'>Serveurs membres de la grappe Redis</separator>
@@ -61,24 +99,56 @@
61 99
             <param>non</param>
62 100
             <target type='filelist'>redis</target>
63 101
             <target type='family'>Redis</target>
64
-            <target type='service_accesslist'>saredis</target>
102
+            <target type='service_accesslist'>saRedis</target>
103
+            <target type='service_accesslist'>saRedisSlave</target>
65 104
             <target type='servicelist'>svredis</target>
66 105
         </condition>
67 106
 
107
+        <condition name='disabled_if_in' source='redisSlaveInstance'>
108
+            <param>non</param>
109
+            <target type='filelist'>redisSlave</target>
110
+            <target type='servicelist'>svredisSlave</target>
111
+            <target type='service_accesslist'>saRedisSlave</target>
112
+            <target type='variable'>redisSlaveInstanceName</target>
113
+            <target type='variable'>redisSlaveInstanceMaster</target>
114
+            <target type='variable'>redisPortSlave</target>
115
+            <target type='variable'>redisClPortSlave</target>
116
+            <target type='variable'>redisMemoryPolicySlave</target>
117
+            <target type='variable'>redisTCPKeepAliveSlave</target>
118
+            <target type='variable'>redisMaxMemorySlave</target>
119
+        </condition>
120
+
121
+        <condition name='disabled_if_in' source='rdClMemberAsSlave'>
122
+            <param>non</param>
123
+            <target type='variable'>rdClMemberSlaveName</target>
124
+            <target type='variable'>rdClMemberSlaveIP</target>
125
+            <target type='variable'>rdClMemberSlavePort</target>
126
+            <target type='variable'>rdClMemberSlaveRole</target>
127
+            <target type='variable'>rdClMemberSlaveMaster</target>
128
+        </condition>
129
+
68 130
         <condition name='disabled_if_in' source='redisMode'>
69 131
             <param>Local</param>
70 132
             <target type='variable'>redisRole</target>
133
+            <target type='variable'>redisSlaveInstance</target>
71 134
             <target type='filelist'>redisCl</target>
135
+            <target type='variable'>redisClPort</target>
72 136
         </condition>
73 137
 
74 138
         <condition name='disabled_if_in' source='redisRole'>
75 139
             <param>Node</param>
76 140
             <target type='filelist'>redisCl</target>
77
-			<target type='variable'>rdClMember</target>
78
-			<target type='variable'>rdClMemberIP</target>
79
-			<target type='variable'>rdClMemberPort</target>
80
-			<target type='variable'>rdClMemberRole</target>
81
-			<target type='variable'>rdClMemberMaster</target>
141
+            <target type='variable'>rdClMember</target>
142
+            <target type='variable'>rdClMemberIP</target>
143
+            <target type='variable'>rdClMemberPort</target>
144
+            <target type='variable'>rdClMemberRole</target>
145
+            <target type='variable'>rdClMemberMaster</target>
146
+            <target type='variable'>rdClMemberAsSlave</target>
147
+            <target type='variable'>rdClMemberSlaveName</target>
148
+            <target type='variable'>rdClMemberSlaveIP</target>
149
+            <target type='variable'>rdClMemberSlavePort</target>
150
+            <target type='variable'>rdClMemberSlaveRole</target>
151
+            <target type='variable'>rdClMemberSlaveMaster</target>
82 152
         </condition>
83 153
 
84 154
         <condition name='disabled_if_in' source='rdClMemberRole'>
@@ -95,6 +165,12 @@
95 165
             <slave>rdClMemberPort</slave>
96 166
             <slave>rdClMemberRole</slave>
97 167
             <slave>rdClMemberMaster</slave>
168
+            <slave>rdClMemberAsSlave</slave>
169
+            <slave>rdClMemberSlaveName</slave>
170
+            <slave>rdClMemberSlaveIP</slave>
171
+            <slave>rdClMemberSlavePort</slave>
172
+            <slave>rdClMemberSlaveRole</slave>
173
+            <slave>rdClMemberSlaveMaster</slave>
98 174
         </group>
99 175
         <check name="valid_enum" target="redisRole">
100 176
             <param>['Leader','Node']</param>
@@ -108,10 +184,57 @@
108 184
         <check name="valid_enum" target="redisMemoryPolicy">
109 185
             <param>['noeviction', 'allkeys-lru','volatile-lru','volatile-random', 'allkeys-random','volatile-ttl']</param>
110 186
         </check>
111
-        <fill name='add' target='redisClPort'>
187
+
188
+        <fill name='concat' target="redisSlaveInstanceName">
189
+            <param type='eole' name='valeur1'>redisInstanceName</param>
190
+            <param name='valeur2'>Second</param>
191
+        </fill>
192
+
193
+        <fill name='concat' target="rdClMemberSlaveName">
194
+            <param type='eole' name='valeur1'>rdClMember</param>
195
+            <param name='valeur2'>Second</param>
196
+        </fill>
197
+
198
+        <fill name='calc_val' target="rdClMemberSlaveIP">
199
+            <param type='eole' name='valeur'>rdClMemberIP</param>
200
+        </fill>
201
+        <auto name='calc_val' target='rdClMemberSlaveRole'>
202
+            <param>slave</param>
203
+        </auto>
204
+
205
+        <fill name='intAdd' target='rdClMemberSlavePort'>
206
+            <param type='eole' name='num1'>rdClMemberPort</param>
207
+            <param name='num2'>2000</param>
208
+        </fill>
209
+
210
+        <fill name='calc_val' target='redisInstanceName'>
211
+            <param type='eole' name='valeur'>nom_machine</param>
212
+        </fill>
213
+
214
+        <fill name='intAdd' target='redisClPort'>
112 215
             <param type='eole' name='num1'>redisPort</param>
113 216
             <param name='num2'>10000</param>
114 217
         </fill>
218
+
219
+        <fill name='intAdd' target='redisPortSlave'>
220
+            <param type='eole' name='num1'>redisPort</param>
221
+            <param name='num2'>2000</param>
222
+        </fill>
223
+
224
+        <fill name='intAdd' target='redisClPortSlave'>
225
+            <param type='eole' name='num1'>redisPortSlave</param>
226
+            <param name='num2'>10000</param>
227
+        </fill>
228
+        <fill name='calc_val' target='redisMaxMemorySlave'>
229
+            <param type='eole' name='valeur'>redisMaxMemory</param>
230
+        </fill>
231
+        <fill name='calc_val' target='redisMemoryPolicySlave'>
232
+            <param type='eole' name='valeur'>redisMemoryPolicy</param>
233
+        </fill>
234
+        <fill name='calc_val' target='redisTCPKeepAliveSlave'>
235
+            <param type='eole' name='valeur'>redisTCPKeepAlive</param>
236
+        </fill>
237
+
115 238
     </constraints>
116 239
     <help>
117 240
         <variable name='activer_redis'>Activer le service de cache Redis</variable>

+ 26
- 8
postservice/90-redis-init View File

@@ -52,8 +52,17 @@ function getNodeID()
52 52
     else
53 53
         searchCmd="awk '/${3}:${4}@/ { print \$1  }'"
54 54
     fi
55
-    redisRun $1 $2 cluster nodes | eval ${searchCmd}
56
-    return ${?}
55
+	result=$(redisRun $1 $2 cluster nodes | eval ${searchCmd})
56
+	rcode=${?}
57
+
58
+	if [[ -z ${result} ]]
59
+	then
60
+		searchCmd="awk '/${3}:${4}@/ { print \$1   }'"
61
+		result=$(redisRun $1 $2 cluster nodes | eval ${searchCmd})
62
+		rcode=${?}
63
+	fi
64
+	echo ${result}
65
+	return ${rcode}
57 66
 }
58 67
 
59 68
 function redisClusterForgetAll()
@@ -112,10 +121,13 @@ declare -A PORTS
112 121
 declare -A ROLES
113 122
 declare -A MASTERS
114 123
 declare -A NIDS
124
+declare LeaderIP
125
+declare LeaderPort
115 126
 index=0
116 127
 
117 128
 while read line
118 129
 do
130
+	[[ ${line} =~ ^# ]] && continue
119 131
 	line=${line//::/:none:}
120 132
 	li=(${line//:/ })
121 133
 
@@ -124,7 +136,13 @@ do
124 136
     port=${li[2]}
125 137
     role=${li[3]}
126 138
     master=${li[4]}
139
+	ntype=${li[5]}
127 140
 
141
+	if [[ ${ntype} == "Leader" ]] 
142
+	then
143
+		LeaderIP=${ip}
144
+		LeaderPort=${port}
145
+	fi
128 146
     NAMES+=(${name})
129 147
     IPADDRS+=([${name}]=${ip})
130 148
 	PORTS+=([${name}]=${port})
@@ -133,12 +151,12 @@ do
133 151
 done < ${CONF}
134 152
 
135 153
 # If the cluster is "ok" don't do anything
136
-st=$(redisClusterIsOK ${IPADDRS["Leader"]} ${PORTS["Leader"]})
154
+st=$(redisClusterIsOK ${LeaderIP} ${LeaderPort})
137 155
 #[[ ${?} -eq 0 ]] && exit 0
138 156
 
139 157
 if [[ ${1} == "forget" ]]
140 158
 then
141
-    redisClusterForgetAll ${IPADDRS["Leader"]} ${PORTS["Leader"]}
159
+    redisClusterForgetAll ${LeaderIP} ${LeaderPort}
142 160
     exit ${?}
143 161
 fi
144 162
 
@@ -160,7 +178,7 @@ for node in ${NAMES[@]}
160 178
 do
161 179
     try=3
162 180
     scmd="awk '/${IPADDRS[$node]}:${PORTS[${node}]}/ {print \$8}'"
163
-    while [[ $(redisRun ${IPADDRS['Leader']} ${PORTS['Leader']} "cluster nodes" | eval ${scmd}) != "connected" ]]
181
+    while [[ $(redisRun ${LeaderIP} ${LeaderPort} "cluster nodes" | eval ${scmd}) != "connected" ]]
164 182
     do
165 183
         sleep 1
166 184
         try=$((try-1))
@@ -196,7 +214,7 @@ echo " * Configuring replication."
196 214
 NIDS+=()
197 215
 for node in ${NAMES[@]}
198 216
 do
199
-   NIDS+=([${node}]=$(getNodeID ${IPADDRS["Leader"]} ${PORTS["Leader"]} ${IPADDRS[${node}]} ${PORTS[${node}]}))
217
+   NIDS+=([${node}]=$(getNodeID ${LeaderIP} ${LeaderPort} ${IPADDRS[${node}]} ${PORTS[${node}]}))
200 218
 done
201 219
 
202 220
 for node in ${NAMES[@]}
@@ -206,12 +224,12 @@ do
206 224
     redisAddReplica ${IPADDRS[${node}]} ${PORTS[${node}]} ${NIDS[${MASTERS[${node}]}]}
207 225
 done
208 226
 
209
-sleep 2
227
+sleep 5
210 228
 
211 229
 echo
212 230
 echo "Cluster status :"
213 231
 echo
214
-redisRun ${IPADDRS["Leader"]} ${PORTS["Leader"]} cluster info
232
+redisRun ${LeaderIP} ${LeaderPort} cluster info
215 233
 echo
216 234
 
217 235
 

+ 9
- 3
tmpl/redis-cluster.conf View File

@@ -1,10 +1,16 @@
1 1
 %if %%getVar('activer_redis','non') == 'oui' and %%getVar('redisRole','Node') == 'Leader'
2
-Leader:%%adresse_ip_eth0:%%{redisPort}:master::
2
+%%redisInstanceName:%%adresse_ip_eth0:%%{redisPort}:master::Leader:
3
+   %if %%getVar('redisSlaveInstance','non') == 'oui'
4
+%%redisSlaveInstanceName:%%adresse_ip_eth0:%%{redisPortSlave}:slave:%%{redisSlaveInstanceMaster}:Node:
5
+	%end if
3 6
    %for %%node in %%getVar('rdClMember',[])
4 7
       %if %%node.rdClMemberRole == 'master'
5
-%%{node}:%%{node.rdClMemberIP}:%%{node.rdClMemberPort}:%%{node.rdClMemberRole}::
8
+%%{node}:%%{node.rdClMemberIP}:%%{node.rdClMemberPort}:%%{node.rdClMemberRole}::Node:
6 9
       %else
7
-%%{node}:%%{node.rdClMemberIP}:%%{node.rdClMemberPort}:%%{node.rdClMemberRole}:%%{node.rdClMemberMaster}:
10
+%%{node}:%%{node.rdClMemberIP}:%%{node.rdClMemberPort}:%%{node.rdClMemberRole}:%%{node.rdClMemberMaster}:Node:
11
+      %end if
12
+      %if %%node.rdClMemberAsSlave == 'oui'
13
+%%{node.rdClMemberSlaveName}:%%{node.rdClMemberSlaveIP}:%%{node.rdClMemberSlavePort}:%%{node.rdClMemberSlaveRole}:%%{node.rdClMemberSlaveMaster}:Node:
8 14
       %end if
9 15
    %end for
10 16
 %end if

+ 834
- 0
tmpl/redis-slave.conf View File

@@ -0,0 +1,834 @@
1
+# Redis configuration file example.
2
+#
3
+# Note that in order to read the configuration file, Redis must be
4
+# started with the file path as first argument:
5
+#
6
+# ./redis-server /path/to/redis.conf
7
+
8
+# Note on units: when memory size is needed, it is possible to specify
9
+# it in the usual form of 1k 5GB 4M and so forth:
10
+#
11
+# 1k => 1000 bytes
12
+# 1kb => 1024 bytes
13
+# 1m => 1000000 bytes
14
+# 1mb => 1024*1024 bytes
15
+# 1g => 1000000000 bytes
16
+# 1gb => 1024*1024*1024 bytes
17
+#
18
+# units are case insensitive so 1GB 1Gb 1gB are all the same.
19
+
20
+################################## INCLUDES ###################################
21
+
22
+# Include one or more other config files here.  This is useful if you
23
+# have a standard template that goes to all Redis servers but also need
24
+# to customize a few per-server settings.  Include files can include
25
+# other files, so use this wisely.
26
+#
27
+# Notice option "include" won't be rewritten by command "CONFIG REWRITE"
28
+# from admin or Redis Sentinel. Since Redis always uses the last processed
29
+# line as value of a configuration directive, you'd better put includes
30
+# at the beginning of this file to avoid overwriting config change at runtime.
31
+#
32
+# If instead you are interested in using includes to override configuration
33
+# options, it is better to use include as the last line.
34
+#
35
+# include /path/to/local.conf
36
+# include /path/to/other.conf
37
+
38
+################################## NETWORK #####################################
39
+
40
+# By default, if no "bind" configuration directive is specified, Redis listens
41
+# for connections from all the network interfaces available on the server.
42
+# It is possible to listen to just one or multiple selected interfaces using
43
+# the "bind" configuration directive, followed by one or more IP addresses.
44
+#
45
+# Examples:
46
+#
47
+# bind 192.168.1.100 10.0.0.1
48
+# bind 127.0.0.1 ::1
49
+#
50
+# ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the
51
+# internet, binding to all the interfaces is dangerous and will expose the
52
+# instance to everybody on the internet. So by default we uncomment the
53
+# following bind directive, that will force Redis to listen only into
54
+# the IPv4 lookback interface address (this means Redis will be able to
55
+# accept connections only from clients running into the same computer it
56
+# is running).
57
+#
58
+# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
59
+# JUST COMMENT THE FOLLOWING LINE.
60
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
61
+bind 0.0.0.0
62
+
63
+# Protected mode is a layer of security protection, in order to avoid that
64
+# Redis instances left open on the internet are accessed and exploited.
65
+#
66
+# When protected mode is on and if:
67
+#
68
+# 1) The server is not binding explicitly to a set of addresses using the
69
+#    "bind" directive.
70
+# 2) No password is configured.
71
+#
72
+# The server only accepts connections from clients connecting from the
73
+# IPv4 and IPv6 loopback addresses 127.0.0.1 and ::1, and from Unix domain
74
+# sockets.
75
+#
76
+# By default protected mode is enabled. You should disable it only if
77
+# you are sure you want clients from other hosts to connect to Redis
78
+# even if no authentication is configured, nor a specific set of interfaces
79
+# are explicitly listed using the "bind" directive.
80
+protected-mode no
81
+
82
+# Accept connections on the specified port, default is 6379 (IANA #815344).
83
+# If port 0 is specified Redis will not listen on a TCP socket.
84
+port %%redisPortSlave
85
+
86
+# TCP listen() backlog.
87
+#
88
+# In high requests-per-second environments you need an high backlog in order
89
+# to avoid slow clients connections issues. Note that the Linux kernel
90
+# will silently truncate it to the value of /proc/sys/net/core/somaxconn so
91
+# make sure to raise both the value of somaxconn and tcp_max_syn_backlog
92
+# in order to get the desired effect.
93
+tcp-backlog 511
94
+
95
+# Unix socket.
96
+#
97
+# Specify the path for the Unix socket that will be used to listen for
98
+# incoming connections. There is no default, so Redis will not listen
99
+# on a unix socket when not specified.
100
+#
101
+# unixsocket /var/run/redis/redis.sock
102
+# unixsocketperm 700
103
+
104
+# Close the connection after a client is idle for N seconds (0 to disable)
105
+timeout 0
106
+
107
+# TCP keepalive.
108
+#
109
+# If non-zero, use SO_KEEPALIVE to send TCP ACKs to clients in absence
110
+# of communication. This is useful for two reasons:
111
+#
112
+# 1) Detect dead peers.
113
+# 2) Take the connection alive from the point of view of network
114
+#    equipment in the middle.
115
+#
116
+# On Linux, the specified value (in seconds) is the period used to send ACKs.
117
+# Note that to close the connection the double of the time is needed.
118
+# On other kernels the period depends on the kernel configuration.
119
+#
120
+# A reasonable value for this option is 300 seconds, which is the new
121
+# Redis default starting with Redis 3.2.1.
122
+tcp-keepalive %%redisTCPKeepAliveSlave
123
+
124
+################################# GENERAL #####################################
125
+
126
+# By default Redis does not run as a daemon. Use 'yes' if you need it.
127
+# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
128
+daemonize yes
129
+
130
+# If you run Redis from upstart or systemd, Redis can interact with your
131
+# supervision tree. Options:
132
+#   supervised no      - no supervision interaction
133
+#   supervised upstart - signal upstart by putting Redis into SIGSTOP mode
134
+#   supervised systemd - signal systemd by writing READY=1 to $NOTIFY_SOCKET
135
+#   supervised auto    - detect upstart or systemd method based on
136
+#                        UPSTART_JOB or NOTIFY_SOCKET environment variables
137
+# Note: these supervision methods only signal "process is ready."
138
+#       They do not enable continuous liveness pings back to your supervisor.
139
+supervised systemd
140
+
141
+# If a pid file is specified, Redis writes it where specified at startup
142
+# and removes it at exit.
143
+#
144
+# When the server runs non daemonized, no pid file is created if none is
145
+# specified in the configuration. When the server is daemonized, the pid file
146
+# is used even if not specified, defaulting to "/var/run/redis.pid".
147
+#
148
+# Creating a pid file is best effort: if Redis is not able to create it
149
+# nothing bad happens, the server will start and run normally.
150
+pidfile /var/run/redis/redis-server.pid
151
+
152
+# Specify the server verbosity level.
153
+# This can be one of:
154
+# debug (a lot of information, useful for development/testing)
155
+# verbose (many rarely useful info, but not a mess like the debug level)
156
+# notice (moderately verbose, what you want in production probably)
157
+# warning (only very important / critical messages are logged)
158
+loglevel notice
159
+
160
+# Specify the log file name. Also the empty string can be used to force
161
+# Redis to log on the standard output. Note that if you use standard
162
+# output for logging but daemonize, logs will be sent to /dev/null
163
+logfile /var/log/redis/redis-server.log
164
+
165
+# To enable logging to the system logger, just set 'syslog-enabled' to yes,
166
+# and optionally update the other syslog parameters to suit your needs.
167
+# syslog-enabled no
168
+
169
+# Specify the syslog identity.
170
+# syslog-ident redis
171
+
172
+# Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7.
173
+# syslog-facility local0
174
+
175
+# Set the number of databases. The default database is DB 0, you can select
176
+# a different one on a per-connection basis using SELECT <dbid> where
177
+# dbid is a number between 0 and 'databases'-1
178
+databases 16
179
+
180
+################################ SNAPSHOTTING  ################################
181
+#
182
+# Save the DB on disk:
183
+#
184
+#   save <seconds> <changes>
185
+#
186
+#   Will save the DB if both the given number of seconds and the given
187
+#   number of write operations against the DB occurred.
188
+#
189
+#   In the example below the behaviour will be to save:
190
+#   after 900 sec (15 min) if at least 1 key changed
191
+#   after 300 sec (5 min) if at least 10 keys changed
192
+#   after 60 sec if at least 10000 keys changed
193
+#
194
+#   Note: you can disable saving completely by commenting out all "save" lines.
195
+#
196
+#   It is also possible to remove all the previously configured save
197
+#   points by adding a save directive with a single empty string argument
198
+#   like in the following example:
199
+#
200
+#   save ""
201
+
202
+save 900 1
203
+save 300 10
204
+save 60 10000
205
+
206
+# By default Redis will stop accepting writes if RDB snapshots are enabled
207
+# (at least one save point) and the latest background save failed.
208
+# This will make the user aware (in a hard way) that data is not persisting
209
+# on disk properly, otherwise chances are that no one will notice and some
210
+# disaster will happen.
211
+#
212
+# If the background saving process will start working again Redis will
213
+# automatically allow writes again.
214
+#
215
+# However if you have setup your proper monitoring of the Redis server
216
+# and persistence, you may want to disable this feature so that Redis will
217
+# continue to work as usual even if there are problems with disk,
218
+# permissions, and so forth.
219
+stop-writes-on-bgsave-error yes
220
+
221
+# Compress string objects using LZF when dump .rdb databases?
222
+# For default that's set to 'yes' as it's almost always a win.
223
+# If you want to save some CPU in the saving child set it to 'no' but
224
+# the dataset will likely be bigger if you have compressible values or keys.
225
+rdbcompression yes
226
+
227
+# Since version 5 of RDB a CRC64 checksum is placed at the end of the file.
228
+# This makes the format more resistant to corruption but there is a performance
229
+# hit to pay (around 10%) when saving and loading RDB files, so you can disable it
230
+# for maximum performances.
231
+#
232
+# RDB files created with checksum disabled have a checksum of zero that will
233
+# tell the loading code to skip the check.
234
+rdbchecksum yes
235
+
236
+# The filename where to dump the DB
237
+dbfilename dump.rdb
238
+
239
+# The working directory.
240
+#
241
+# The DB will be written inside this directory, with the filename specified
242
+# above using the 'dbfilename' configuration directive.
243
+#
244
+# The Append Only File will also be created inside this directory.
245
+#
246
+# Note that you must specify a directory here, not a file name.
247
+dir /var/lib/redis
248
+
249
+################################## SECURITY ###################################
250
+
251
+# Require clients to issue AUTH <PASSWORD> before processing any other
252
+# commands.  This might be useful in environments in which you do not trust
253
+# others with access to the host running redis-server.
254
+#
255
+# This should stay commented out for backward compatibility and because most
256
+# people do not need auth (e.g. they run their own servers).
257
+#
258
+# Warning: since Redis is pretty fast an outside user can try up to
259
+# 150k passwords per second against a good box. This means that you should
260
+# use a very strong password otherwise it will be very easy to break.
261
+#
262
+#requirepass redisMasterPassword
263
+
264
+# Command renaming.
265
+#
266
+# It is possible to change the name of dangerous commands in a shared
267
+# environment. For instance the CONFIG command may be renamed into something
268
+# hard to guess so that it will still be available for internal-use tools
269
+# but not available for general clients.
270
+#
271
+# Example:
272
+#
273
+# rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52
274
+#
275
+# It is also possible to completely kill a command by renaming it into
276
+# an empty string:
277
+#
278
+# rename-command CONFIG ""
279
+#
280
+# Please note that changing the name of commands that are logged into the
281
+# AOF file or transmitted to slaves may cause problems.
282
+
283
+################################### LIMITS ####################################
284
+
285
+# Set the max number of connected clients at the same time. By default
286
+# this limit is set to 10000 clients, however if the Redis server is not
287
+# able to configure the process file limit to allow for the specified limit
288
+# the max number of allowed clients is set to the current file limit
289
+# minus 32 (as Redis reserves a few file descriptors for internal uses).
290
+#
291
+# Once the limit is reached Redis will close all the new connections sending
292
+# an error 'max number of clients reached'.
293
+#
294
+# maxclients 10000
295
+
296
+# Don't use more memory than the specified amount of bytes.
297
+# When the memory limit is reached Redis will try to remove keys
298
+# according to the eviction policy selected (see maxmemory-policy).
299
+#
300
+# If Redis can't remove keys according to the policy, or if the policy is
301
+# set to 'noeviction', Redis will start to reply with errors to commands
302
+# that would use more memory, like SET, LPUSH, and so on, and will continue
303
+# to reply to read-only commands like GET.
304
+#
305
+# This option is usually useful when using Redis as an LRU cache, or to set
306
+# a hard memory limit for an instance (using the 'noeviction' policy).
307
+#
308
+# WARNING: If you have slaves attached to an instance with maxmemory on,
309
+# the size of the output buffers needed to feed the slaves are subtracted
310
+# from the used memory count, so that network problems / resyncs will
311
+# not trigger a loop where keys are evicted, and in turn the output
312
+# buffer of slaves is full with DELs of keys evicted triggering the deletion
313
+# of more keys, and so forth until the database is completely emptied.
314
+#
315
+# In short... if you have slaves attached it is suggested that you set a lower
316
+# limit for maxmemory so that there is some free RAM on the system for slave
317
+# output buffers (but this is not needed if the policy is 'noeviction').
318
+#
319
+maxmemory %{redisMaxMemory}mb
320
+
321
+# MAXMEMORY POLICY: how Redis will select what to remove when maxmemory
322
+# is reached. You can select among five behaviors:
323
+#
324
+# volatile-lru -> remove the key with an expire set using an LRU algorithm
325
+# allkeys-lru -> remove any key according to the LRU algorithm
326
+# volatile-random -> remove a random key with an expire set
327
+# allkeys-random -> remove a random key, any key
328
+# volatile-ttl -> remove the key with the nearest expire time (minor TTL)
329
+# noeviction -> don't expire at all, just return an error on write operations
330
+#
331
+# Note: with any of the above policies, Redis will return an error on write
332
+#       operations, when there are no suitable keys for eviction.
333
+#
334
+#       At the date of writing these commands are: set setnx setex append
335
+#       incr decr rpush lpush rpushx lpushx linsert lset rpoplpush sadd
336
+#       sinter sinterstore sunion sunionstore sdiff sdiffstore zadd zincrby
337
+#       zunionstore zinterstore hset hsetnx hmset hincrby incrby decrby
338
+#       getset mset msetnx exec sort
339
+#
340
+# The default is:
341
+#
342
+maxmemory-policy %%redisMemoryPolicySlave
343
+
344
+# LRU and minimal TTL algorithms are not precise algorithms but approximated
345
+# algorithms (in order to save memory), so you can tune it for speed or
346
+# accuracy. For default Redis will check five keys and pick the one that was
347
+# used less recently, you can change the sample size using the following
348
+# configuration directive.
349
+#
350
+# The default of 5 produces good enough results. 10 Approximates very closely
351
+# true LRU but costs a bit more CPU. 3 is very fast but not very accurate.
352
+#
353
+# maxmemory-samples 5
354
+
355
+############################## APPEND ONLY MODE ###############################
356
+
357
+# By default Redis asynchronously dumps the dataset on disk. This mode is
358
+# good enough in many applications, but an issue with the Redis process or
359
+# a power outage may result into a few minutes of writes lost (depending on
360
+# the configured save points).
361
+#
362
+# The Append Only File is an alternative persistence mode that provides
363
+# much better durability. For instance using the default data fsync policy
364
+# (see later in the config file) Redis can lose just one second of writes in a
365
+# dramatic event like a server power outage, or a single write if something
366
+# wrong with the Redis process itself happens, but the operating system is
367
+# still running correctly.
368
+#
369
+# AOF and RDB persistence can be enabled at the same time without problems.
370
+# If the AOF is enabled on startup Redis will load the AOF, that is the file
371
+# with the better durability guarantees.
372
+#
373
+# Please check http://redis.io/topics/persistence for more information.
374
+
375
+appendonly yes
376
+
377
+# The name of the append only file (default: "appendonly.aof")
378
+
379
+appendfilename "appendonly.aof"
380
+
381
+# The fsync() call tells the Operating System to actually write data on disk
382
+# instead of waiting for more data in the output buffer. Some OS will really flush
383
+# data on disk, some other OS will just try to do it ASAP.
384
+#
385
+# Redis supports three different modes:
386
+#
387
+# no: don't fsync, just let the OS flush the data when it wants. Faster.
388
+# always: fsync after every write to the append only log. Slow, Safest.
389
+# everysec: fsync only one time every second. Compromise.
390
+#
391
+# The default is "everysec", as that's usually the right compromise between
392
+# speed and data safety. It's up to you to understand if you can relax this to
393
+# "no" that will let the operating system flush the output buffer when
394
+# it wants, for better performances (but if you can live with the idea of
395
+# some data loss consider the default persistence mode that's snapshotting),
396
+# or on the contrary, use "always" that's very slow but a bit safer than
397
+# everysec.
398
+#
399
+# More details please check the following article:
400
+# http://antirez.com/post/redis-persistence-demystified.html
401
+#
402
+# If unsure, use "everysec".
403
+
404
+# appendfsync always
405
+appendfsync everysec
406
+# appendfsync no
407
+
408
+# When the AOF fsync policy is set to always or everysec, and a background
409
+# saving process (a background save or AOF log background rewriting) is
410
+# performing a lot of I/O against the disk, in some Linux configurations
411
+# Redis may block too long on the fsync() call. Note that there is no fix for
412
+# this currently, as even performing fsync in a different thread will block
413
+# our synchronous write(2) call.
414
+#
415
+# In order to mitigate this problem it's possible to use the following option
416
+# that will prevent fsync() from being called in the main process while a
417
+# BGSAVE or BGREWRITEAOF is in progress.
418
+#
419
+# This means that while another child is saving, the durability of Redis is
420
+# the same as "appendfsync none". In practical terms, this means that it is
421
+# possible to lose up to 30 seconds of log in the worst scenario (with the
422
+# default Linux settings).
423
+#
424
+# If you have latency problems turn this to "yes". Otherwise leave it as
425
+# "no" that is the safest pick from the point of view of durability.
426
+
427
+no-appendfsync-on-rewrite no
428
+
429
+# Automatic rewrite of the append only file.
430
+# Redis is able to automatically rewrite the log file implicitly calling
431
+# BGREWRITEAOF when the AOF log size grows by the specified percentage.
432
+#
433
+# This is how it works: Redis remembers the size of the AOF file after the
434
+# latest rewrite (if no rewrite has happened since the restart, the size of
435
+# the AOF at startup is used).
436
+#
437
+# This base size is compared to the current size. If the current size is
438
+# bigger than the specified percentage, the rewrite is triggered. Also
439
+# you need to specify a minimal size for the AOF file to be rewritten, this
440
+# is useful to avoid rewriting the AOF file even if the percentage increase
441
+# is reached but it is still pretty small.
442
+#
443
+# Specify a percentage of zero in order to disable the automatic AOF
444
+# rewrite feature.
445
+
446
+auto-aof-rewrite-percentage 100
447
+auto-aof-rewrite-min-size 64mb
448
+
449
+# An AOF file may be found to be truncated at the end during the Redis
450
+# startup process, when the AOF data gets loaded back into memory.
451
+# This may happen when the system where Redis is running
452
+# crashes, especially when an ext4 filesystem is mounted without the
453
+# data=ordered option (however this can't happen when Redis itself
454
+# crashes or aborts but the operating system still works correctly).
455
+#
456
+# Redis can either exit with an error when this happens, or load as much
457
+# data as possible (the default now) and start if the AOF file is found
458
+# to be truncated at the end. The following option controls this behavior.
459
+#
460
+# If aof-load-truncated is set to yes, a truncated AOF file is loaded and
461
+# the Redis server starts emitting a log to inform the user of the event.
462
+# Otherwise if the option is set to no, the server aborts with an error
463
+# and refuses to start. When the option is set to no, the user requires
464
+# to fix the AOF file using the "redis-check-aof" utility before to restart
465
+# the server.
466
+#
467
+# Note that if the AOF file will be found to be corrupted in the middle
468
+# the server will still exit with an error. This option only applies when
469
+# Redis will try to read more data from the AOF file but not enough bytes
470
+# will be found.
471
+aof-load-truncated yes
472
+
473
+################################ LUA SCRIPTING  ###############################
474
+
475
+# Max execution time of a Lua script in milliseconds.
476
+#
477
+# If the maximum execution time is reached Redis will log that a script is
478
+# still in execution after the maximum allowed time and will start to
479
+# reply to queries with an error.
480
+#
481
+# When a long running script exceeds the maximum execution time only the
482
+# SCRIPT KILL and SHUTDOWN NOSAVE commands are available. The first can be
483
+# used to stop a script that did not yet called write commands. The second
484
+# is the only way to shut down the server in the case a write command was
485
+# already issued by the script but the user doesn't want to wait for the natural
486
+# termination of the script.
487
+#
488
+# Set it to 0 or a negative value for unlimited execution without warnings.
489
+lua-time-limit 5000
490
+
491
+################################ REDIS CLUSTER  ###############################
492
+#
493
+# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
494
+# WARNING EXPERIMENTAL: Redis Cluster is considered to be stable code, however
495
+# in order to mark it as "mature" we need to wait for a non trivial percentage
496
+# of users to deploy it in production.
497
+# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
498
+#
499
+# Normal Redis instances can't be part of a Redis Cluster; only nodes that are
500
+# started as cluster nodes can. In order to start a Redis instance as a
501
+# cluster node enable the cluster support uncommenting the following:
502
+#
503
+cluster-enabled yes
504
+
505
+# Every cluster node has a cluster configuration file. This file is not
506
+# intended to be edited by hand. It is created and updated by Redis nodes.
507
+# Every Redis Cluster node requires a different cluster configuration file.
508
+# Make sure that instances running in the same system do not have
509
+# overlapping cluster configuration file names.
510
+#
511
+cluster-config-file nodes-slave.conf
512
+
513
+# Cluster node timeout is the amount of milliseconds a node must be unreachable
514
+# for it to be considered in failure state.
515
+# Most other internal time limits are multiple of the node timeout.
516
+#
517
+cluster-node-timeout 15000
518
+
519
+# A slave of a failing master will avoid to start a failover if its data
520
+# looks too old.
521
+#
522
+# There is no simple way for a slave to actually have a exact measure of
523
+# its "data age", so the following two checks are performed:
524
+#
525
+# 1) If there are multiple slaves able to failover, they exchange messages
526
+#    in order to try to give an advantage to the slave with the best
527
+#    replication offset (more data from the master processed).
528
+#    Slaves will try to get their rank by offset, and apply to the start
529
+#    of the failover a delay proportional to their rank.
530
+#
531
+# 2) Every single slave computes the time of the last interaction with
532
+#    its master. This can be the last ping or command received (if the master
533
+#    is still in the "connected" state), or the time that elapsed since the
534
+#    disconnection with the master (if the replication link is currently down).
535
+#    If the last interaction is too old, the slave will not try to failover
536
+#    at all.
537
+#
538
+# The point "2" can be tuned by user. Specifically a slave will not perform
539
+# the failover if, since the last interaction with the master, the time
540
+# elapsed is greater than:
541
+#
542
+#   (node-timeout * slave-validity-factor) + repl-ping-slave-period
543
+#
544
+# So for example if node-timeout is 30 seconds, and the slave-validity-factor
545
+# is 10, and assuming a default repl-ping-slave-period of 10 seconds, the
546
+# slave will not try to failover if it was not able to talk with the master
547
+# for longer than 310 seconds.
548
+#
549
+# A large slave-validity-factor may allow slaves with too old data to failover
550
+# a master, while a too small value may prevent the cluster from being able to
551
+# elect a slave at all.
552
+#
553
+# For maximum availability, it is possible to set the slave-validity-factor
554
+# to a value of 0, which means, that slaves will always try to failover the
555
+# master regardless of the last time they interacted with the master.
556
+# (However they'll always try to apply a delay proportional to their
557
+# offset rank).
558
+#
559
+# Zero is the only value able to guarantee that when all the partitions heal
560
+# the cluster will always be able to continue.
561
+#
562
+cluster-slave-validity-factor 10
563
+
564
+# Cluster slaves are able to migrate to orphaned masters, that are masters
565
+# that are left without working slaves. This improves the cluster ability
566
+# to resist to failures as otherwise an orphaned master can't be failed over
567
+# in case of failure if it has no working slaves.
568
+#
569
+# Slaves migrate to orphaned masters only if there are still at least a
570
+# given number of other working slaves for their old master. This number
571
+# is the "migration barrier". A migration barrier of 1 means that a slave
572
+# will migrate only if there is at least 1 other working slave for its master
573
+# and so forth. It usually reflects the number of slaves you want for every
574
+# master in your cluster.
575
+#
576
+# Default is 1 (slaves migrate only if their masters remain with at least
577
+# one slave). To disable migration just set it to a very large value.
578
+# A value of 0 can be set but is useful only for debugging and dangerous
579
+# in production.
580
+#
581
+cluster-migration-barrier 1
582
+
583
+# By default Redis Cluster nodes stop accepting queries if they detect there
584
+# is at least an hash slot uncovered (no available node is serving it).
585
+# This way if the cluster is partially down (for example a range of hash slots
586
+# are no longer covered) all the cluster becomes, eventually, unavailable.
587
+# It automatically returns available as soon as all the slots are covered again.
588
+#
589
+# However sometimes you want the subset of the cluster which is working,
590
+# to continue to accept queries for the part of the key space that is still
591
+# covered. In order to do so, just set the cluster-require-full-coverage
592
+# option to no.
593
+#
594
+cluster-require-full-coverage yes
595
+
596
+# In order to setup your cluster make sure to read the documentation
597
+# available at http://redis.io web site.
598
+
599
+################################## SLOW LOG ###################################
600
+
601
+# The Redis Slow Log is a system to log queries that exceeded a specified
602
+# execution time. The execution time does not include the I/O operations
603
+# like talking with the client, sending the reply and so forth,
604
+# but just the time needed to actually execute the command (this is the only
605
+# stage of command execution where the thread is blocked and can not serve
606
+# other requests in the meantime).
607
+#
608
+# You can configure the slow log with two parameters: one tells Redis
609
+# what is the execution time, in microseconds, to exceed in order for the
610
+# command to get logged, and the other parameter is the length of the
611
+# slow log. When a new command is logged the oldest one is removed from the
612
+# queue of logged commands.
613
+
614
+# The following time is expressed in microseconds, so 1000000 is equivalent
615
+# to one second. Note that a negative number disables the slow log, while
616
+# a value of zero forces the logging of every command.
617
+slowlog-log-slower-than 10000
618
+
619
+# There is no limit to this length. Just be aware that it will consume memory.
620
+# You can reclaim memory used by the slow log with SLOWLOG RESET.
621
+slowlog-max-len 128
622
+
623
+################################ LATENCY MONITOR ##############################
624
+
625
+# The Redis latency monitoring subsystem samples different operations
626
+# at runtime in order to collect data related to possible sources of
627
+# latency of a Redis instance.
628
+#
629
+# Via the LATENCY command this information is available to the user that can
630
+# print graphs and obtain reports.
631
+#
632
+# The system only logs operations that were performed in a time equal or
633
+# greater than the amount of milliseconds specified via the
634
+# latency-monitor-threshold configuration directive. When its value is set
635
+# to zero, the latency monitor is turned off.
636
+#
637
+# By default latency monitoring is disabled since it is mostly not needed
638
+# if you don't have latency issues, and collecting data has a performance
639
+# impact, that while very small, can be measured under big load. Latency
640
+# monitoring can easily be enabled at runtime using the command
641
+# "CONFIG SET latency-monitor-threshold <milliseconds>" if needed.
642
+latency-monitor-threshold 0
643
+
644
+############################# EVENT NOTIFICATION ##############################
645
+
646
+# Redis can notify Pub/Sub clients about events happening in the key space.
647
+# This feature is documented at http://redis.io/topics/notifications
648
+#
649
+# For instance if keyspace events notification is enabled, and a client
650
+# performs a DEL operation on key "foo" stored in the Database 0, two
651
+# messages will be published via Pub/Sub:
652
+#
653
+# PUBLISH __keyspace@0__:foo del
654
+# PUBLISH __keyevent@0__:del foo
655
+#
656
+# It is possible to select the events that Redis will notify among a set
657
+# of classes. Every class is identified by a single character:
658
+#
659
+#  K     Keyspace events, published with __keyspace@<db>__ prefix.
660
+#  E     Keyevent events, published with __keyevent@<db>__ prefix.
661
+#  g     Generic commands (non-type specific) like DEL, EXPIRE, RENAME, ...
662
+#  $     String commands
663
+#  l     List commands
664
+#  s     Set commands
665
+#  h     Hash commands
666
+#  z     Sorted set commands
667
+#  x     Expired events (events generated every time a key expires)
668
+#  e     Evicted events (events generated when a key is evicted for maxmemory)
669
+#  A     Alias for g$lshzxe, so that the "AKE" string means all the events.
670
+#
671
+#  The "notify-keyspace-events" takes as argument a string that is composed
672
+#  of zero or multiple characters. The empty string means that notifications
673
+#  are disabled.
674
+#
675
+#  Example: to enable list and generic events, from the point of view of the
676
+#           event name, use:
677
+#
678
+#  notify-keyspace-events Elg
679
+#
680
+#  Example 2: to get the stream of the expired keys subscribing to channel
681
+#             name __keyevent@0__:expired use:
682
+#
683
+#  notify-keyspace-events Ex
684
+#
685
+#  By default all notifications are disabled because most users don't need
686
+#  this feature and the feature has some overhead. Note that if you don't
687
+#  specify at least one of K or E, no events will be delivered.
688
+notify-keyspace-events ""
689
+
690
+############################### ADVANCED CONFIG ###############################
691
+
692
+# Hashes are encoded using a memory efficient data structure when they have a
693
+# small number of entries, and the biggest entry does not exceed a given
694
+# threshold. These thresholds can be configured using the following directives.
695
+hash-max-ziplist-entries 512
696
+hash-max-ziplist-value 64
697
+
698
+# Lists are also encoded in a special way to save a lot of space.
699
+# The number of entries allowed per internal list node can be specified
700
+# as a fixed maximum size or a maximum number of elements.
701
+# For a fixed maximum size, use -5 through -1, meaning:
702
+# -5: max size: 64 Kb  <-- not recommended for normal workloads
703
+# -4: max size: 32 Kb  <-- not recommended
704
+# -3: max size: 16 Kb  <-- probably not recommended
705
+# -2: max size: 8 Kb   <-- good
706
+# -1: max size: 4 Kb   <-- good
707
+# Positive numbers mean store up to _exactly_ that number of elements
708
+# per list node.
709
+# The highest performing option is usually -2 (8 Kb size) or -1 (4 Kb size),
710
+# but if your use case is unique, adjust the settings as necessary.
711
+list-max-ziplist-size -2
712
+
713
+# Lists may also be compressed.
714
+# Compress depth is the number of quicklist ziplist nodes from *each* side of
715
+# the list to *exclude* from compression.  The head and tail of the list
716
+# are always uncompressed for fast push/pop operations.  Settings are:
717
+# 0: disable all list compression
718
+# 1: depth 1 means "don't start compressing until after 1 node into the list,
719
+#    going from either the head or tail"
720
+#    So: [head]->node->node->...->node->[tail]
721
+#    [head], [tail] will always be uncompressed; inner nodes will compress.
722
+# 2: [head]->[next]->node->node->...->node->[prev]->[tail]
723
+#    2 here means: don't compress head or head->next or tail->prev or tail,
724
+#    but compress all nodes between them.
725
+# 3: [head]->[next]->[next]->node->node->...->node->[prev]->[prev]->[tail]
726
+# etc.
727
+list-compress-depth 0
728
+
729
+# Sets have a special encoding in just one case: when a set is composed
730
+# of just strings that happen to be integers in radix 10 in the range
731
+# of 64 bit signed integers.
732
+# The following configuration setting sets the limit in the size of the
733
+# set in order to use this special memory saving encoding.
734
+set-max-intset-entries 512
735
+
736
+# Similarly to hashes and lists, sorted sets are also specially encoded in
737
+# order to save a lot of space. This encoding is only used when the length and
738
+# elements of a sorted set are below the following limits:
739
+zset-max-ziplist-entries 128
740
+zset-max-ziplist-value 64
741
+
742
+# HyperLogLog sparse representation bytes limit. The limit includes the
743
+# 16 bytes header. When an HyperLogLog using the sparse representation crosses
744
+# this limit, it is converted into the dense representation.
745
+#
746
+# A value greater than 16000 is totally useless, since at that point the
747
+# dense representation is more memory efficient.
748
+#
749
+# The suggested value is ~ 3000 in order to have the benefits of
750
+# the space efficient encoding without slowing down too much PFADD,
751
+# which is O(N) with the sparse encoding. The value can be raised to
752
+# ~ 10000 when CPU is not a concern, but space is, and the data set is
753
+# composed of many HyperLogLogs with cardinality in the 0 - 15000 range.
754
+hll-sparse-max-bytes 3000
755
+
756
+# Active rehashing uses 1 millisecond every 100 milliseconds of CPU time in
757
+# order to help rehashing the main Redis hash table (the one mapping top-level
758
+# keys to values). The hash table implementation Redis uses (see dict.c)
759
+# performs a lazy rehashing: the more operation you run into a hash table
760
+# that is rehashing, the more rehashing "steps" are performed, so if the
761
+# server is idle the rehashing is never complete and some more memory is used
762
+# by the hash table.
763
+#
764
+# The default is to use this millisecond 10 times every second in order to
765
+# actively rehash the main dictionaries, freeing memory when possible.
766
+#
767
+# If unsure:
768
+# use "activerehashing no" if you have hard latency requirements and it is
769
+# not a good thing in your environment that Redis can reply from time to time
770
+# to queries with 2 milliseconds delay.
771
+#
772
+# use "activerehashing yes" if you don't have such hard requirements but
773
+# want to free memory asap when possible.
774
+activerehashing yes
775
+
776
+# The client output buffer limits can be used to force disconnection of clients
777
+# that are not reading data from the server fast enough for some reason (a
778
+# common reason is that a Pub/Sub client can't consume messages as fast as the
779
+# publisher can produce them).
780
+#
781
+# The limit can be set differently for the three different classes of clients:
782
+#
783
+# normal -> normal clients including MONITOR clients
784
+# slave  -> slave clients
785
+# pubsub -> clients subscribed to at least one pubsub channel or pattern
786
+#
787
+# The syntax of every client-output-buffer-limit directive is the following:
788
+#
789
+# client-output-buffer-limit <class> <hard limit> <soft limit> <soft seconds>
790
+#
791
+# A client is immediately disconnected once the hard limit is reached, or if
792
+# the soft limit is reached and remains reached for the specified number of
793
+# seconds (continuously).
794
+# So for instance if the hard limit is 32 megabytes and the soft limit is
795
+# 16 megabytes / 10 seconds, the client will get disconnected immediately
796
+# if the size of the output buffers reach 32 megabytes, but will also get
797
+# disconnected if the client reaches 16 megabytes and continuously overcomes
798
+# the limit for 10 seconds.
799
+#
800
+# By default normal clients are not limited because they don't receive data
801
+# without asking (in a push way), but just after a request, so only
802
+# asynchronous clients may create a scenario where data is requested faster
803
+# than it can read.
804
+#
805
+# Instead there is a default limit for pubsub and slave clients, since
806
+# subscribers and slaves receive data in a push fashion.
807
+#
808
+# Both the hard or the soft limit can be disabled by setting them to zero.
809
+client-output-buffer-limit normal 0 0 0
810
+client-output-buffer-limit slave 256mb 64mb 60
811
+client-output-buffer-limit pubsub 32mb 8mb 60
812
+
813
+# Redis calls an internal function to perform many background tasks, like
814
+# closing connections of clients in timeout, purging expired keys that are
815
+# never requested, and so forth.
816
+#
817
+# Not all tasks are performed with the same frequency, but Redis checks for
818
+# tasks to perform according to the specified "hz" value.
819
+#
820
+# By default "hz" is set to 10. Raising the value will use more CPU when
821
+# Redis is idle, but at the same time will make Redis more responsive when
822
+# there are many keys expiring at the same time, and timeouts may be
823
+# handled with more precision.
824
+#
825
+# The range is between 1 and 500, however a value over 100 is usually not
826
+# a good idea. Most users should use the default of 10 and raise this up to
827
+# 100 only in environments where very low latency is required.
828
+hz 10
829
+
830
+# When a child rewrites the AOF file, if the following option is enabled
831
+# the file will be fsync-ed every 32 MB of data generated. This is useful
832
+# in order to commit the file to the disk more incrementally and avoid
833
+# big latency spikes.
834
+aof-rewrite-incremental-fsync yes