欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

MySQL数据库的可用性监控脚本实例

程序员文章站 2022-06-23 14:34:36
mysql可用性监控脚本 方法一: [root@host-39-108-217-12 scripts]# cat mysql-available-status.sh #!/bin/ba...

mysql可用性监控脚本

方法一:

[root@host-39-108-217-12 scripts]# cat mysql-available-status.sh 
#!/bin/bash

mysql_ping=`/usr/bin/mysqladmin -uroot -p123456 ping`

mysql_ok="mysqld is alive"

if [[ "$mysql_ping" != "$mysql_ok" ]];then

        echo "mysql is not ok !"
        sleep 5
        systemctl restart mariadb

else

        echo "mysql is ok !"
fi