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监控正常启用
#代理端:==》被监控端,执行正常
[[email protected] zabbixsrv]# zabbix_get -s 192.168.68.183 -k "mysql.replication.status"
2
#数据过来
#配置触发器(主从同步)
#配置媒介
管理==》用户==》添加媒介
#动作(触发器)
#微信告警
停止master,告警生成,发送微信告警
#重启master,服务正常,告警恢复
#报错:主机监控显示不支持
这是服务没有重启,键值没识别
systemctl restart zabbix-agent
需要授权()
MariaDB [(none)]> grant replication client on *.* to "zabbix"@localhost;
MariaDB [(none)]> flush privileges;
企业微信收到的告警