Ubuntu下Zabbix结合percona监控mysql数据
按道理来说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数据的更多相关文章
- Zabbix通过percona监控MySQL
因为Zabbix自带的MySQL监控没有提供可以直接使用的Key,所以一般不采用,业界的同学们都使用Percona Monitoring Plugins 监控 MySQL的方式 Percona介绍 P ...
- zabbix通过第三方插件percona监控mysql数据库
zabbix通过第三方插件percona监控mysql数据库 ...
- Ubuntu下Zabbix安装及使用问题
1.configure: error: MySQL library not found MySQL library not found root@kallen:~# apt-get install l ...
- Ubuntu下Zabbix服务器监控工具部署
Ubuntu下Zabbix服务器监控工具部署 一 安装安装Apache.Mysql.Php.zabbix sudo apt-get update sudo apt-get install apache ...
- 分布式监控系统Zabbix-3.0.3-完整安装记录(7)-使用percona监控MySQL
前面已经介绍了分布式监控系统Zabbix-3.0.3-完整安装记录(2)-添加mysql监控,但是没有提供可以直接使用的Key,太过简陋,监控效果不佳.要想更加仔细的监控Mysql,业内同学们都会选择 ...
- zabbix自动发现监控mysql
一. 数据库给只读权限 1.1 grant usage on *.* to 'zabbix'@'127.0.0.1' identified by 'zabbix'; flush privileges; ...
- zabbix入门之监控MySQL
zabbix入门之监控MySQL 这里使用的是zabbix官方自带的MySQL监控模板. 首先确保在被监控主机安装zabbix-agent.zabbix-sender,并且将主机加入监控节点.具体操作 ...
- CentOS下使用MyTop实时监控MySQL
CentOS下使用MyTop实时监控MySQL MyTop的项目页面为:http://jeremy.zawodny.com/mysql/mytop/ MyTop安装 $ yum -y install ...
- Ubuntu下使用C语言连接Mysql 8.0客户端教程
Ubuntu下如何C语言程序连接MYSQL 8.0(全教程) 1. 安装GCC(略) 2. 安装mysql(本人使用的是最新MySQL 8.0版本) sudo apt install mysql-cl ...
随机推荐
- Javascript之DOM的三大节点及部分用法
DOM有三种节点:元素节点.属性节点.文本节点. 一.用nodeType可以检测节点的类型 节点类型 nodeType属性值 元素节点 1 属性节点 2 文本节点 3 这样方便在js中对各个节点进行操 ...
- react-native 在Xcode上传到iTunes Connect里报错
在xcode里面点击“upload to app store”的时候,提示“the session's status is FAILED and the error description is 'C ...
- Android已上线应用开源分享中(第一季)
这是我上线的第一个android应用,在百度.腾讯.豌豆荚等平台测试通过,也有了部分用户,还是可以的啊,哈哈.现在分享给大家,当然,源码我也会分享. 1.软件是一个管理wifi的小工具 (1)查询.连 ...
- Python初学者第四天 二进制运转换
4day 1.二进制运算 a.十进制转换二进制 342 转换成二进制 342 101010110 Python提供了一种简单的计算二进制的方法:bin() b.文字转换成二进制 ASCII码表 GB ...
- Fatal error: Call to undefined function fnmatch() 解决
我的PHP版本是5.6.30,linux 是CentOS 6.6,nginx,也不知啥问题,看了官方: https://secure.php.net/manual/en/function.fnmatc ...
- MARKS:路由器桥接
仅供参考…… 测试使用环境:Tplink & Tenda渣渣路由器.其他环境或不同. 设置注意事项:副路由器网段设置和主路由一致.主路由不需要开启WDS.副路由器开启WDS(连接ok,状态即显 ...
- 全文检索之solr学习
solr下载: http://www.apache.org/dyn/closer.lua/lucene/solr/7.3.1 学习教程 除了官网的教程,一切教程都是可以有错误的. https://lu ...
- RBTree和AVL
红黑树和AVL的相同:都是平衡二叉树,所以插入删除修改查询都非常高效. 红黑树和AVL的区别: 红黑树: 不是要求绝对平衡,付出的代价是要着色,查询次数可能会多一层,好处是减少旋转次数. AVL ...
- 从数据库反向生成django的models
有办法实现django 数据库反向生成models的方法吗?答案是肯定的. 1. 配置 settings.py 中的数据库配置部分 DATABASES = { 'default': { 'ENGINE ...
- 「uoj#188. 【UR #13】Sanrd」
题目 不是很能看懂题意,其实就是求\([l,r]\)区间内所有数的次大质因子的和 这可真是看起来有点鬼畜啊 这显然不是一个积性函数啊,不要考虑什么特殊的函数了 我们考虑Min_25筛的过程 设\(S( ...