Check the state of the database server from the MySQL master-slave synchronization structure-script shell

Source: Internet
Author: User

Check the status of the MySQL master- Slave synchronization architecture (from a master-to-one) from the database server  

(IP Authorization, whether the server and Io are normal, from my SQL process is normal)

Master mysql:192.168.1.10

From mysql:192.168.1.20


[Email protected] ~]# VI check_slave.sh

#!/bin/bash

master=192.168.1.10

I=1

Service mysqld Status &>/dev/null

While [true]

Do

Echo $i

Service mysqld Status &>/dev/null

if[$?-ne 0];then

echo "Slave server is down!"

Exit

Fi

Ping-c 3 $master &>/dev/null

if[$?-ne 0];then

echo "Physical link is disconnected!"

Exit

Else

Grant= ' mysql-h$master-uslave-ptarena-bse ' show grants [email protected] '

grant_1= "GRANT REPLICATION SLAVE on * * to ' SLAVE ' @ ' 192.168.1.20 ' identified by PASSWORD ' 3907ff810e745021 '"

If ["$grant"! = "$grant _1"];then

echo "There is no grant for slave server!"

Exit

Fi

Stat_1= ' mysql-bse ' show slave status\g ' | grep slave_io_running | Awk-f ":" ' {print $} '

Stat_2= ' mysql-bse ' show slave status\g ' | grep slave_sql_running | Awk-f ":" ' {print $} '

if [$stat _1! = "Yes"];then

echo "IO progress has something wrong!"

Exit

Fi

if [$stat _2! = "Yes"];then

echo "SQL progress has something wrong!"

Exit

Fi

leti++

Done


This article is from the "Dave-Technology blog" blog, please be sure to keep this source http://davewang.blog.51cto.com/6974997/1855106

Check the state of the database server from the MySQL master-slave synchronization structure-script shell

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.