Home > Database > Mysql Tutorial > 简单检测mysql主从正常与否的脚本_MySQL

简单检测mysql主从正常与否的脚本_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-01 13:32:02
Original
1419 people have browsed it

bitsCN.com

简单检测mysql主从正常与否的脚本

 

在学习myslq主从的,想用简单的脚本去测试下主从是否正常。

 

01#!/bin/bash0203while getopts "h:u:p:P:" arg #选项后面的冒号表示该选项需要参数04do05        case $arg in06             h)07                HOST=$OPTARG #参数存在$OPTARG中08                ;;09             u)10                USER=$OPTARG11                ;;12             p)13                PASSWD=$OPTARG14                ;;15             P)16                PORT=$OPTARG17                ;;18             ?)  #当有不认识的选项的时候arg为?19                echo "unkonw argument"20                exit 1 ;;21        esac22done232425#获取id地址26ip=`ifconfig eth0|sed -n 2p|awk  '{ print $2 }'|awk -F : '{ print $2 }'`27array=($(mysql -h$HOST -u$USER -p$PASSWD -P$PORT -e "show slave status/G"|grep "Running" |awk '{print $2}'))28if [ "${array[0]}" == "Yes" ] || [ "${array[1]}" == "Yes" ]29          then30            echo "slave is OK"31       else32        #发送邮件33           #/home/shell/sendEmail/sendEmail -f  XXX@XXX -t XXX@XXX -s smtp.XXX -u "mysql主从复制出错" -xu user -xp passwd -m "${ip}:slave is error"34       echo "mysql主从复制出错"35fi
Copy after login

 


bitsCN.com
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
MySQL stops process
From 1970-01-01 08:00:00
0
0
0
Error when installing mysql on linux
From 1970-01-01 08:00:00
0
0
0
phpstudy cannot start mysql?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template