1. 程式人生 > >ZABBIX 3.X載入percona mysql外掛來監控mysql5.6的詳細實現過程

ZABBIX 3.X載入percona mysql外掛來監控mysql5.6的詳細實現過程

http://blog.csdn.net/crpp0902/article/details/77978405

部署完zabbix,自帶的對於mysql的監控指令碼遠遠不能滿足DBA日常監控的需要,percona就有這個詳細監控的模版以及指令碼,剛好能用於DBA日常的監控。

1、需要安裝php指令碼執行環境

percona監控zabbix的指令碼使用php寫的,所以需要準備好php執行環境:

yum install -yphp php-mysql 

2、安裝 percona-zabbix-templates
yum install https://www.percona.com/downloads/percona-monitoring-plugins/1.1.6/percona-zabbix-templates-1.1.6-1.noarch.rpm

安裝完,我們介紹幾個重要檔案:

[[email protected] zabbix_agentd.d]# cd /var/lib/zabbix/percona/
[[email protected] percona]# ls
scripts  templates
[[email protected] percona]#
[[email protected] scripts]# cd ../templates/
[[email protected] templates]# ls -alt
total 292
drwxr-xr-x. 2 root root   4096 Sep 14 01:33 .
drwxr-xr-x. 4 root root   4096 Sep 13 21:52 ..
-rw-r--r--. 1 root root  18866 Jan 11  2016 userparameter_percona_mysql.conf
-rw-r--r--. 1 root root 269258 Jan 11  2016 zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.6.xml
[
[email protected]
templates]# ls -alt ../scripts/ total 72 drwxr-xr-x. 2 root root 4096 Sep 14 01:40 . -rwxr-xr-x. 1 root root 1259 Sep 14 01:40 get_mysql_stats_wrapper.sh -rwxr-xr-x. 1 root root 59634 Sep 13 22:23 ss_get_mysql_stats.php

*scripts目錄下get_mysql_stats_wrapper.sh指令碼是監控獲取MySQL狀態的,ss_get_mysql_stats.php檔案是配置連線資料庫使用者名稱密碼的。用shell來呼叫PHP。

* templates目錄下conf檔案是要放在agent端/etc/zabbix/zabbix_agentd.d/下面的,用於定義監控的items,XML檔案是模版檔案(這個模板目前還不支援zabbix 3,需要進行修改)

3、匯入模板xml檔案到zabbix server

報錯:Invalid tag"/zabbix_export/date": "YYYY-MM-DDThh:mm:ssZ" is expected.

解決:這個模板還不支援zabbix,需要修改xml模板檔案,網上有對應ZABBIX 3的模板匯入即可。

4、修改相關指令碼:

vim get_mysql_stats_wrapper.sh
修改:
RES=`HOME=~zabbix mysql -e 'SHOW SLAVESTATUS\G' | egrep '(Slave_IO_Running|Slave_SQL_Running):' | awk -F: '{print$2}' | tr '\n
為:
RES=`HOME=~/usr/bin/mysql -e 'SHOW SLAVE STATUS\G' | egrep'(Slave_IO_Running|Slave_SQL_Running):' | awk -F: '{print $2}' | tr '\n' ','`

修改
HOST=localhost
為:
HOST=192.168.174.133 


vim ss_get_mysql_stats.php    
$mysql_user = 'zabbix';
$mysql_pass = '123456';
$mysql_port = 3306;

cp/var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf/etc/zabbix/zabbix_agentd.d/userparameter_percona_mysql.conf

測試監控項:
[[email protected] templates]#  /usr/bin/php -q /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php--host localhost --items gg

ERROR: Access denied for user'zabbix'@'localhost' (using password: YES)

 [[email protected]]#  /usr/bin/php -q/var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php --host 192.168.174.133--items gg

gg:28

5、應用percona模板到監控:



檢視相應監控資料圖表:


碰到問題:

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)"

執行測試發現發現是檔案許可權不對:

[[email protected] 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
22
[[email protected] 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

修改許可權後測試正常:

[[email protected] zabbix]# chown zabbix:zabbix /tmp/192.168.174.133-mysql_cacti_stats.txt

[[email protected] zabbix]# zabbix_get -s 192.168.174.133 -p 10050 -k  "MySQL.Threads-connected"
22
[[email protected] zabbix]# zabbix_get -s 192.168.174.133 -p 10050 -k  "MySQL.Key-read-requests"
152

檢視日誌也正常:
[[email protected] 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




相關推薦

ZABBIX 3.X載入percona mysql外掛監控mysql5.6詳細實現過程

http://blog.csdn.net/crpp0902/article/details/77978405 部署完zabbix,自帶的對於mysql的監控指令碼遠遠不能滿足DBA日常監控的需要,percona就有這個詳細監控的模版以及指令碼,剛好能用於DBA日常的監

zabbix3.0.4使用percona-monitoring-plugins插件監控mysql5.6詳細實現過程

sta moni nod .rpm exp oss percona 密碼 slave zabbix3.0.4使用percona-monitoring-plugins插件來監控mysql5.6的詳細實現過程 因為Zabbix自帶的MySQL監控沒有提供可以直接使用的Key,所

Zabbix 3 中使用 Percona Monitoring Plugins 監控 MySQL

zabbix1、安裝監控插件wget https://www.percona.com/downloads/percona-monitoring-plugins/percona-monitoring-plugins-1.1.7/binary/redhat/6/x86_64/percona-zabbix-temp

Cent OS 7.x 安裝Zabbix 3.x

zabbix centos 系統環境: VMware Workstation 12 Pro 12.5.0Cent OS 7.3_1611Zabbix 3.2---以下操作均以root身份操作---1:設置網卡為開機啟動Shell>ifconfig1. [root@localhost

使用percona mysql插件監控mysql5.7

cacti 5.7 cat upload php -s my.cnf load 監控 1、安裝 php yum install -y php php-mysql 2、安裝 percona-zabbix yum install -y https://www.percona.c

zabbix 3.2添加Oracle表空間監控

zabbix查看博文:http://7424593.blog.51cto.com/7414593/1910111?utm_source=tuicool&utm_medium=referral 註意:在zabbix中添加監控項時需要把PROCESS_NAME改為TABLESPACE_NAMEzabbix

zabbix 3.4 直接 發現埠並作存活監控(帶服務名)

      客戶端配置 1.指令碼 [[email protected] home]# cat /home/port_service.sh #!/bin/bash#by Mr.lu#su rootportarray=(`sudo -u root /usr/bi

zabbix監控mysql5.6版本出不了圖,怎麽辦?這裏有解決辦法!!!

echo line 進行 password 搭建過程 using 部署 所在 取數 問題:今天我把本地的zabbix對mysql監控的部署系統轉到雲主機上,發現出現下圖的情況(搭建過程可參考http://blog.51cto.com/xiaozhagn/2059430)然

記一次MySQL遷移並從MySQL5.6升級到5.7後查詢慢了幾十倍的問題

打印 ins 狀態 sql語句 top 引用 為什麽 區別 image 起因 因為生產環境數據量越來越大,客戶越來越多,項目功能也越來越多,項目本身也越來越多,導致之前的服務器內存、硬盤都已經漸漸的不夠用了,當時出現了2種解決方案,增加服務器配置和新購服務器,但是就算是新增

mysql 5.7.14 二進位制版本詳細安裝過程

安裝環境: DISTRIB_ID=Ubuntu DISTRIB_RELEASE=12.04 DISTRIB_CODENAME=precise 安裝版本        mysql5.7.7及以上做了很多改變,5.7.7以前安裝方法和以前差不多,初始化也保留了mysql_in

RedHat6.9中編制安裝zabbix-3.4.7,DB用percona mysql 5.7.20

zabbix percona mysql linux 監控 zabbix配置 軟件版本:Redhat6.9zabbix-3.4.7percona mysql-5.7.20 準備工作:關閉防火墻,或者添加相應端口。關閉selinux ———— (安裝如下zabbix依賴包)————####這

CentOS 7.x下部署和配置zabbix 3.2.x監控工具

centos zabbix 監控一.安裝zabbix服務端1.下載官方yum源:rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm2.安裝zabbix服務端(會自動安裝http

Zabbix 3.2.6通過ODBC監控MySQL

zabbix一、總覽 ODBC的監控和在Zabbix前端配置數據庫監控條目類型基本一致。 ODBC是用C語言編寫的用於連接數據庫管理系統的一個中間件,最初有微軟公司研發,後來發展到各大平臺。 有了ODBC的支持,Zabbix可以查詢很多種數據庫,因為Zabbix自己不直接去連接數據庫,而是通

Zabbix 3.0 監控MySQL

監控 zabbix mysql Mysql監控   zabbix自帶了一個監控mysql的模板,但是真正監控mysql的並不是zabbix自帶的模板。而是percona公司的一個監控mysql模板  percona官網: www.percona.comPercona組成介紹1、php腳本 用

基於CentOS 7.x上部署Zabbix 3.4

zabbix 3.4 監控 linux 服務器 1、安裝zabbix最新版epel源:rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-1.el7.centos.noarch.rpm2、安

Zabbix結合插件percona監控mysql數據

restart ffffff include clu 成功 -- www 2.4 type Zabbix結合插件percona監控mysql數據 按道理來說zabbix就

python 3.x 學習筆記18 (mysql 未完 )

offset targe name屬性 表結構 不用 創建用戶 ant 書籍 主鍵 1.數據庫(Database)是按照數據結構來組織、存儲和管理數據的倉庫 2.RDBMS即關系數據庫管理系統(Relational Database Management System)的特

Zabbix 3.0.X 配置客戶端自動註冊(Auto-Registration)

zabbix auto_registration 自動註冊 一、客戶端配置 1、配置zabbix官方源 [root@node11 ~]# rpm -iUh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el

Confluence 6 MySQL 3.x 字符集編碼問題

-c 錯誤 height 頁面 tro -i tin order embedded MySQL 3.x is 已知在大寫和小寫轉換的時候有些問題(non-ASCII)。問題診斷請按照 Troubleshooting Character Encodings 頁面中的內容對問題

zabbix通過插件percona進行監控MySQL

down star 插件安裝 令行 load 發現 new 解決方法 自帶 Zabbix結合插件percona監控mysql數據 因為MySQL的自帶模板監控的東西太