In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article shows you how to use zabbix to monitor the master and slave status of MySQL. The content is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
In general, check whether the running status of the slave from the top of the MySQL is through the Slave_IO_ running thread and the Slave_SQL_ running thread is ok, you can view it with the command "show slave status\ G;". So here's a judgment based on these two values.
Script writing and configuration on agent side
Note: I put all the scripts related to zabbix in the / etc/zabbix/script/ directory. The following are operated on the monitored side of zabbix, and the above database belongs to the master and slave of MySQL.
1) scripting
[root@srt-xt ~] # cd / etc/zabbix/script/ [root@srt-xt / etc/zabbix/script] # cat mysql_slvae_status.sh #! / bin/bash#Desc: used to obtain master-slave synchronization information, determine whether the master-slave is abnormal or not, and then submit it to zabbix#Date: 2019-06-06. LeeLay PASSWD= "nae3eabo9naeli1Oov1a" NAME=$1function IO {Slave_IO_Running= `MySQL-u $USER-p$PASSWD-e "show slave status\ G" "2 > / dev/null | grep Slave_IO_Running | awk'{print $2} '`if [$Slave_IO_Running = =" Yes "]; then echo 0 else echo 1 fi} function SQL {Slave_SQL_Running= `mysql-u $USER-p$PASSWD-e" show slave status\ G; "2 > / dev/null | grep Slave_SQL_Running: | awk' {print $2} '`if [$Slave_SQL_Running= =" Yes "]; then echo 0 else echo 1 fi} case $NAME in io) IO Sql) SQL;; *) echo-e "Usage: $0 [io | sql]" esac
2) modify the configuration file and write a self-configuration file that specifies the path of the script written above
[root@srt-xt ~] # cd / etc/zabbix/zabbix_agentd.d/ [root@srt-xt / etc/zabbix/zabbix_agentd.d] # cat userparameter_mysql_slave.conf # get MySQL slave status UserParameter=mysql.slave [*], / etc/zabbix/script/mysql_slvae_status.sh $1
3) restart zabbix-agent
[root@srt-xt / etc/zabbix/zabbix_agentd.d] # / etc/init.d/zabbix-agent restart
4) Test on the zabbix-server to see if the value can be obtained successfully. Through the above script, 0 means normal and 1 means abnormal.
[root@xxxxx ~] # zabbix_get-s 218.75.249.55-k mysql.slave [sql] 0 [root@xxxxx ~] # zabbix_get-s 218.75.249.55-k mysql.slave [io] 0
Server-side web configuration
1) configure Slave_IO_Running thread monitoring items
2) configure Slave_SQL_Running thread monitoring items
3) configure triggers for Slave_IO_Running threads
4) configure triggers for Slave_SQL_Running threads
5) configure trigger action
Configure the actions to be performed in the action (send a message to the administrator)
Configure the action when the state is restored (also send messages to the administrator)
Finally view the monitoring item
The above content is how to use zabbix to monitor the master-slave status of MySQL. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are 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.