萬盛學電腦網

 萬盛學電腦網 >> 數據庫 >> mysql教程 >> zabbix+mysql mpm監控配置步驟

zabbix+mysql mpm監控配置步驟

下面我們再來看一篇關於zabbix+mysql mpm監控配置步驟吧,希望這篇文章能夠對各位有幫助。

mysql mpm
下載mpm

wget -c http://www.shinguz.ch/download/mysql_performance_monitor-latest.tar.gz
tar xf mysql_performance_monitor-latest.tar.gz
yum install perl-File-Which perl-libwww-perl perl-Digest-SHA perl-DBD-MySQL perl-Time-HiRes
tar xf mysql_performance_monitor_agent-0.9.1.tar.gz
cd mysql_performance_monitor_agent-0.9.1
創建配置文件目錄並復制配置文件

mkdir /etc/fpmmm/
cp etc/FromDualMySQLagent.conf.template /etc/fpmmm/FromDualMySQLagent.conf
將key添加到zabbix_agentd.conf

vim /etc/zabbix/zabbix_agentd.conf
/usr/local/mysql_performance_monitor_agent-0.9.1/FromDualMySQLagent.pl /etc/fpmmm/FromDualMySQLagent.conf
並且每分鐘執行一次

[root@localhost local]# crontab -l
* * * * *  /usr/local/mysql_performance_monitor_agent-0.9.1/FromDualMySQLagent.pl /etc/fpmmm/FromDualMySQLagent.conf >/dev/null
重啟agentd

/etc/init.d/zabbix-agentd restart
mkdir -p /var/log/zabbix /var/log/zabbix/cache
chown -R zabbix: /var/log/zabbix /var/log/zabbix/cache
配置文件具體如下:

[root@localhost local]# egrep -v "^#|^$|^%" /etc/fpmmm/FromDualMySQLagent.conf
[default]
Type         = mysqld
Debug         = 2
LogFile       = /var/log/zabbix/FromDualMySQLagent.log  #如目錄不存在則創建
CacheFileBase = /var/log/zabbix/cache/FromDualAgentCache  #目錄不存在則創建
Username     = fpmmm   #授權數據庫 mysql -e "GRANT ALL  ON *.* TO 'fpmmm'@'127.0.0.1' IDENTIFIED BY 'password';"
Password     = password   #用戶授權完畢,本地測試即可
MysqlHost    = 127.0.0.1
MysqlPort    = 3306
ZabbixServer = 192.168.158.128
Disabled     = false
Modules      = process mysql myisam innodb
ClusterLog   = /var/lib/mysql-cluster/ndb_1_cluster.log
PidFile      = /var/lib/mysqld/mysqld.pid
[db1]       # This MUST match Hostname in Zabbix!  #需要和
Type         = mysqld
MysqlPort    = 3306
Modules      = process mysql myisam slave
PidFile      = /var/run/mysqld/mysqld.pid
修改配置文件

[root@localhost local]# vim /usr/local/mysql_performance_monitor_agent/lib/sendData.pm
# 注釋掉的語句如下:
 #   $rc = &FromDualMySQLagent::checkConnectionToZabbixServer($main::gParameter{'ZabbixServer'}, $main::gParameter{'ZabbixServerPort'}, $main::gParameter{'Hostname'});
目錄屬組屬主為zabbix

[root@localhost local]# ll  /var/log/zabbix/cache/
total 0
-rw-r--r--. 1 zabbix zabbix 0 May  9 06:26 FromDualAgentCache.db1.cache
[root@localhost local]#
如果報如下內容則刪除FromDualAgentCache.db1.cache即可
ERR : Load of cache file failed. rc=1301

最終日志如下:


agent


模板說明:導入即可

Template_FromDual.MySQL.mpm.xml (監控mpm agent本身,這個必須導入)
Template_FromDual.MySQL.server.xml (監控Linux系統跟數據庫使用相關的附加項)
Template_FromDual.MySQL.process.xml (監控各種Linux進程[比如:mysqld,ndbd])
Template_FromDual.MySQL.mysql.xml (監控MySQL常用狀態變量)
Template_FromDual.MySQL.innodb.xml (監控InnoDB存儲引擎狀態變量)
Template_FromDual.MySQL.myisam.xml (監控MyISAM存儲引擎狀態變量)
Template_FromDual.MySQL.master.xml (監控MySQL主從復制的Master狀態)
Template_FromDual.MySQL.slave.xml (監控MySQL主從復制的Slave狀態)
MPM其它用途的模板:

Template_FromDual.MySQL.ndb.xml (監控MySQL Cluster)
Template_FromDual.MySQL.galera.xml (監控MySQL Galera Cluster)
Template_FromDual.MySQL.pbxt.xml (監控PBXT存儲引擎狀態變量)
Template_FromDual.MySQL.aria.xml (監控Aria存儲引擎的狀態變量)
Template_FromDual.MySQL.drbd.xml (監控DRBD設備狀態信息)

copyright © 萬盛學電腦網 all rights reserved