Simple Linux Panel
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mdserver-web/plugins/keepalived/scripts/chk_mysql.sh

32 lines
863 B

2 years ago
#!/bin/bash
2 years ago
2 years ago
# 计划任务,恢复后,可自动拉起keepalived
# {$SERVER_PATH}/keepalived/scripts/chk_mysql.sh
2 years ago
counter=$(netstat -na|grep "LISTEN"|grep "3306"|wc -l)
2 years ago
if [ "${counter}" -eq 0 ]; then
echo "start check mysql status ..."
date +'%Y-%m-%d %H:%M:%S'
2 years ago
echo "check mysql is down, stop keepalive"
2 years ago
systemctl stop keepalived
date +'%Y-%m-%d %H:%M:%S'
echo "start check mysql end !!!"
2 years ago
fi
# 恢复后,自动拉起
# systemctl start keepalived
if [ "${counter}" -gt 0 ]; then
echo "start check mysql status ..."
date +'%Y-%m-%d %H:%M:%S'
echo "check mysql is up, start keepalive"
keepalived_status=`systemctl status keepalived | grep Active | grep inactive`
if [ "$keepalived_status" != "" ];then
systemctl start keepalived
fi
date +'%Y-%m-%d %H:%M:%S'
echo "start check mysql end !!!"
fi