天天看點

Zabbix 3 中使用 Percona Monitoring Plugins 監控 MySQL

1、安裝監控插件

wget https://www.percona.com/downloads/percona-monitoring-plugins/percona-monitoring-plugins-1.1.7/binary/redhat/6/x86_64/percona-zabbix-templates-1.1.7-2.noarch.rpm

rpm -ivh percona-zabbix-templates-1.1.7-2.noarch.rpm 

yum install percona-zabbix-templates php php-mysql -y

2、修改zabbix agent配置檔案

cp /var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf /usr/local/zabbix/etc/zabbix_agentd.conf.d/

vim /usr/local/zabbix/etc/zabbix_agentd.conf

Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/

killall -9 zabbix_agentd

/usr/local/zabbix/sbin/zabbix_agentd

3、建立mysql賬号

mysql> GRANT SELECT,PROCESS,SUPER,REPLICATION CLIENT ON *.* TO 'zabbixmoniter'@'localhost' IDENTIFIED BY "123456";

mysql> flush privileges;

4、修改插件配置檔案

vim /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php

$mysql_user = 'zabbixmoniter';

$mysql_pass = '123456';

$mysql_port = 3306;

$mysql_socket = '/tmp/mysql.sock';

5、建立zabbix使用者MySQL使用者賬号(監控slave用)

su - zabbix

vim ~/.my.cnf 

[client]

user = zabbixmoniter

password = 123456

socket = /tmp/mysql.sock

6、測試slave

sh /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh running-slave

7、導入模闆

模闆下載下傳位址:

<a href="http://jaminzhang.github.io/soft-conf/Zabbix/zbx_percona_mysql_template.xml" target="_blank">http://jaminzhang.github.io/soft-conf/Zabbix/zbx_percona_mysql_template.xml</a>

參考博文:

<a href="http://www.ywnds.com/?p=6199" target="_blank">http://www.ywnds.com/?p=6199</a>

<a href="http://10880347.blog.51cto.com/346720/1932100" target="_blank">http://10880347.blog.51cto.com/346720/1932100</a>

<a href="http://jaminzhang.github.io/monitoring/Monitoring-MySQL-using-Percona-Monitoring-Plugins-in-Zabbix/" target="_blank">http://jaminzhang.github.io/monitoring/Monitoring-MySQL-using-Percona-Monitoring-Plugins-in-Zabbix/</a>

     本文轉自1321385590 51CTO部落格,原文連結:http://blog.51cto.com/linux10000/1950862,如需轉載請自行聯系原作者