zabbix公司專屬應用程式之監控mysql 5.6版本

來源:互聯網
上載者:User

標籤:zabbix監控mysql 5.6   zabbix monitor mysql   zabbix監控mysql   zabbix monitor mysql 5.6   

最近很多人都問我如何為什麼使用我之前部落格的模板不能監控了,經過溝通發現對方的mysql版本是5.6,在進行命令列查看資料的實話,使用mysql -uxxx -pxxx -Pxxx的時候,會如下報錯

Warning: Using a password on the command line interface can be insecure

報錯原因是mysql 5.6版本增加了密碼安全性原則,之前版本可以使用的命令列裡加上密碼就會強制報錯,所以使用zabbix lld監控mysql的時候,就會由於收到此報錯導致沒辦法監控。

解決的方法為:

第一種:使用mysql 5.5的用戶端

第二種:使用--login-path(推薦)

一、mysql配置

下面是介紹如何使用--login-path設定

mysql_config_editor set --login-path=local --host=localhost --user=zabbix -p

命令解釋:

--login-path是設定訪問的名字,我設定的local;

--host是指定允許訪問的host地址,這個地址是你grant的時候配置的;

--user是使用者名稱,也是grant時候配置的;

-p是指定密碼,同樣是grant配置。

運行上面命令後,會要求你屬於密碼,輸入後會什麼反饋都沒有,可以使用下面命令查看

15:35:38 # mysql_config_editor print --all[local]user = zabbixpassword = *****host = localhost

測試

15:35:40 # mysql --login-path=localWelcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 741Server version: 5.6.19-67.0-log Percona Server (GPL), Release 67.0, Revision 618Copyright (c) 2009-2014 Percona LLC and/or its affiliatesCopyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.mysql> quit

上面就配置好了mysql安全模式訪問

二、zabbix agentd配置

下面介紹zabbix用戶端設定檔裡key的情況

預設用戶端的key是

UserParameter=mysql_stats[*],mysql -h localhost -P $1 -uzabbix -pzabbix -e "show global status"|grep "\<$2\>"|cut  -f2UserParameter=mysql_stats_slave[*],mysql -h localhost -P $1 -uzabbix -pzabbix  -e "show slave status\G"|grep "\<$2\>"|awk ‘{if($NF=="Yes") {print 1} else {print 0}}‘

修改為

UserParameter=mysql_stats_5.6[*],sudo mysql --login-path=local -P $1  -e "show global status"|grep "\<$2\>"|cut  -f2UserParameter=mysql_stats_slave_5.6[*],sudo mysql --login-path=local -P $1  -e "show slave status\G"|grep "\<$2\>"|awk ‘{if($NF=="Yes") {print 1} else {print 0}}‘

然後配置sudo,在/etc/sudoers裡添加

zabbix ALL=(root) NOPASSWD:/usr/bin/mysql

其中/usr/bin/mysql是mysql程式地址,可以根據你自身情況修改。

完成後重啟zabbix agentd

ps -ef|grep zabbix|grep -v grep|awk ‘{print $2}‘|xargs kill -9/usr/local/zabbix/sbin/zabbix_agentd -c /usr/local/zabbix/conf/zabbix_agentd.conf

其他的配置參考之前監控mysql的就行

三、zabbix web配置

A、模板匯入

把Template Mysql 5.6 Auto Discovery匯入到zabbix裡(模板在附件),具體操作不介紹。

B.主機關聯模板

把需要監控mysql 5.6版本的主機系統管理範本即可監控,預設是3600秒後自動更新。

本文出自 “吟—技術交流” 部落格,請務必保留此出處http://dl528888.blog.51cto.com/2382721/1677545

zabbix公司專屬應用程式之監控mysql 5.6版本

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.