时间:2021-07-01 10:21:17 帮助过:12人阅读
若下载失败可到文末底部GitHub链接下载再安装
rpm -ivh https://www.percona.com/downloads/percona-monitoring-plugins/percona-monitoring-plugins-1.1.8/binary/redhat/7/x86_64/percona-zabbix-templates-1.1.8-1.noarch.rpm
当装完percona插件之后,默认在/var/lib/zabbix/下会生成percona目录,查看如下
[root@gzyk201808 ~]# cd /var/lib/zabbix/
[root@gzyk201808 zabbix]# ll
总用量 0
drwxr-xr-x 4 root root 38 3月 16 16:49 percona
[root@gzyk201808 zabbix]# tree percona/
percona/
├── scripts
│ ├── get_mysql_stats_wrapper.sh
│ └── ss_get_mysql_stats.php
└── templates
├── userparameter_percona_mysql.conf
└── zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.8.xml
2 directories, 4 files
cp /var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf /etc/zabbix/zabbix_agentd.d/
# 安装时已完成,可略过
grant all privileges on *.* to zabbix@localhost identified by "Zabbix@123";
[root@gzyk201808 zabbix]# vim /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php
# 依据mysql安装和数据库情况编辑
$mysql_user = ‘zabbix‘;
$mysql_pass = ‘Zabbix@123‘;
$mysql_port = 3306;
# 根据mysql安装配置修改
$mysql_socket = NUll;
chmod +x /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh
systemctl restart zabbix-agent
# 先检查是否存在 /tmp/localhost-mysql_cacti_stats.txt 文件,若不存在执行以下语句会生成该文件,默认存在该文件
/usr/bin/php -q /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php --host localhost --items gg
# 在Agent节点上配置和验证与127.0.0.1的MySQL连接,返回任何数字则表式连接成功
/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh gg
修改客户端mysql配置文件 /etc/my.cnf ,添加如下并重启客户端数据库
测试脚本,执行未报错且输出为0或1则表明测试通过
sudo -u zabbix -H /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh running-slave
chown -R zabbix.zabbix /tmp/localhost-mysql_cacti_stats.txt
chmod 755 /tmp/localhost-mysql_cacti_stats.txt
zabbix_get -s 192.168.181.136 -p10050 -k "MySQL.Threads-connected"
配置-模板-导入模板,这里提供完整模板,地址,自行选择模板类型,导入模板之后,选择相应的主机添加模板即可
011-通过安装percona插件监控MySQL
标签:str 特性 rip ble connect 数字 行数据 connected moni