mysql Fpmmm是MPM的升級版,相對而言,fpmmm要比mpm使用起來更方便,但是需要開啟相應的優化參數
1,配置pid
復制啟動腳本
cp support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
service mysqld start
pid-file=/var/run/mysqld/mysqld.pid
配置環境變量
vim /etc/profile.d/mysql.sh
export PATH=/usr/local/mysql/bin:$PATH
sh vim /etc/profile.d/mysql.sh
添加配置文件中的pid
[root@localhost mysql]# vim /etc/mysql/my.cnf
pid-file=/var/run/mysqld/mysqld.pid
[root@localhost mysql]# mkdir /var/run/mysqld
[root@localhost mysql]# chown -R mysql.mysql /var/run/mysqld
[root@localhost mysql]# /etc/init.d/mysqld start
2,安裝zabbx-agnet
rpm -ivh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm
yum install -y zabbix-agent-2.4.7 zabbix-sender-2.4.7 zabbix-2.4.7 agent-2.4.7
vim /etc/zabbix/zabbix_server.conf
Server=192.168.128.128
erverActive=192.168.128.128
Hostname=Zabbix server
3,fpmmm監控
yum install php-cli php-process php-mysqli
cat << _EOF >/etc/php.d/fpmmm.ini
variables_order = "EGPCS"
date.timezone = 'Europe/Zurich'
_EOF
下載fpmmm
wget -P /usr/local/ https://support.fromdual.com/admin/download/fpmmm-0.10.5.tar.gz
cd /usr/local
tar xf fpmmm-0.10.5.tar.gz
ln -s fpmmm-0.10.5 fpmmm
cd fpmmm
mkdir /etc/fpmmm
cp /usr/local/fpmmm/tpl/fpmmm.conf.template /etc/fpmmm/fpmmm.conf
chown -R zabbix: /etc/fpmmm
授權fpmmm、
vim /etc/profile.d/mysql.sh
export PATH=/usr/local/mysql/bin:$PATH
sh vim /etc/profile.d/mysql.sh
mysql -e "GRANT ALL ON *.* TO 'fpmmm'@'192.168.158.130' IDENTIFIED BY 'password';""
mysql -e "GRANT ALL ON *.* TO 'fpmmm'@'127.0.0.1' IDENTIFIED BY 'password';"
添加zabbix用戶到mysql
usermod -G mysql zabbix
修改fpmm配置文件
[root@localhost fpmmm]# egrep -v "^#|^$" /etc/fpmmm/fpmmm.conf
[default]
Type = mysqld
LogLevel = 2
LogFile = /tmp/fpmmm/fpmmm.log
CacheFileBase = /tmp/fpmmm/fpmmmCache
AgentLockFile = /tmp/fpmmm/fpmmm.lock
Username = fpmmm
Password = password
MysqlHost = 127.0.0.1
MysqlPort = 3306
ZabbixServer = 192.168.158.128
Disabled = false
Modules = innodb master myisam mysql process security
PidFile = /var/lib/mysql/mysqld.pid
[mysql-master] # This MUST match Hostname in Zabbix!
Type = mysqld
Modules = fpmmm server
[mysql-master] # This MUST match Hostname in Zabbix!
Type = mysqld
MysqlPort = 3306
Modules = process mysql myisam innodb master slave security
PidFile = /var/run/mysqld/mysqld.pid
測試
[root@localhost fpmmm]# /usr/local/fpmmm/bin/fpmmm --config=/etc/fpmmm/fpmmm.conf
1
添加mysql.check
vim /etc/zabbix/zabbix_agentd.conf
UserParameter=FromDual.MySQL.check,/usr/lcaol/fpmmm/bin/fpmmm --config=/etc/fpmmm/fpmmm.conf
計劃任務
[root@localhost fpmmm]# crontab -l
* * * * * /usr/local/fpmmm/bin/fpmmm --config=/etc/fpmmm/fpmmm.conf >/dev/null
觀察日志
96402:2016-05-10 12:09:02.338 - WARN: Instance db2 seems not to be a Slave. (rc=1577).
96402:2016-05-10 12:09:02.373 - INFO: FromDual Performance Monitor for MySQL and MariaDB (fpmmm) run finished (rc=0).
96608:2016-05-10 12:10:01.438 - INFO: FromDual Performance Monitor for MySQL and MariaDB (fpmmm) (0.10.5) run started.
96608:2016-05-10 12:10:02.616 - WARN: Instance db2 seems not to be a Slave. (rc=1577).
96608:2016-05-10 12:10:02.649 - INFO: FromDual Performance Monitor for MySQL and MariaDB (fpmmm) run finished (rc=0).
96808:2016-05-10 12:11:01.678 - INFO: FromDual Performance Monitor for MySQL and MariaDB (fpmmm) (0.10.5) run started.
96808:2016-05-10 12:11:02.823 - WARN: Instance db2 seems not to be a Slave. (rc=1577).
96808:2016-05-10 12:11:02.866 - INFO: FromDual Performance Monitor for MySQL and MariaDB (fpmmm) run finished (rc=0).
97010:2016-05-10 12:12:01.891 - INFO: FromDual Performance Monitor for MySQL and MariaDB (fpmmm) (0.10.5) run started.
97010:2016-05-10 12:12:03.048 - WARN: Instance db2 seems not to be a Slave. (rc=1577).
97010:2016-05-10 12:12:03.081 - INFO: FromDual Performance Monitor for MySQL and MariaDB (fpmmm) run finished (rc=0).
97210:2016-05-10 12:13:01.137 - INFO: FromDual Performance Monitor for MySQL and MariaDB (fpmmm) (0.10.5) run started.
97210:2016-05-10 12:13:02.322 - WARN: Instance db2 seems not to be a Slave. (rc=1577).
97210:2016-05-10 12:13:02.355 - INFO: FromDual Performance Monitor for MySQL and MariaDB (fpmmm) run finished (rc=0).
97411:2016-05-10 12:14:01.380 - INFO: FromDual Performance Monitor for MySQL and MariaDB (fpmmm) (0.10.5) run started.
97411:2016-05-10 12:14:02.534 - WARN: Instance db2 seems not to be a Slave. (rc=1577).
97411:2016-05-10 12:14:02.569 - INFO: FromDual Performance Monitor for MySQL and MariaDB (fpmmm) run finished (rc=0).
97611:2016-05-10 12:15:01.607 - INFO: FromDual Performance Monitor for MySQL and MariaDB (fpmmm) (0.10.5) run started.
97611:2016-05-10 12:15:02.765 - WARN: Instance db2 seems not to be a Slave. (rc=1577).
97611:2016-05-10 12:15:02.799 - INFO: FromDual Performance Monitor for MySQL and MariaDB (fpmmm) run finished (rc=0).
97811:2016-05-10 12:16:01.846 - INFO: FromDual Performance Monitor for MySQL and MariaDB (fpmmm) (0.10.5) run started.
97811:2016-05-10 12:16:03.003 - WARN: Instance db2 seems not to be a Slave. (rc=1577).
97811:2016-05-10 12:16:03.037 - INFO: FromDual Performance Monitor for MySQL and MariaDB (fpmmm) run finished (rc=0).
98011:2016-05-10 12:17:01.095 - INFO: FromDual Performance Monitor for MySQL and MariaDB (fpmmm) (0.10.5) run started.
98011:2016-05-10 12:17:02.263 - WARN: Instance db2 seems not to be a Slave. (rc=1577).
98011:2016-05-10 12:17:02.304 - INFO: FromDual Performance Monitor for MySQL and MariaDB (fpmmm) run finished (rc=0).
查看圖
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設備狀態信息