linux上zabbix监控mysql主从状态
1:主从mysql上,建立监控用户
#建立zabbix监控用户(只有查询权限)
grant select on *.* to zabbix@'127.0.0.1' identified by '密码';
grant select on *.* to zabbix@'localhost' identified by '密码';
##建立监控mysql用户
grant replication client on *.* to 'zabbix'@'localhost' identified by '密码'
grant replication client on *.* to 'zabbix'@'127.0.0.1' identified by '密码';FLUSH PRIVILEGES;
2:自定义监控项(从库上)
vim /etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf
#slave从存活:
UserParameter=mysql.slave,mysql -uzabbix -p"Thk~@#8695gHf" -e "show slave status \G;" 2> /dev/null | grep -E 'Slave_IO_Running: Yes|Slave_SQL_Running: Yes' | grep -c Yes
重启zabbix-agnet
3:web端添加监控项