Zabbix监控MySQL图文详解

Linux大全评论1.1K views阅读模式

注意事项:
实验环境
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

 

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、打开配置文件查看监控的内容,根据需要获取相应的参数

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

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

然后查看图形连接数

更多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

企鹅博客
  • 本文由 发表于 2020年6月8日 02:17:51
  • 转载请务必保留本文链接:https://www.qieseo.com/194171.html

发表评论