nagios监控mysql主从复制
?環(huán)境:
Centos5.6 mysql只做同步指定庫,沒有同步mysql庫用戶數(shù)據(jù)
登陸從服務器mysql,添加驗證的用戶
?
grant replication client on *.* to 'slave'@localhost identified by '123456';
flush privileges;
?
查看是否添加成功
select user,host from mysql.user
?
在從服務器安裝 nrpe,然后在配置文件nrpe.cfg加入一行
?
command[check_mysql_slave]=/usr/local/nagios/libexec/check_mysql_slave
添加這個文件內容:
vi /usr/local/nagios/libexec/check_mysql_slave?
?
?#!/bin/sh?
declare -a slave_is
slave_is=($(/usr/local/mysql/bin/mysql -uslave -p123456 -e "show slave status\G"|grep Running |awk '{print $2}'))
if [ "${slave_is[0]}" = "Yes" -a "${slave_is[1]}" = "Yes" ]
? ? ?then
? ? ?echo "OK -slave is running"?
? ? ?exit 0
else
? ? ?echo "Critical -slave is error"?
? ? ?exit 2
fi
?
再執(zhí)行這個腳本,觀察輸出情況
?
/usr/local/nagios/libexec/check_nrpe -H 192.168.10.231
?
/usr/local/nagios/libexec/check_nrpe -H 192.168.10.231 -c check_mysql_slave
?
在主監(jiān)控服務里面添加了重啟
?
define service {
host_name 192.168.10.232
service_description check_mysql_slave
check_period 24x7
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
contact_groups mygroup
notification_interval 5
notification_period 24x7
notification_options w,u,c,r
check_command check_nrpe!check_mysql_slave
}
本文轉自奔跑在路上博客51CTO博客,原文鏈接http://blog.51cto.com/qiangsh/1575726如需轉載請自行聯(lián)系原作者
qianghong000
總結
以上是生活随笔為你收集整理的nagios监控mysql主从复制的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: INTERSPEECH 2017系列 |
- 下一篇: 为Docker Swarm添加调度策略