zabbix監控MySQL詳解

來源:互聯網
上載者:User

標籤:設定檔   linux   release   監控   監控mysql   

注意事項:

實驗環境

CentOS Linux release 7.0.1406 (Core)

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

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

[[email protected] alertscripts]# yum install percona-zabbix-templates php php-mysql

4、查看具體安裝了什麼軟體

[[email protected] alertscripts]# rpm -qa php

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

[[email protected] scripts]# 


5、匯入模板

/var/lib/zabbix/percona/templates/zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.7.xml

650) this.width=650;" src="https://s4.51cto.com/wyfs02/M00/99/30/wKioL1lFGWLijmcBAADE9i5lqsk501.png-wh_500x0-wm_3-wmp_4-s_3335679567.png" title="zabbix01.png" alt="wKioL1lFGWLijmcBAADE9i5lqsk501.png-wh_50" />



6、拷貝設定檔

[[email protected] alertscripts]# cp /var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf /etc/zabbix/zabbix_agentd.d/

7、指令碼存放位置

[[email protected] scripts]# pwd

/var/lib/zabbix/percona/scripts

8、重啟服務

[[email protected] scripts]# systemctl restart zabbix-agent

9、建立一個設定檔,內容,使用者名稱,密碼。

<注意:生產環境中,需要建立一個監控使用者>

[[email protected] scripts]# vim ss_get_mysql_stats.php.cnf

[[email protected] scripts]# cat ss_get_mysql_stats.php.cnf

<?php

$mysql_user = ‘root‘;

$mysql_pass = ‘s3cret‘;(我這裡root密碼為空白,因為沒有設定)

9、開啟設定檔查看監控的內容,根據需要擷取相應的參數


650) this.width=650;" src="https://s2.51cto.com/wyfs02/M00/99/30/wKiom1lFGauzEbICAAGItZI4pyA883.png-wh_500x0-wm_3-wmp_4-s_3268697960.png" title="zabbix-02.png" alt="wKiom1lFGauzEbICAAGItZI4pyA883.png-wh_50" />


10、執行下指令碼

[[email protected] scripts]# ./get_mysql_stats_wrapper.sh

獲得的指標

[[email protected] scripts]# ./get_mysql_stats_wrapper.sh

7

4

4

4

2746

273953

1

20

0

0

8191

6663

1507

26

0

1507


11、指令碼中有點小BUG

650) this.width=650;" src="https://s2.51cto.com/wyfs02/M02/99/31/wKiom1lFGkLgeDIuAADAEg8zzRs320.png" title="zabbix03.png" alt="wKiom1lFGkLgeDIuAADAEg8zzRs320.png" />

11、配置主機添加模板,用慣了英文換會英文介面

650) this.width=650;" src="https://s5.51cto.com/wyfs02/M01/99/30/wKioL1lFGmjzX9q1AACX4uDT1ao646.png-wh_500x0-wm_3-wmp_4-s_1327815239.png" title="zabbix-04.png" alt="wKioL1lFGmjzX9q1AACX4uDT1ao646.png-wh_50" />

然後查看圖形串連數

650) this.width=650;" src="https://s1.51cto.com/wyfs02/M01/99/30/wKioL1lFGsyzwXXZAANLKvNcmuE684.png-wh_500x0-wm_3-wmp_4-s_3929347931.png" title="zabbix-MySQL5.png" alt="wKioL1lFGsyzwXXZAANLKvNcmuE684.png-wh_50" />

本文出自 “一杯水” 部落格,請務必保留此出處http://6528161.blog.51cto.com/6518161/1939390

zabbix監控MySQL詳解

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.