-
-
Save pegasuskim/9cebf26927987cdbc8eb544ef81087d2 to your computer and use it in GitHub Desktop.
redis-sentinel client-reconfig-script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# The following arguments are passed to the script: | |
# | |
# <master-name> <role> <state> <from-ip> <from-port> <to-ip> <to-port> | |
MASTER_IP=$6 | |
VIP=172.17.0.101 | |
NETMASK=16 | |
IF=eth0 | |
MY_IP=$(ip addr show dev $IF | grep "global $IF" | head -1 | sed -e "s/^.*inet \(.*\)\/$NETMASK .*$/\1/") | |
echo "master_ip:$MASTER_IP my_ip:$MY_IP" | |
if [ ${MASTER_IP} = ${MY_IP} ]; then | |
echo "add $VIP/$NETMASK" | |
sudo /usr/bin/ip addr add ${VIP}/${NETMASK} dev ${IF} | |
# clear arp cache | |
sudo /usr/bin/arping -q -c 3 -A ${VIP} -I ${IF} | |
else | |
echo "del $VIP/$NETMASK" | |
sudo /usr/bin/ip addr del ${VIP}/${NETMASK} dev ${IF} | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment