本文共 527 字,大约阅读时间需要 1 分钟。
[root@mariadb01 ~]# cat check_mysql.sh
MYSQL=/usr/bin/mysql MYSQL_HOST=localhost MYSQL_USER=root MYSQL_PASSWORD=123456$MYSQL -h $MYSQL_HOST -u $MYSQL_USER -p$MYSQL_PASSWORD -e "show status;" >/dev/null 2>&1
#$mysqlclient --host=$host --port=$port --user=$user --password=$password -e "show databases;" > /dev/null 2>&1 if [ $? == 0 ] then echo " $host mysql login successfully " systemctl start keepalivedexit 0 else echo " $host mysql login faild" systemctl stop keepalived exit 2 fi转载于:https://blog.51cto.com/wsw26/2067195