监控MySQL

1、使用percona监控插件监控MySQL

[[email protected] alertscripts]# yum install http://www.percona.com/downloads/percona-release/redhat/0.1-4/percona-release-0.1-4.noarch.rpm

2、percona组成部分

  • PHP脚本

  • shell脚本去调用PHP脚本

  • zabbix配置文件

  • zabbix模板文件

3、安装percona-zabbix模板 PHP PHP-MySQL

[[email protected] alertscripts]# yum install percona-zabbix-templates php php-mysql

4、查看具体安装了什么软件

[[email protected] alertscripts]# rpm -qa php

zabbix之监控监控MySQL

5、导入模板

模板见附件

zabbix之监控监控MySQL

6、拷贝配置文件

[[email protected] alertscripts]# cp /var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf /etc/zabbix/zabbix_agentd.d/

7、脚本存放位置

[[email protected] scripts]# pwd

/var/lib/zabbix/percona/scripts

8、重启服务

[[email protected] scripts]# systemctl restart zabbix-agent

9、创建一个配置文件,内容,用户名,密码。

<注意:生产环境中,需要创建一个监控用户>

[[email protected] scripts]# vim ss_get_mysql_stats.php.cnf

[[email protected] scripts]# cat ss_get_mysql_stats.php.cnf

<?php

$mysql_user = 'root';

$mysql_pass = 's3cret';(我这里root密码为空,因为没有设置)

9、打开配置文件查看监控的内容,根据需要获取相应的参数

zabbix之监控监控MySQL

10、执行下脚本

[[email protected] scripts]# ./get_mysql_stats_wrapper.sh

获得的指标

zabbix之监控监控MySQL

11、配置主机添加模板

zabbix之监控监控MySQL

然后查看图形

连接数

zabbix之监控监控MySQL