Initial commit.
Manager for Redis Cluster created from scratch. Used in a CAC40 company to perform seamless failover with only 2 datacenters.
This commit is contained in:
commit
0d98099e88
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
old/
|
59
prepare_reboot_redis.sh
Executable file
59
prepare_reboot_redis.sh
Executable file
@ -0,0 +1,59 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Paramètres pouvant être modifiés :
|
||||
# MANAGERS : Liste des managers redis.
|
||||
# MANAGER_PORT : Port du manager.
|
||||
# DURATION : Temps approximatif du reboot.
|
||||
#
|
||||
# Ensuite dans le script il y a un sleep 30 et un count qui va jusqu’à 10, à modifier si on a besoin de plus de temps pour que le cluster soit modifié.
|
||||
# Les logs (sur RHEL6 et RHEL7) sont envoyés dans /var/log/cron si le lancement de ce script est ajouté en crontab.
|
||||
|
||||
############
|
||||
MANAGERS="10.166.119.48 10.166.119.47"
|
||||
MANAGER_PORT=45000
|
||||
############
|
||||
DURATION=300
|
||||
WAIT=1
|
||||
|
||||
SERVER_IP=$(ip route get 10 | head -n 1 | awk '{print $NF}')
|
||||
|
||||
echo "Preparing redis for reboot."
|
||||
|
||||
for MANAGER in ${MANAGERS}; do
|
||||
OUTPUT_ROLE=$(timeout 1 curl -s ${MANAGER}:${MANAGER_PORT}/manager_status 2>&1)
|
||||
echo ${OUTPUT_ROLE} | grep -q 'active'
|
||||
if [ $? == 0 ]; then
|
||||
ACTIVE_MANAGER=${MANAGER}
|
||||
break
|
||||
else
|
||||
continue
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z ${ACTIVE_MANAGER} ]; then
|
||||
echo "No active manager found."
|
||||
echo "Managers tried : ${MANAGERS}"
|
||||
exit 2
|
||||
else
|
||||
echo "Active manager is : ${ACTIVE_MANAGER}"
|
||||
fi
|
||||
|
||||
COUNT=0
|
||||
while [ $WAIT == 1 ]; do
|
||||
echo "Asking ${MANAGER}..."
|
||||
OUTPUT=$(timeout 1 curl -s ${MANAGER}:${MANAGER_PORT}/prepare_for_reboot/${SERVER_IP}\&duration=${DURATION} 2>&1)
|
||||
echo "$OUTPUT" | grep -q 'DONE'
|
||||
if [ $? == 0 ]; then
|
||||
WAIT=0
|
||||
else
|
||||
COUNT=$(($COUNT+1))
|
||||
echo $COUNT
|
||||
sleep 30
|
||||
fi
|
||||
if [ $COUNT == 10 ]; then
|
||||
echo "Error, manager taking too long to modify the cluster"
|
||||
exit 2
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Ready for reboot"
|
1075
redis-manager.py
Executable file
1075
redis-manager.py
Executable file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user