按道理来说zabbix就自带的MySQL插件来监控mysql数据库,但是你会发现,自带的mysql监控项是很少的,根本满足不了公司的需求。
由于它本身自带的模板太过简单了,所以需要做更详细的监控,而percona就提供了这个详细监控的模版以及脚本,解决了监控不全面的问题。
percona插件是安装在zabbix-agent端的

1、percona插件安装:

首先需要下载php依赖:

ubuntu@ubuntu:~$ apt-get install php

1、官网下载percona包

https://www.percona.com/downloads/percona-monitoring-plugins/
Version: percona的版本
Software:linux server的版本
Download All Packages Together: 一起下载所有包
Download Packages Separately: 单独下载某个包
这里我们选择下载最后一个包-percona-zabbix-templates-1.1.7-1.xenial_all.ded

2、命令下载

ubuntu@ubuntu:~$ wget https://www.percona.com/downloads/percona-monitoring-plugins/1.1.7/binary/debian/xenial/x86_64/percona-zabbix-templates_1.1.7-1.xenial_all.deb

3、安装percona包

ubuntu@ubuntu:~$ sudo dpkg -i percona-zabbix-templates_1.1.7-1.xenial_all.deb
ubuntu@ubuntu:~$ cd /var/lib/zabbix/percona/templates && ll
total 292
drwxr-xr-x 2 root root 4096 Mar 25 14:19 ./
drwxr-xr-x 4 root root 4096 Mar 15 11:39 ../
-rw-r--r-- 1 root root 18866 Dec 8 2016 userparameter_percona_mysql.conf
-rw-r--r-- 1 root root 269258 Dec 8 2016 zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.7.xml

2、编辑配置文件

1、添加模板文件路径

ubuntu@ubuntu:~$ sudo mv /var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf /etc/zabbix_agentd.conf.d/

2、修改MySQL的执行命令文件,更改mysql的用户与密码:

 ubuntu@ubuntu:~$ sudo vim /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh

RES=`HOME=~ /usr/bin/mysql -uroot -pzabbix  -e 'SHOW SLAVE STATUS\G' | egrep '(Slave_IO_Running|Slave_SQL_Running):' | awk -F: '{print $2}' | tr '\n' ','`

mysql -u用户名 -p密码,这里根据自己实际情况修改

3、修改 ss_get_mysql_stats.php文件

ubuntu@ubuntu:~$ sudo vim /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php

$mysql_user = 'root';
$mysql_pass = 'zabbix';

4、重启zabbix客户端

[root@node2 templates]# /etc/init.d/zabbix_agentd restart

5、导入mysql的监控模板

模板需要先导入桌面

ubuntu@ubuntu:~$ sudo sz /var/lib/zabbix/percona/templates/zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.7.xml


                                                                   图1

6、导入出错

出现“标签无效 "/zabbix_export/date": "YYYY-MM-DDThh:mm:ssZ" 预计”,如图2所示:
 
                                                                   图2
解决方法:百度了一下说将zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.7.xml导入zabbix2.4版本中再导出。之后将新的导出xml导入到3.2中问题解决。

7、关联模板Template Percona MySQL Server


可以发现自带的监控项就一百多了,图形四十多个。

                                                                 图3

8、查看监控图像,出数据如图4、图5所示:


                                                                 图4
 

9、碰到问题:

55392:20170914:014811.374 item "SLAVE1:MySQL.State-none" became not supported: Value "rm: cannot remove `/tmp/192.168.174.133-mysql_cacti_stats.txt': Operation not permitted

21" of type "string" is not suitable for value type "Numeric (float)"

55392:20170914:014813.403 item "SLAVE1:MySQL.State-other" became not supported: Value "rm: cannot remove `/tmp/192.168.174.133-mysql_cacti_stats.txt': Operation not permitted

0" of type "string" is not suitable for value type "Numeric (float)"

执行测试发现发现是文件权限不对:

[root@slave1 zabbix]# zabbix_get -s 192.168.174.133 -p 10050 -k  "MySQL.Threads-connected"
rm: cannot remove `/tmp/192.168.174.133-mysql_cacti_stats.txt': Operation not permitted
[root@slave1 zabbix]# ls -alt /tmp/192.168.174.133-mysql_cacti_stats.txt
-rw-r--r--. 1 root root 1422 Sep 14 01:41 /tmp/192.168.174.133-mysql_cacti_stats.txt

修改权限后测试正常:

[root@slave1 zabbix]# chown zabbix:zabbix /tmp/192.168.174.133-mysql_cacti_stats.txt
[root@slave1 zabbix]# zabbix_get -s 192.168.174.133 -p 10050 -k "MySQL.Threads-connected"
22
[root@slave1 zabbix]# zabbix_get -s 192.168.174.133 -p 10050 -k  "MySQL.Key-read-requests"
152

查看日志也正常:

[root@slave1 zabbix]# tail -f zabbix_server.log

55393:20170914:015126.082 item "SLAVE1:MySQL.innodb-transactions" became not supported: cannot convert value to numeric type

55394:20170914:015127.098 item "SLAVE1:MySQL.Key-buf-bytes-unflushed" became not supported: Value "rm: cannot remove `/tmp/192.168.174.133-mysql_cacti_stats.txt': Operation not permitted

0" of type "string" is not suitable for value type "Numeric (float)"

55392:20170914:015128.100 item "SLAVE1:MySQL.Key-buf-bytes-used" became not supported: Value "rm: cannot remove `/tmp/192.168.174.133-mysql_cacti_stats.txt': Operation not permitted

1530880" of type "string" is not suitable for value type "Numeric (float)"

55392:20170914:015129.120 item "SLAVE1:MySQL.key-buffer-size" became not supported: Value "rm: cannot remove `/tmp/192.168.174.133-mysql_cacti_stats.txt': Operation not permitted

8388608" of type "string" is not suitable for value type "Numeric (float)"

55395:20170914:015130.166 item "SLAVE1:MySQL.Key-read-requests" became not supported: cannot convert value to numeric type

55393:20170914:015131.169 item "SLAVE1:MySQL.Key-reads" became not supported: cannot convert value to numeric type

55393:20170914:015132.182 item "SLAVE1:MySQL.Key-write-requests" became not supported: cannot convert value to numeric type

55392:20170914:015252.792 item "SLAVE1:MySQL.slave-lag" became supported

55393:20170914:015253.795 item "SLAVE1:MySQL.Slave-open-temp-tables" became supported

55393:20170914:015255.830 item "SLAVE1:MySQL.slave-running" became supported

55395:20170914:015256.873 item "SLAVE1:MySQL.slave-stopped" became supported

55393:20170914:015304.906 item "SLAVE1:MySQL.State-closing-tables" became supported

55392:20170914:015305.913 item "SLAVE1:MySQL.State-copying-to-tmp-table" became supported

55395:20170914:015306.925 item "SLAVE1:MySQL.State-end" became supported

55392:20170914:015307.934 item "SLAVE1:MySQL.State-freeing-items" became supported

Ubuntu下Zabbix结合percona监控mysql数据的更多相关文章

  1. Zabbix通过percona监控MySQL

    因为Zabbix自带的MySQL监控没有提供可以直接使用的Key,所以一般不采用,业界的同学们都使用Percona Monitoring Plugins 监控 MySQL的方式 Percona介绍 P ...

  2. zabbix通过第三方插件percona监控mysql数据库

     zabbix通过第三方插件percona监控mysql数据库                                                                     ...

  3. Ubuntu下Zabbix安装及使用问题

    1.configure: error: MySQL library not found MySQL library not found root@kallen:~# apt-get install l ...

  4. Ubuntu下Zabbix服务器监控工具部署

    Ubuntu下Zabbix服务器监控工具部署 一 安装安装Apache.Mysql.Php.zabbix sudo apt-get update sudo apt-get install apache ...

  5. 分布式监控系统Zabbix-3.0.3-完整安装记录(7)-使用percona监控MySQL

    前面已经介绍了分布式监控系统Zabbix-3.0.3-完整安装记录(2)-添加mysql监控,但是没有提供可以直接使用的Key,太过简陋,监控效果不佳.要想更加仔细的监控Mysql,业内同学们都会选择 ...

  6. zabbix自动发现监控mysql

    一. 数据库给只读权限 1.1 grant usage on *.* to 'zabbix'@'127.0.0.1' identified by 'zabbix'; flush privileges; ...

  7. zabbix入门之监控MySQL

    zabbix入门之监控MySQL 这里使用的是zabbix官方自带的MySQL监控模板. 首先确保在被监控主机安装zabbix-agent.zabbix-sender,并且将主机加入监控节点.具体操作 ...

  8. CentOS下使用MyTop实时监控MySQL

    CentOS下使用MyTop实时监控MySQL MyTop的项目页面为:http://jeremy.zawodny.com/mysql/mytop/ MyTop安装 $ yum -y install ...

  9. Ubuntu下使用C语言连接Mysql 8.0客户端教程

    Ubuntu下如何C语言程序连接MYSQL 8.0(全教程) 1. 安装GCC(略) 2. 安装mysql(本人使用的是最新MySQL 8.0版本) sudo apt install mysql-cl ...

随机推荐

  1. Java入门到精通——调错篇之Astah Community打开报需要jre1.7运行环境

    1.问题概述     Astah Community安装完以后点击运行Astah Community的时候报此应用需要jdk1.7如下图     但是我的电脑在D盘装了jdk1.8了为什么这个软件为什 ...

  2. Codeforces Round #412 A Is it rated ?

    A. Is it rated? time limit per test  2 seconds memory limit per test  256 megabytes Is it rated? Her ...

  3. 【2014-08-23】Beyong Coding

        be a product engineer,not be a engineer 选择比努力更重要   just code it,code it ,until you make it 缺的不是i ...

  4. java面试题之----Java内部类

    这是我学习Java内部类的笔记 1.为什么使用内部类? 使用内部类最吸引人的原因是:每个内部类都能独立地继承一个(接口的)实现,所以无论外围类是否已经继承了某个(接口的)实现, 对于内部类都没有影响 ...

  5. 一张图看懂CSS cascade, specific, importance, inheritance

    http://www.w3.org/TR/CSS21/cascade.html#inheritance http://www.w3.org/TR/CSS21/cascade.html#cascade ...

  6. glyphicons-halflings-regular.woff2 not found 前台错误修正

    错误内容如下: 首先在 web.config 里面加上如下内容: <system.webServer> <staticContent> <remove fileExten ...

  7. 在Visualsvn Server上创建svn账号和密码

    VisualSVN Server是一个集成的svn服务端工具,是一款svn服务端不可多得的好工具.可以先安装好VisualSVN Server后,运行VisualSVN Server Manger,然 ...

  8. Linux入门-2 VIM基础

    启动与退出 模式 进入插入模式 命令 删除.复制.粘贴 光标控制 查找与替换 EX模式 启动与退出 vim只启动vim vim <filename>打开文件,如果不存在则新建 模式 Nor ...

  9. 通过CXF,开发rest协议接口

    1. 引入cxf的jar包 pom文件里面直接增加依赖 < dependency> <groupId > junit</ groupId> <artifact ...

  10. 理解Underscore中的uniq函数

    uniq函数,是Underscore中的一个数组去重函数,给它传递一个数组,它将会返回该数组的去重副本. 1 ES6版本去重 在ES6版本中,引入了一个新的数据结构——set,这是一种类似数组的数据结 ...