Using redis-trib.rb because it works ...
This commit is contained in:
parent
c6fb12c816
commit
373275a8fc
29
postservice/91-redis-init
Executable file
29
postservice/91-redis-init
Executable 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
|
Loading…
Reference in New Issue
Block a user