1.MPM(PERFORMANCE MONITOR FOR MYSQL)依赖的相关Perl模块安装:
yum install perl-File-Which perl-libwww-perl perl-Digest-SHA1 perl-DBD-MySQL perl-Time-HiRes perl-Crypt-SSLeay
tar zxvf mysql_performance_
2. 到我们需要的模板
cd mysql_performance_monitor_templates-0.9.1
在Zabbix Web UI导入监控所需的模板("Configuration”->”Templates”->”Import”):
Template_FromDual.l (监控mpm agent本身,这个必须导入)
Template_FromDual.l (监控Linux系统跟数据库使用相关的附加项)
Template_FromDual.l (监控各种Linux进程[比如:mysqld,ndbd])
Template_l (监控MySQL常用状态变量)
Template_FromDual.l (监控InnoDB存储引擎状态变量)
Template_l (监控MyISAM存储引擎状态变量)
Template_FromDual.l (监控MySQL主从复制的Master状态)
Template_FromDual.l (监控MySQL主从复制的Slave状态)
MPM其它用途的模板:
Template_FromDual.l (监控MySQL Cluster)
Template_FromDual.l (监控MySQL Galera Cluster)
Template_FromDual.l (监控PBXT存储引擎状态变量)
Template_FromDual.l (监控Aria存储引擎的状态变量)
Template_FromDual.l (监控DRBD设备状态信息)
从zabbix中导入我们需要的模板
3.安装MPM和配置MPM Agent的Zabbix Keys
安装MPM:
# tar zxvf mysql_performance_monitor_agent-0.9.
# mv mysql_performance_monitor_agent-0.9.1 /usr/local/mysql_performance_monitor-agent
修改FromDualMySQLagent.pl中的zabbix_sender的路径:
# cd /usr/local/mysql_performance_monitor-agent/
# sed -i 's|/usr/local/bin|/usr/local/zabbix/bin/|g' FromDualMySQLagent.pl
将MPM Agent的Keys配置添加到Zabbix Agentd配置文件目录中:
# cd /usr/local/zabbix/etc/f.d
# vi FromDual_f
# cat FromDual_f
UserParameter=FromDual.MySQL.check,/usr/local/mysql_performance_monitor-agent/FromDualMy
SQLagent.pl /usr/local/mysql_performance_monitor-agent/f
MPM Agent配置
创建MySQL监控用户mpm:
mysql> create user 'mpm'@'127.0.0.1' identified by 'mpm';
mysql> grant process, replication client on *.* to 'mpm'@'127.0.0.1';
mysql> flush privileges;
配置MPM Agent:
# cd /usr/local/mysql_performance_monitor-agent/etc
# f.f
# mkdir -p /var/log/zabbix
# mkdir -p /var/log/zabbix/cache
# touch /var/log/zabbix/FromDualMySQLagent.log
# chown -R zabbix:zabbix /var/log/zabbix
# chmod o+r /var/lib/mysql/mysqld.pid
# f
# f
[default]
# Type of section:
# mysqld for a normal MySQL database
# ndbd  for a MySQL cluster
Type        = mysqld
mysql下载libs包的网址# Debug levels are:
# 1 is logging only errors
# 2 is logging errors and wa
rnings (this is the default)
# 3 logs some informations messages as well
# 4 logs everything (for debugging purposes only)
Debug        = 2
LogFile      = /var/log/zabbix/FromDualMySQLagent.log
# Directory where the Cache files should be written to:
CacheFileBase = /var/log/zabbix/cache/FromDualAgentCache
# If you agent is not located in the same time zone as your server
# TimeShift = +0.0
# Information for MySQL connections:
Username    = mpm
Password    = mpm
MysqlHost    = 127.0.0.1
MysqlPort    = 3306
# Zabbix Server IP address
ZabbixServer = 192.168.4.15
# If section is disabled
Disabled    = false
# Possible modules for databases are:
# process mysql myisam aria innodb pbxt ndb master slave drbd galera memcache
# Possible modules for servers are:
# mpm server
# Usual modules are
Modules      = process mysql myisam innodb
# Special parameter which is used for module ndb and process
#ClusterLog  = /var/lib/mysql-cluster/ndb_1_cluster.log
# MySQL Pid file, need read permission for zabbix user
# All MySQL databases here
# Try to avoid section names with spaces!
[mysql3]  # This MUST match Hostname in Zabbix!
Type        = mysqld
MysqlPort    = 3306
Modules      = process mysql myisam innodb slave
PidFile      = /var/lib/mysql/mysqld.pid
Debug        = 1
注:这里监控的MySQL Server是MySQL主从复制的中的Slave机器.
检查MPM的监控的状态:
/usr/local/mysql_performance_monitor_agent/FromDualMySQLagent.pl /usr/local/mysql_performance_monitor_agent/f
1
返回1表示mpm的工作状态正常
重新启动 zabbix_agentd
/etc/init.d/zabbix_agentd restart
---------------------------------------->>###-----------------------------------------
----- 在调试mpm的时候需要将debug=4调试
1 安装过程遇到的错误:
4777:2015-10-13 17:45:27.488 - DBG :      /usr/local/zabbix/bin/zabbix_sender --zabbix-server 192.168.4.15 --port 10051 --host 'mysql4' --key FromDual.server.check --value '1' -vv
zabbix_sender [24834]: DEBUG: answer [{
"response":"success",
"info":"Processed 0 Failed 1 Total 1 Seconds spent 0.000021"}]
解决办法:
root@mysql4 xml]# grep "key" Template_FromDual.l
<item type="2" key="FromDual.MySQL.agent_OK" value_type="3">
<publickey></publickey>
<privatekey></privatekey>
<item type="0" key="FromDual.MySQL.check" value_type="3">
<publickey></publickey>
<privatekey></privatekey>
<item type="2" key="FromDual.MySQL.mpm.mpm_mr_version" value_type="1">
<publickey></publickey>
<privatekey></privatekey>
<item type="2" key="FromDual.MySQL.mpm.mpm_version" value_type="1">
<publickey></publickey>
<privatekey></privatekey>
<ymin_item_key></ymin_item_key>
<ymax_item_key></ymax_item_key>
我们看见value为1的值应该是FromDual.MySQL.mpm.mpm_mr_vers
ion或者FromDual.MySQL.mpm.mpm_version
[root@mysql4 lib]# grep "FromDual.server.check" * -r
FromDualMySQLagent.pm:  my $lKey    = 'FromDual.server.check';
将FromDualMySQLagent.pm文件的FromDual.server.check 替换成FromDual.MySQL.mpm.mpm_mr_version或者FromDual.MySQL.mpm.mpm_version
2.WARN: Warning: No DBD::mysql found. Please install DBD::mysql (rc=1312) 需要安装 mysql---libs php-mysql  perl-dbd-mysql

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。

发表评论