mysql主从告警测试(zabbix微信告警配置)

告警测试(mysql主从)

192.168.68.181    master

192.168.68.183    slave

 

master:

[[email protected] ~]# vim /etc/my.cnf

[mysqld]

log-bin=node181-bin

server-id=1

systemctl start mariadb

 

MariaDB [(none)]> show master status;

#授权

MariaDB [(none)]> grant replication slave on *.* to "tongbu"@"192.168.68.183" identified by "123456";

MariaDB [(none)]> flush privileges;

 

slave:

[[email protected] ~]# vim /etc/my.cnf

[mysqld]

server-id=2

 

systemctl start mariadb

 

MariaDB [(none)]> stop slave ;

MariaDB [(none)]> reset slave all;

MariaDB [(none)]> show slave status\G;

 

MariaDB [(none)]> change master to  master_host="192.168.68.181", master_user="tongbu", master_password="123456", master_log_file=" node5-bin.000006", master_log_pos=941;

 

MariaDB [(none)]> slave start;

MariaDB [(none)]> show slave status\G;

 

#清除slave关系

[[email protected] src]# mysql -e "show slave status\G"

[[email protected] src]# mysql -e "show slave status\G"|grep Yes

[[email protected] src]# mysql -e "show slave status\G"|grep -c Yes

 

#修改zabbix-agent配置文件

vim /etc/zabbix_agentd.conf

# 指定监控项及获取值的方式:

UserParameter=mysql.replication.status,bash /data/sh/mysql_replication_status.sh

vim  /data/sh/mysql_replication_status.sh

bash /data/sh/mysql_replication_status.sh

 

systemctl restart zabbix-agent

 

#授权

MariaDB [(none)]> grant replication client on *.* to "zabbix"@localhost;

MariaDB [(none)]> flush privileges;

 

 

#创建监控项(配置=》主机=》监控项)

 

mysql主从告警测试(zabbix微信告警配置)

#主机mysql监控正常启用

 

mysql主从告警测试(zabbix微信告警配置)

#代理端:==》被监控端,执行正常

[[email protected] zabbixsrv]# zabbix_get -s 192.168.68.183 -k "mysql.replication.status"

2

 

#数据过来

 

mysql主从告警测试(zabbix微信告警配置)

 

#配置触发器(主从同步)

 

 

 

mysql主从告警测试(zabbix微信告警配置)

mysql主从告警测试(zabbix微信告警配置)

#配置媒介

管理==》用户==》添加媒介

 

#动作(触发器)

 

mysql主从告警测试(zabbix微信告警配置)

mysql主从告警测试(zabbix微信告警配置)

 

#微信告警

停止master,告警生成,发送微信告警

mysql主从告警测试(zabbix微信告警配置)

 

#重启master,服务正常,告警恢复

 

mysql主从告警测试(zabbix微信告警配置)

#报错:主机监控显示不支持

mysql主从告警测试(zabbix微信告警配置)

 

这是服务没有重启,键值没识别

systemctl restart zabbix-agent

mysql主从告警测试(zabbix微信告警配置)

 

需要授权()

MariaDB [(none)]> grant replication client on *.* to "zabbix"@localhost;

MariaDB [(none)]> flush privileges;

 

企业微信收到的告警

mysql主从告警测试(zabbix微信告警配置)

 

 

基于三台服务器,实现zabbix分布式监控(zabbix搭建)

https://blog.csdn.net/qq_45255414/article/details/107016099