Percona监控MySQL数据库

配置zabbix-agent

  • 安装percona插件
yum -y install http://www.percona.com/downloads/percona-release/redhat/0.1-6/percona-release-0.1-6.noarch.rpm
yum -y install php php-mysql percona-zabbix-templates
  • 拷贝配置文件并重启zabbix-agent
cp /var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf /etc/zabbix_agentd.conf.d/userparameter_percona_mysql.conf
systemctl restart zabbix-agent
  • 查看percona相关目录
rpm -ql percona-zabbix-templates
/var/lib/zabbix/percona
/var/lib/zabbix/percona/scripts
/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh   # 脚本调用PHP
/var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php       # PHP采集数据
/var/lib/zabbix/percona/templates
/var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf
/var/lib/zabbix/percona/templates/zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.8.xml   # 模板文件,3.x导入会报错

导入修改过的模板文件

配置MySQL连接

  • 配置php连接数据库
mysql> GRANT USAGE, PROCESS, REPLICATION CLIENT ON *.* TO 'zabbix'@'localhost' IDENTIFIED BY "zabbix00";
vim /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php.cnf
<?php
$mysql_user = 'zabbix';
$mysql_pass = 'zabbix00';
  • 测试脚本
/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh gg
73
  • 配置~zabbix/.my.cnf
vim ~zabbix/.my.cnf
[client]
user=zabbix
password='zabbix00'
  • 测试脚本
sudo -u zabbix -H /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh running-slave
# 结果为1或0为正常
posted @ 2018-07-26 14:02  Testder探索者  阅读(424)  评论(0编辑  收藏  举报