标签:mysql 主从复制延迟 zabbix percona-toolkit
1、在主从上分别安装percona-toolkit
wget https://www.percona.com/downloads/percona-toolkit/2.2.18/RPM/percona-toolkit-2.2.18-1.noarch.rpm
yum localinstall percona-toolkit-2.2.18-1.noarch.rpm
2、在主库上执行
pt-heartbeat --user=root --password=******* -S /var/lib/mysql/mysql.sock -D test --master-server-id=1 --update --daemonize
3、在从库上执行
pt-heartbeat --user=root --password=******* -S /var/lib/mysql/mysql.sock -D test --master-server-id=1 --monitor --print-master-server-id --daemonize --log=/tmp/slave-dely.log
4、zabbix监控
# cat /etc/zabbix/mon/slave_dely.sh
#!/bin/bash
a1=`tail -n1 /tmp/slave-dely.log |sed ‘s/s//g‘|sed ‘s/,//g‘|awk ‘{print $1,$3,$4,$5}‘`
echo $a1
# cat zabbix_agentd.d/mysql.conf
UserParameter=slave_dely0,/bin/bash /etc/zabbix/mon/slave_dely.sh |awk ‘{print $1}‘
UserParameter=slave_dely1,/bin/bash /etc/zabbix/mon/slave_dely.sh |awk ‘{print $2}‘
UserParameter=slave_dely5,/bin/bash /etc/zabbix/mon/slave_dely.sh |awk ‘{print $3}‘
UserParameter=slave_dely15,/bin/bash /etc/zabbix/mon/slave_dely.sh |awk ‘{print $4}‘
本文出自 “linux学习” 博客,请务必保留此出处http://wjlking.blog.51cto.com/4431189/1828053
标签:mysql 主从复制延迟 zabbix percona-toolkit
原文地址:http://wjlking.blog.51cto.com/4431189/1828053