阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Zabbix监控MySQL图文详解

171次阅读
没有评论

共计 2624 个字符,预计需要花费 7 分钟才能阅读完成。

注意事项:
实验环境
CentOS Linux release 7.0.1406 (Core)
[root@localhost scripts]# MySQL -v
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 10683
Server version: 5.5.52-MariaDB MariaDB Server

因为我是在一台服务器上做的,需要如下:

zabbix_agentd httpd mysqld zabbix_server

1、使用 percona 监控插件监控 MySQL
[root@localhost 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
[root@localhost alertscripts]# yum install percona-zabbix-templates php php-mysql

4、查看具体安装了什么软件
[root@localhost alertscripts]# rpm -qa php
[root@localhost scripts]# rpm -ql percona-zabbix-templates
/var/lib/zabbix/percona
/var/lib/zabbix/percona/scripts
/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh
/var/lib/zabbix/percona/scripts/ss_get_mysql_stats.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.7.xml
[root@localhost scripts]#

5、导入模板
/var/lib/zabbix/percona/templates/zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.7.xml

Zabbix 监控 MySQL 图文详解 

6、拷贝配置文件
[root@localhost alertscripts]# cp /var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf /etc/zabbix/zabbix_agentd.d/

7、脚本存放位置
[root@localhost scripts]# pwd
/var/lib/zabbix/percona/scripts

8、重启服务
[root@localhost scripts]# systemctl restart zabbix-agent

9、创建一个配置文件,内容,用户名,密码。
< 注意:生产环境中,需要创建一个监控用户 >
[root@localhost scripts]# vim ss_get_mysql_stats.php.cnf
[root@localhost scripts]# cat ss_get_mysql_stats.php.cnf
<?php
$mysql_user = ‘root’;
$mysql_pass = ‘s3cret’;(我这里 root 密码为空,因为没有设置)

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

Zabbix 监控 MySQL 图文详解

11、执行下脚本
[root@localhost scripts]# ./get_mysql_stats_wrapper.sh
获得的指标
[root@localhost scripts]# ./get_mysql_stats_wrapper.sh
7
4
4
4
2746
273953
1
20
0
0
8191
6663
1507
26
0
1507

12、脚本中有点小 BUG

Zabbix 监控 MySQL 图文详解

13、配置主机添加模板,用惯了英文换会英文界面

Zabbix 监控 MySQL 图文详解

然后查看图形连接数

Zabbix 监控 MySQL 图文详解

更多 Zabbix 相关教程集合

Ubuntu 14.04 下 Zabbix2.4.5 源码编译安装  http://www.linuxidc.com/Linux/2015-05/117657.htm

CentOS 7 LNMP 环境搭建 Zabbix3.0  http://www.linuxidc.com/Linux/2017-02/140134.htm

Ubuntu 16.04 安装部署监控系统 Zabbix2.4  http://www.linuxidc.com/Linux/2017-03/141436.htm

Zabbix 监控安装部署及警报配置  http://www.linuxidc.com/Linux/2017-03/141611.htm

Zabbix 触发器表达式详解 http://www.linuxidc.com/Linux/2017-03/141921.htm

Ubuntu 16.04 下安装部署 Zabbix3.0  http://www.linuxidc.com/Linux/2017-02/140395.htm

CentOS 6.3 下 Zabbix 监控 apache server-status http://www.linuxidc.com/Linux/2013-05/84740.htm

CentOS 7 下 Zabbix 3.0 安装详解 http://www.linuxidc.com/Linux/2017-03/141716.htm

64 位 CentOS 6.2 下安装 Zabbix 2.0.6   http://www.linuxidc.com/Linux/2014-11/109541.htm

ZABBIX 的详细介绍:请点这里
ZABBIX 的下载地址:请点这里

本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-06/144952.htm

正文完
星哥说事-微信公众号
post-qrcode
 
星锅
版权声明:本站原创文章,由 星锅 2022-01-22发表,共计2624字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中