Compare commits

...

19 Commits

Author SHA1 Message Date
Teddy Cornaut 92b8541fa2 Suppression des addInt qui empechent d'utiliser le dico dans zephir 2019-11-21 14:03:46 -05:00
Teddy Cornaut 9bfa3a41f5 Ajout conf sysctl 2019-04-11 11:25:40 +02:00
Teddy Cornaut 1ca2797bb3 Ajout service redis slave 2019-03-19 14:57:52 +01:00
Emmanuel Garette f899c6516c remove redis2-server 2019-03-05 10:34:22 +01:00
Emmanuel Garette f7ce4d51d6 corrections 2019-03-04 17:26:33 +01:00
Teddy Cornaut ae562d6a60 Fix init 2019-02-14 11:55:13 +01:00
Teddy Cornaut c568646a7d Fix variable redisMaxMemory dans conf 2018-09-06 09:23:44 +02:00
Teddy Cornaut c26de6593e Cluster non présent par défaut sur les slaves + desactivation des sauvegardes auto RDB et AOF 2018-09-04 16:51:12 +02:00
Teddy Cornaut e164823580 Correction du mode local avec slave distant 2018-09-04 15:57:54 +02:00
Teddy Cornaut 15dbc98eb8 Ajout du mode local avec slave distant 2018-09-04 10:47:54 +02:00
Philippe Caseiro dc5fc136c8 Fix typo 2018-06-26 10:33:12 +02:00
Philippe Caseiro 23d8921d16 Adding maxclients support 2018-06-25 22:20:33 +02:00
Philippe Caseiro 07e64177f1 Disable Transparent Huge Page support 2018-06-21 10:38:16 +02:00
Philippe Caseiro 56a630eadb Fixing typo in dico 2018-06-21 10:14:46 +02:00
Philippe Caseiro ccc8629b8e Adding Possibility to disable persistence on Master instances 2018-06-21 10:02:34 +02:00
Philippe Caseiro 0c0202ba87 Adding somme tunning for better slave sync 2018-06-21 08:58:25 +02:00
Philippe Caseiro 2081ae6d7f Adding vm.overcommit_memory kernel parameter 2018-06-13 09:42:28 +02:00
Philippe Caseiro fad3a3febf Hidding variable not usable in with Node Rôle 2018-05-15 13:57:34 +02:00
Philippe Caseiro 4a5a5aaaf5 Hidding variable not usable in with Node Rôle 2018-05-15 13:53:31 +02:00
6 changed files with 113 additions and 39 deletions

View File

@ -2,6 +2,7 @@
<creole>
<files>
<!-- System configuration -->
<file filelist='redis' name='/etc/sysctl.d/100-redis-tuning.conf' source='redis_sysctl.conf' mkdir='True' rm='True'/>
<file filelist='redis' name='/etc/redis/redis.conf' mkdir='True' rm='True'/>
<file filelist='redisSlave' name='/etc/redis/redis-slave.conf' mkdir='True' rm='True'/>
<file filelist='redisCl' name='/etc/redis/cluster.conf' source='redis-cluster.conf' mkdir='True' rm='True'/>
@ -31,8 +32,9 @@
<variable name='redisSlaveInstance' type='oui/non' description="Voulez-vous lancer une instance esclave Redis sur ce serveur ?">
<value>non</value>
</variable>
<!-- Instance Principale-->
<variable name='redisInstanceName' type='string' description="Nom de l'instance secondaire"/>
<variable name='redisInstanceName' type='string' description="Nom de l'instance principale"/>
<variable name='redisPort' type='number' description="Port d'écoute du service Redis">
<value>6379</value>
</variable>
@ -49,9 +51,13 @@
<!-- Instance Secondaire -->
<variable name='redisSlaveInstanceName' type='string' description="Nom de l'instance secondaire"/>
<variable name='redisSlaveInstanceMaster' type='string' description="Nom du noeud a répliquer sur l'instance secondaire"/>
<variable name='redisPortSlave' type='number' description="Port d'écoute du service Redis">
<variable name='redisMasterIPSlave' type='domain' description="Nom de domaine du service Redis master" mandatory="True"/>
<variable name='redisMasterPortSlave' type='number' description="Port d'écoute du service Redis master">
<value>6379</value>
</variable>
<variable name='redisPortSlave' type='number' description="Port d'écoute du service Redis slave">
<value>8379</value>
</variable>
<variable name='redisClPortSlave' type='number' description="Port d'écoute du service Cluster Redis"/>
<variable name='redisMaxMemorySlave' type='number' description="Quantité de mémoire utilisable par Redis en Mo">
<value>512</value>
@ -86,6 +92,23 @@
<variable name='rdClMemberSlaveRole' type='string' description="Rôle de l'instance secondaire" hidden='True'/>
<variable name='rdClMemberSlaveMaster' type='string' description="Noeud du noeud répliquer sur cette instance secondaire"/>
</family>
<family name='Redis tunning' mode='expert'>
<variable name='redisMaxClients' type='number' description="Maximum allowed clients">
<value>10000</value>
</variable>
<variable name='rdCliOutBuffHardLimit' type='number' description="Client output buffer hard limit (for slave)">
<value>512</value>
</variable>
<variable name='rdCliOutBuffSoftLimit' type='number' description="Client output buffer soft limit (for slave)">
<value>256</value>
</variable>
<variable name='rdSaveDisable' type='oui/non' description="Désactiver la persistence des données sur les maitres et esclaves">
<value>non</value>
</variable>
<variable name='rdAOFDisable' type='oui/non' description="Désactiver la sauvegarde AOF sur les maitres et esclaves">
<value>non</value>
</variable>
</family>
<separators>
<separator name='redisInstanceName'>Instance Principale</separator>
<separator name='redisSlaveInstanceName'>Instance Secondaire</separator>
@ -130,14 +153,32 @@
<condition name='disabled_if_in' source='redisMode'>
<param>Local</param>
<target type='variable'>redisRole</target>
<target type='variable'>redisInstanceName</target>
<target type='variable'>redisSlaveInstance</target>
<target type='filelist'>redisCl</target>
<target type='variable'>redisClPort</target>
</condition>
<condition name='disabled_if_in' source='redisMode'>
<param>Local avec slave distant</param>
<target type='variable'>redisRole</target>
<target type='variable'>redisInstanceName</target>
<target type='variable'>redisSlaveInstanceName</target>
<target type='variable'>redisSlaveInstanceMaster</target>
<target type='variable'>redisClPortSlave</target>
<target type='variable'>redisClPort</target>
</condition>
<condition name='disabled_if_not_in' source='redisMode'>
<param>Local avec slave distant</param>
<target type='variable'>redisMasterIPSlave</target>
<target type='variable'>redisMasterPortSlave</target>
</condition>
<condition name='disabled_if_in' source='redisRole'>
<param>Node</param>
<target type='filelist'>redisCl</target>
<target type='variable'>redisInstanceName</target>
<target type='variable'>rdClMember</target>
<target type='variable'>rdClMemberIP</target>
<target type='variable'>rdClMemberPort</target>
@ -149,6 +190,7 @@
<target type='variable'>rdClMemberSlavePort</target>
<target type='variable'>rdClMemberSlaveRole</target>
<target type='variable'>rdClMemberSlaveMaster</target>
<target type='variable'>redisSlaveInstanceMaster</target>
</condition>
<condition name='disabled_if_in' source='rdClMemberRole'>
@ -176,7 +218,7 @@
<param>['Leader','Node']</param>
</check>
<check name="valid_enum" target="redisMode">
<param>['Local','Cluster']</param>
<param>['Local', 'Local avec slave distant', 'Cluster']</param>
</check>
<check name="valid_enum" target="rdClMemberRole">
<param>['master','slave']</param>
@ -202,35 +244,18 @@
<param>slave</param>
</auto>
<fill name='intAdd' target='rdClMemberSlavePort'>
<param type='eole' name='num1'>rdClMemberPort</param>
<param name='num2'>2000</param>
</fill>
<fill name='calc_val' target='redisInstanceName'>
<param type='eole' name='valeur'>nom_machine</param>
</fill>
<fill name='intAdd' target='redisClPort'>
<param type='eole' name='num1'>redisPort</param>
<param name='num2'>10000</param>
</fill>
<fill name='intAdd' target='redisPortSlave'>
<param type='eole' name='num1'>redisPort</param>
<param name='num2'>2000</param>
</fill>
<fill name='intAdd' target='redisClPortSlave'>
<param type='eole' name='num1'>redisPortSlave</param>
<param name='num2'>10000</param>
</fill>
<fill name='calc_val' target='redisMaxMemorySlave'>
<param type='eole' name='valeur'>redisMaxMemory</param>
</fill>
<fill name='calc_val' target='redisMemoryPolicySlave'>
<param type='eole' name='valeur'>redisMemoryPolicy</param>
</fill>
<fill name='calc_val' target='redisTCPKeepAliveSlave'>
<param type='eole' name='valeur'>redisTCPKeepAlive</param>
</fill>

View File

@ -14,12 +14,6 @@ Group=redis
RuntimeDirectory=redis
RuntimeDirectoryMode=2755
ExecStartPre=-/bin/run-parts --verbose /etc/redis/redis-server.pre-up.d
ExecStartPost=-/bin/run-parts --verbose /etc/redis/redis-server.post-up.d
ExecStop=-/bin/run-parts --verbose /etc/redis/redis-server.pre-down.d
ExecStop=/bin/kill -s TERM $MAINPID
ExecStopPost=-/bin/run-parts --verbose /etc/redis/redis-server.post-down.d
UMask=007
PrivateTmp=yes
LimitNOFILE=65535
@ -29,7 +23,16 @@ ReadOnlyDirectories=/
ReadWriteDirectories=-/var/lib/redis
ReadWriteDirectories=-/var/log/redis
ReadWriteDirectories=-/var/run/redis
CapabilityBoundingSet=~CAP_SYS_PTRACE
NoNewPrivileges=true
CapabilityBoundingSet=CAP_SETGID CAP_SETUID CAP_SYS_RESOURCE
MemoryDenyWriteExecute=true
ProtectKernelModules=true
ProtectKernelTunables=true
ProtectControlGroups=true
RestrictRealtime=true
RestrictNamespaces=true
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX
# redis-server can write to its own config file when in cluster mode so we
# permit writing there by default. If you are not using this feature, it is

View File

@ -113,6 +113,14 @@ function redisClusterIsOK()
}
CONF="/etc/redis/cluster.conf"
INITFLAG="/usr/share/eole/redisinit.flg"
sysConf=$(grep "vm.overcommit_memory" /etc/sysctl.conf 2>&1 > /dev/null)
if [[ ${?} -ne 0 ]]
then
echo "vm.overcommit_memory=1" >> /etc/sysctl.conf
sysctl -p /etc/sysctl.conf
fi
[[ ! -e ${CONF} ]] && exit 0
@ -138,7 +146,7 @@ do
master=${li[4]}
ntype=${li[5]}
if [[ ${ntype} == "Leader" ]]
if [[ ${ntype} == "Leader" ]]
then
LeaderIP=${ip}
LeaderPort=${port}
@ -150,9 +158,8 @@ do
MASTERS+=([${name}]=${master})
done < ${CONF}
# If the cluster is "ok" don't do anything
st=$(redisClusterIsOK ${LeaderIP} ${LeaderPort})
#[[ ${?} -eq 0 ]] && exit 0
# Disable Transparent Huge Page support on kernel
echo never > /sys/kernel/mm/transparent_hugepage/enabled
if [[ ${1} == "forget" ]]
then
@ -160,6 +167,17 @@ then
exit ${?}
fi
# If the cluster is "ok" don't do anything
st=$(redisClusterIsOK ${LeaderIP} ${LeaderPort})
[[ ${?} -eq 0 ]] && exit 0
if [[ -e ${INITFLAG} ]]
then
echo "Init allready done ... nothing to do"
exit 0
fi
echo " * Organise Cluster Meeting."
for node in ${NAMES[@]}
do
@ -232,5 +250,6 @@ echo
redisRun ${LeaderIP} ${LeaderPort} cluster info
echo
touch ${INITFLAG}
exit 0

View File

@ -83,6 +83,12 @@ protected-mode no
# If port 0 is specified Redis will not listen on a TCP socket.
port %%redisPortSlave
%if %%redisMode == 'Local avec slave distant'
slaveof %%redisMasterIPSlave %%redisMasterPortSlave
%end if
# TCP listen() backlog.
#
# In high requests-per-second environments you need an high backlog in order
@ -199,9 +205,13 @@ databases 16
#
# save ""
%if %%rdSaveDisable == 'oui'
save ""
%else
save 900 1
save 300 10
save 60 10000
%end if
# By default Redis will stop accepting writes if RDB snapshots are enabled
# (at least one save point) and the latest background save failed.
@ -291,7 +301,7 @@ dir /var/lib/redis
# Once the limit is reached Redis will close all the new connections sending
# an error 'max number of clients reached'.
#
# maxclients 10000
maxclients %%redisMaxClients
# Don't use more memory than the specified amount of bytes.
# When the memory limit is reached Redis will try to remove keys
@ -316,7 +326,7 @@ dir /var/lib/redis
# limit for maxmemory so that there is some free RAM on the system for slave
# output buffers (but this is not needed if the policy is 'noeviction').
#
maxmemory %{redisMaxMemory}mb
maxmemory %%{redisMaxMemory}mb
# MAXMEMORY POLICY: how Redis will select what to remove when maxmemory
# is reached. You can select among five behaviors:
@ -372,7 +382,11 @@ maxmemory-policy %%redisMemoryPolicySlave
#
# Please check http://redis.io/topics/persistence for more information.
%if %%rdAOFDisable == 'oui'
appendonly no
%else
appendonly yes
%end if
# The name of the append only file (default: "appendonly.aof")
@ -488,6 +502,7 @@ aof-load-truncated yes
# Set it to 0 or a negative value for unlimited execution without warnings.
lua-time-limit 5000
%if %%getVar('redisMode','Local') == "Cluster"
################################ REDIS CLUSTER ###############################
#
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@ -595,6 +610,7 @@ cluster-require-full-coverage yes
# In order to setup your cluster make sure to read the documentation
# available at http://redis.io web site.
%end if
################################## SLOW LOG ###################################
@ -807,7 +823,7 @@ activerehashing yes
#
# Both the hard or the soft limit can be disabled by setting them to zero.
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit slave %%{rdCliOutBuffHardLimit}mb %%{rdCliOutBuffSoftLimit}mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
# Redis calls an internal function to perform many background tasks, like

View File

@ -199,9 +199,13 @@ databases 16
#
# save ""
%if %%rdSaveDisable == 'oui'
save ""
%else
save 900 1
save 300 10
save 60 10000
%end if
# By default Redis will stop accepting writes if RDB snapshots are enabled
# (at least one save point) and the latest background save failed.
@ -291,7 +295,7 @@ dir /var/lib/redis
# Once the limit is reached Redis will close all the new connections sending
# an error 'max number of clients reached'.
#
# maxclients 10000
maxclients %%redisMaxClients
# Don't use more memory than the specified amount of bytes.
# When the memory limit is reached Redis will try to remove keys
@ -316,7 +320,7 @@ dir /var/lib/redis
# limit for maxmemory so that there is some free RAM on the system for slave
# output buffers (but this is not needed if the policy is 'noeviction').
#
maxmemory %{redisMaxMemory}mb
maxmemory %%{redisMaxMemory}mb
# MAXMEMORY POLICY: how Redis will select what to remove when maxmemory
# is reached. You can select among five behaviors:
@ -372,7 +376,12 @@ maxmemory-policy %%redisMemoryPolicy
#
# Please check http://redis.io/topics/persistence for more information.
%if %%rdAOFDisable == 'oui'
appendonly no
%else
appendonly yes
%end if
# The name of the append only file (default: "appendonly.aof")
@ -809,7 +818,7 @@ activerehashing yes
#
# Both the hard or the soft limit can be disabled by setting them to zero.
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit slave %%{rdCliOutBuffHardLimit}mb %%{rdCliOutBuffSoftLimit}mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
# Redis calls an internal function to perform many background tasks, like

2
tmpl/redis_sysctl.conf Normal file
View File

@ -0,0 +1,2 @@
net.core.somaxconn = 512