How to monitor the master-slave fault is normal? MySQL Database learning

Source: Internet
Author: User

Send message when write monitoring script is out of sync

#!/bin/bash

. /etc/init.d/functions

function Check () {

rep_file=/tmp/rep$ (date +%f). txt

While True

Do

rep= ('/application/mysql/bin/mysql-e ' show slave status\g "|awk '/slave_sql_running:/{print $2};/slave_io_running:/{ Print $2};$1~/seconds_behind_master/{print $ ' |xargs ')

If ["${rep[0]}"! = "yes"]; Then

echo "Slave_io_running:no" > $rep _file

Break 1

Fi

If ["${rep[1]}"! = "yes"]; Then

echo "Slave_sql_running:no" > $rep _file

Fi

If ["${rep[2]}"-ne 0]; Then

echo "Seconds_behind_master delay" > $rep _file

Break 1

Fi

Sleep 3

Done

}

function Main () {

While True

Do

Check

Mail-s "Replication False" [email protected] </tmp/rep$ (date +%f). txt

Internet companies mostly use the database is MySQL, want to stand out from the many IT workers, need to have advanced technology, learning to add value is essential. The way of learning is your insistence.


How to monitor the master-slave fault is normal? MySQL Database learning

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.