月小升在mysql的配置上卡了3天,原因一方面不熟悉,一方面我昨天18:00配置完毕,半天没有数据,就绝望的关闭了,我昨天晚上还在纠结要不要继续研究,今天打开一看,数据图表都有了。原来mysql的监控,需要一点时间来生效。
当知道了正确的办法,我在另一台服务器配置,其实只需要3分钟
1. 关联mysql模版
步骤:配置 > 主机 > 点击主机的主机 > 模版
见图
点击那个模版进去看看模版的描述
Requirements for template operation: 1.Install Zabbix agent and MySQL client. 2.Copy Template_DB_MySQL.conf into folder with Zabbix agent configuration (/etc/zabbix/zabbix_agentd.d/ by default). Don't forget restart zabbix-agent. 3.Create MySQL user for monitoring. For example: CREATE USER 'zbx_monitor'@'%' IDENTIFIED BY '<password>'; GRANT USAGE,REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW ON *.* TO 'zbx_monitor'@'%'; For more information read the MYSQL documentation https://dev.mysql.com/doc/refman/8.0/en/grant.html , please. 4.Create .my.cnf in home directory of Zabbix agent for Linux (/var/lib/zabbix by default ) or my.cnf in c:\ for Windows. For example: [client] user=zbx_monitor password=<password> You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback/384189-discussion-thread-for-official-zabbix-template-db-mysql Template tooling version used: 0.35
2. 设置模版mysql端
备注:月小升的机器并没有/var/lib/zabbix 也找不到模版Template_DB_MySQL.conf,所以我最终用的都是另外一个userparameter_mysql.conf
1)查看zabbix中的mysql监控模板,find / -name userparameter_mysql.conf
[root@ ~]# find / -name userparameter_mysql.conf /backup/soft/zabbix-4.4.6/conf/zabbix_agentd/userparameter_mysql.conf
这个文件的第一句话
#template_db_mysql.conf created by Zabbix for "Template DB MySQL" and Zabbix 4.2
2)拷贝到zabbix_agentd.conf.d/目录下
cp –r /backup/soft/zabbix-4.4.6/conf/zabbix_agentd/userparameter_mysql.conf /usr/local/etc/zabbix_agentd.conf.d/
3)测试模版是否有效
# zabbix_agentd -t mysql.ping -c /usr/local/etc/zabbix_agentd.conf.d/userparameter_mysql.conf m