Using redis-trib.rb because it works ...

This commit is contained in:
Philippe Caseiro 2018-05-14 12:21:55 +02:00
parent c6fb12c816
commit 373275a8fc
1 changed files with 29 additions and 0 deletions

29
postservice/91-redis-init Executable file
View File

@ -0,0 +1,29 @@
#!/bin/bash
#
# Cluster init !
#
redisTrib="/usr/share/doc/redis-tools/examples/redis-trib.rb"
CONF="/etc/redis/cluster.conf"
if [[ -f ${1} ]]
then
CONF=${1}
fi
if [[ -f "${CONF}" ]]
then
LEADER=$(awk -F ':' '/^leader/ {print $2 ":" $3}' ${CONF})
REPLICA=$(${redisTrib} check ${LEADER} | awk '/additional replica/ {print $1}')
if [[ ${REPLICA} -eq 0 ]]
then
# Create Cluster
yes yes | ${redisTrib} create --replicas 1 $(awk -F ':' '{printf "%s:%s ", $2, $3}' ${CONF})
fi
else
echo "${CONF} is missing"
exit 0
fi