欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Percona监控MySQL数据库,配置zabbix-agent和配置MySQL连接教程

程序员文章站 2023-09-05 21:59:00
配置zabbix-agent 安装percona插件 yum -y install https://www.percona.com/downloads/percona-re...

配置zabbix-agent

安装percona插件

yum -y install https://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



测试脚本




/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为正常