redisとkeepaliveの併用、検出メカニズムの改訂
2301 ワード
keepalive , :
############start scripts
killall -0 redis-server
if [ "$?" -eq 0 ]; then
echo good
exit 0
else
LOGFILE=/var/log/keepalived-redis-state.log
echo "[check_fail_log]" >> $LOGFILE
date >> $LOGFILE
killall -0 redis-server
if [ "$?" -ne 0 ]; then
echo killall_bad_two >> /var/log/keepalived-redis-state.log
numprocess1=`netstat -tnpl | grep 6379 -c`
numprocess2=`ps -ef | grep redis-server | grep -c 6379`
if [[ ${numprocess1} -lt 1 ]] && [[ ${numprocess2} -lt 1 ]]; then
echo process_bad_three >> /var/log/keepalived-redis-state.log
#start judge status
/etc/init.d/redis status
if [[ $? -eq 0 ]]; then
echo good
exit 0
else
echo status_bad_four >> /var/log/keepalived-redis-state.log
/etc/init.d/redis status >> /var/log/keepalived-redis-state.log
####start last judge
ALIVE=`/usr/bin/redis-cli -p 6379 PING`
if [ "$ALIVE" != "PONG" ]; then
echo ping_bad_five >> /var/log/keepalived-redis-state.log
exit 1
else
exit 0
fi
###end last judge
fi
#end judge status
else
exit 0
fi
else
exit 0
fi
fi
############end scripts
:
: 。
: netstat ps -ef
: /etc/init.d/redis status 。
: redis ping 。
, 。 redis , 。
。
:
[check_fail_log]
Thu May 19 09:46:23 CST 2016
killall_bad_two
process_bad_three
status_bad_four
redis-server is stopped
ping_bad_five