Created
December 28, 2012 03:52
-
-
Save matetsu/4394287 to your computer and use it in GitHub Desktop.
RedisのMasterになるためのスクリプト
要redis-slaveof.py 、 redis-vpc-route-change.py
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 | |
# redis-to-master.sh | |
PROG_NAME=$0 | |
HOSTNAME=`hostname -s` | |
logger -t ${PROG_NAME} "Start changing ${HOSTNAME} to redis master..." | |
logger -t ${PROG_NAME} "Change this host to master." | |
# up to master | |
/usr/local/sbin/redis-slaveof.py no one | |
sed -i -e 's/^slaveof.*/slaveof no one/' /etc/redis/redis.conf | |
# setting for cluster | |
/sbin/service sentinel status > /dev/null 2>&1 | |
if [ "$?" = "0" ]; then | |
logger -t ${PROG_NAME} "sentinel service is running. so stop service." | |
/sbin/service sentinel stop | |
fi | |
logger -t ${PROG_NAME} "Changing sentinel.conf file." | |
sed -e "s/__MASTER_HOST__/${HOSTNAME}/g" /etc/redis/sentinel.conf.template > /etc/redis/sentinel.conf | |
logger -t ${PROG_NAME} "Start sentinel service..." | |
/sbin/service sentinel start | |
/sbin/service sentinel status > /dev/null 2>&1 | |
if [ "$?" != "0" ]; then | |
logger -t ${PROG_NAME} "Failed to start sentinel service." | |
fi | |
/sbin/chkconfig sentinel on | |
logger -t ${PROG_NAME} "Changing VPC route table..." | |
# change route table | |
/usr/local/sbin/redis-vpc-route-change.py | |
logger -t ${PROG_NAME} "Finished to change ${HOSTNAME} to redis master." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment