Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Design a script method for automatic monitoring synchronization from MySQL

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

The following is about the scripting method of designing automatic monitoring to synchronize from MySQL. The secret of the text is to be close to the topic. So, no more gossip, let's go straight to the following, and I'm sure you'll benefit from this article on designing scripting methods for automatic monitoring from MySQL synchronization.

Script design ideas:

1. This script should be able to adapt to a variety of different internal and external network environments, that is, different IP environments.

2. Let the script monitor whether MySQL is running properly.

3. The IO and SQL status of Slave machines must be YES, which is indispensable. Multiple conditional judgment-an is used here.

#! / bin/bash#check MySQL_Slave Status#crontab time 00grep 10MaillUserlistings MysqlUserkeeper MYSQLPORT = `netstat-na | grep "LISTEN" | grep "3306" | awk-F [: "] +'{print $5} '`MYSQLIP= `ifconfig eth0 | grep" inet addr "| awk-F [:"] +' {print $4} '`STATUS=$ (/ usr/local/mysql/bin/mysql-u $MysqlUser-$MysqlPass-e "show slave status\ G" | grep-I "running") IO_env= `echo $STATUS | grep IO | awk' {print $2} '`SQL_ Env= `echo $STATUS | grep SQL | awk'{print $2} '`if ["$MYSQLPORT" = "3306"] thenecho "mysql is running" else/bin/mail-s "warningshipserver: $MYSQLIP mysql is down" $Mail-listfiif ["$IO_env" = "Yes"-a "$SQL_env" = "Yes"] thenecho "Slave is running!" elseecho "# $date #" > / tmp/check_mysql_slave.logecho "Slave is not running! "> > / tmp/check_mysql_slave.logecho" Slave is not running! "# mail-s" warn! $MySQLIP_replicate_error "$Mail-list

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report