In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you "how shell monitors mysql master-slave replication". The content is simple and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "how shell monitors mysql master-slave replication".
Description:
The monitoring script is tested normally under rhel5. Other versions of linux system should be tested by yourself. For some preparatory work, please see this article.
Code:
The code is as follows:
# Monitoring mysql master-slave replication
Cat chk_mysql_rep.sh
#! / bin/bash
#
# script_name:chk_mysql_rep.sh
# check mysql replication
#
# ssh root@xen "/ usr/local/mysql/bin/mysql-uroot-pdongnan-e 'show slave status\ G'-ss" | awk' / Running:/ {print $2}'
# Yes
# Yes
#
# variables
Ssh=/usr/bin/ssh
Sh_dir=/root/sh/
Crondir=$ {sh_dir} crontab
Source ${sh_dir} CONFIG
Hosts= "$DB_SLAVE_HOSTS"
# main
# the main loop traverses the machine www.yisu.com
For HOST in $hosts;do
Log=$crondir/log/mysql_replication_error.log
Key=$ ($ssh root@$HOST "/ usr/local/mysql/bin/mysql-uroot-pdongnan-e 'show slave status\ G'-ss" | awk' / Running:/ {printf $2}')
# hosts that cannot be connected, skip this cycle
Test-z "$key" & & continue
# the result returned is true
If ["$key" = = "YesYes"]; then
# flag true, deactivate the alarm
If [- f "${crondir} / log/$HOST.mysql"]; then
# sms
# for mobile in $MOBILES;do
# echo "$HOST replication ok" | / usr/local/bin/gammu-- sendsms TEXT "$mobile"-unicode
# done
For mail in $MAILS;do
Echo "$HOST replication ok" | mail-s "$HOST replication ok" $mail
Done
# flag
Rm-f "${crondir} / log/$HOST.mysql"
Fi
# return result is false
Else
Check_date=$ (date'+% F% T')
# flag leave, call the police
If [!-f "${crondir} / log/$HOST.mysql"]; then
# sms www.yisu.com
# for mobile in $MOBILES;do
# echo "$HOST replication error" | / usr/local/bin/gammu-- sendsms TEXT "$mobile"-unicode
# done
For mail in $MAILS;do
Echo "$HOST replication error" | mail-s "$HOST replication error" $mail
Done
# flag
Echo "replication error" > "${crondir} / log/$HOST.mysql"
# log
Echo "$check_date $HOST mysql replicaton error" > > $log
Fi
Fi
#
Done
#
The above is all the contents of the article "how shell monitors mysql master-slave replication". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.