Cacti監控MySQL實現過程中碰到的問題解匯總

來源:互聯網
上載者:User

前言:cacti監控mysql伺服器的大概50張graphs都弄出來了,也出圖了,其中遇到一些問題,印象比較深刻的記錄如下:

(一):添加io監控

 

點擊Create Graphs for this Host 進去建立IO的圖,結果報錯

This data query returned 0 rows, perhaps there was a problem executing this data query. You can run this data query in debug mode  to get more information.


進入*Turn On Graph Debug Mode模式,報錯如下:

RRDTool Command:

/usr/bin/rrdtool graph - \

--imgformat=PNG \

--start=-86400 \

--end=-300 \

--title='db-m2-slave-1 - Traffic' \

--rigid \

--base=1000 \

--height=120 \

--width=500 \

--alt-autoscale-max \

--lower-limit='0' \

--vertical-label='bits per second' \

--slope-mode \

--font TITLE:10: \

--font AXIS:7: \

--font LEGEND:8: \

--font UNIT:7: \

CDEF:cdefa='a,8,*' \

AREA:cdefa#00CF00FF:'Inbound'  \

GPRINT:cdefa:LAST:' Current\:%8.2lf %s'  \

GPRINT:cdefa:AVERAGE:'Average\:%8.2lf %s'  \

GPRINT:cdefa:MAX:'Maximum\:%8.2lf %s\n'  \

LINE1:cdefa#002A97FF:'Outbound'  \

GPRINT:cdefa:LAST:'Current\:%8.2lf %s'  \

GPRINT:cdefa:AVERAGE:'Average\:%8.2lf %s'  \

GPRINT:cdefa:MAX:'Maximum\:%8.2lf %s\n'

RRDTool Says:

ERROR: invalid rpn expression in: a,8,*,如所示

 

 

編輯linux主機下的/etc/snmp/snmpd.conf檔案
找到:com2sec notConfigUser  default       public 
修改成:com2sec notConfigUser  all       public
找到:access  notConfigGroup ""      any       noauth    exact  systemview none none
修改成:access  notConfigGroup ""      any       noauth    exact  all none none
找到:#view all    included  .1     80把該行的#去掉,
找到:#view mib2   included  .iso.org.dod.internet.mgmt.mib-2 fc 把改行的#去掉,
重起snmpd:/etc/init.d/snmpd restart


(二):MySQL添加主機出不來圖

[root@squid-2 test]# service httpd restart

停止 httpd:                                               [確定]

正在啟動 httpd:httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

                                                           [確定]

1)  進入設定檔目錄

cd  /etc/httpd/conf/

2)編輯httpd.conf檔案,搜尋"#ServerName",添加ServerName localhost:80
[root@server conf]# ls
extra  httpd.conf  magic  mime.types  original
[root@server conf]# vi httpd.conf
#ServerName www.example.com:80
ServerName localhost:80
3)再重新啟動apache 即可。

 

(三):啟動報錯

[root@squid-2 error]# tail -f /var/log/httpd/error_log

[Sat May 31 22:49:02 2014] [notice] caught SIGTERM, shutting down

[Sat May 31 22:49:02 2014] [notice] SELinux policy enabled; httpd running as context unconfined_u:system_r:httpd_t:s0

[Sat May 31 22:49:02 2014] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)

[Sat May 31 22:49:02 2014] [notice] Digest: generating secret for digest authentication ...

[Sat May 31 22:49:02 2014] [notice] Digest: done

[Sat May 31 22:49:02 2014] [notice] Apache/2.2.15 (Unix) DAV/2 PHP/5.3.3 configured -- resuming normal operations

解決方案:直接關閉SELinux以及防火牆 


(四):MySQL監控項出圖報錯

[Sat May 31 23:20:10 2014] [error] [client 192.168.171.71] PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 523800 bytes) in /var/www/html/cacti/lib/adodb/adodb.inc.php on line 833

需要匯入cacti.sql檔案

mysql -u root -p cacti < /var/www/html/cacti/cacti.sql

 

(五):SNMP – Interface Statistics報錯

建立SNMP – Interface Statistics報錯,如下:

Created graph: db-m2-slave-2 - Traffic - |query_ifName|

ERROR: no Data Source associated. Check Template

[root@squid-2 html]# snmpwalk -c public -v 2c 10.254.3.73 ifHCInOctets

IF-MIB::ifHCInOctets = No more variables left in this MIB View (It is past the end of the MIB tree)

[root@squid-2 html]#

[root@squid-2 html]# snmpwalk -c public -v 2c 10.254.3.73 if

IF-MIB::ifTable = No Such Object available on this agent at this OID

於是再次修改snmpd.conf,並重啟snmpd
access   notConfigGroup ""       any       noauth     exact   systemview none none-->
access   notConfigGroup ""       any       noauth     exact   all     none none

[root@db-m2-slave-2 ~]# service snmpd restart

停止 snmpd:                                               [確定]

正在啟動 snmpd:                                           [確定]

[root@db-m2-slave-2 ~]#

[root@squid-2 html]# snmpwalk -c public -v 2c 10.254.3.73 if

IF-MIB::ifTable = No more variables left in this MIB View (It is past the end of the MIB tree)

【】解決

在snmpd.conf設定檔裡面,尋找以下欄位:[/color]

##           incl/excl subtree                          mask

#view all    included  .1                               80

將該行前面的"#"去掉.

之後重啟snmpd服務解決。

 

報錯(六):

移除出錯的圖


進去Consoleà Graph Management àHost(選擇出錯的主機地址)—>Search(搜尋報錯的關鍵字Used Space),就會找到報錯不出錯的Graph Title欄目,勾選右側的全選框,點擊Go按鈕刪除掉這些無效的圖即可,如所示:

然後在新出來的提示介面,點擊Continue按鈕,刪除。

 

(七):Memory Free值為nan

分析:memery free 無資料,原因: rrdtool  的記憶體上限為10G。

[root@squid-2 local]# find / -name *mem*.rrd

/var/www/html/cacti/rra/db-m2-slave-1_mem_buffers_189.rrd

/var/www/html/cacti/rra/db-master-2_mem_free_156.rrd

/var/www/html/cacti/rra/db-m2-slave-1_lock_system_memory_20.rrd

/var/www/html/cacti/rra/db-m2-slave-2_total_mem_alloc_74.rrd

/var/www/html/cacti/rra/db-m2-slave-1_total_mem_alloc_23.rrd

/var/www/html/cacti/rra/db-m2-slave-2_lock_system_memory_71.rrd

/var/www/html/cacti/rra/localhost_mem_swap_4.rrd

/var/www/html/cacti/rra/db-master-2_total_mem_alloc_117.rrd

/var/www/html/cacti/rra/db-master-2_mem_cache_155.rrd

/var/www/html/cacti/rra/db-master-2_mem_buffers_154.rrd

/var/www/html/cacti/rra/db-m2-slave-1_mem_free_191.rrd

/var/www/html/cacti/rra/localhost_mem_buffers_3.rrd

/var/www/html/cacti/rra/db-m2-slave-2_mem_free_164.rrd

/var/www/html/cacti/rra/db-m2-slave-2_mem_buffers_162.rrd

/var/www/html/cacti/rra/db-m2-slave-1_mem_buffers_54.rrd

/var/www/html/cacti/rra/db-m2-slave-1_mem_swap_55.rrd

/var/www/html/cacti/rra/db-master-2_lock_system_memory_114.rrd

/var/www/html/cacti/rra/db-m2-slave-2_mem_cache_163.rrd

/var/www/html/cacti/rra/db-m2-slave-1_mem_cache_190.rrd

/var/www/html/cacti/rra/db-master-2_mem_free_146.rrd

[root@squid-2 local]#

[root@squid-2 local]# rrdtool info /var/www/html/cacti/rra/db-m2-slave-1_mem_free_191.rrd |grep mem_free

filename = "/var/www/html/cacti/rra/db-m2-slave-1_mem_free_191.rrd"

ds[mem_free].type = "GAUGE"

ds[mem_free].minimal_heartbeat = 120

ds[mem_free].min = 0.0000000000e+00

ds[mem_free].max = 1.0000000000e+07

ds[mem_free].last_ds = "34166500"

ds[mem_free].value = NaN

ds[mem_free].unknown_sec = 2

[root@squid-2 local]#

註:ds[mem_free].max = 1.0000000000e+07  資料的最大值設定為10G

查看rrdtool如何進行修改,執行—help查看:

[root@squid-2 local]# rrdtool --help

RRDtool 1.3.8  Copyright 1997-2009 by Tobias Oetiker <tobi@oetiker.ch>

               Compiled Aug 21 2010 10:57:18

Usage: rrdtool [options] command command_options

Valid commands: create, update, updatev, graph, graphv,  dump, restore,

                   last, lastupdate, first, info, fetch, tune,

                   resize, xport

RRDtool is distributed under the Terms of the GNU General

Public License Version 2. (www.gnu.org/copyleft/gpl.html)

For more information read the RRD manpages

[root@squid-2 local]#

採用tune命令參數進行修改:

[root@squid-2 rra]# rrdtool tune *_mem_free_*.rrd mem_free:100000000

DS[mem_free] typ: GAUGE     hbt: 120   min: 0.0000      max: 10000000.0000

[root@squid-2 rra]#

有提示資訊,表名tune失敗,原來少了個-a參數,重新修改如下:

[root@squid-2 rra]# rrdtool tune *_mem_cache_*.rrd -a mem_cache:3000000000

[root@squid-2 rra]# rrdtool tune *_mem_free_*.rrd -a mem_free:3000000000

[root@squid-2 rra]# rrdtool tune *_mem_buffers_*.rrd -a mem_buffers:3000000000

[root@squid-2 rra]#

這裡發現rrdtool執行之後,只有一個host主機的的nan變成數字,其他主機的都沒有變, 之所以如此是因為rrdtool tune * -a …命令只有一個.rrd檔案起作用,其餘的需要自己手動再一次次執行rrdtool tune命令。

為了簡化操作,特意寫了一個ssh指令碼如下:

vim /root/rrdtool_increate_mem.shcd /var/www/html/cacti/rrals *_mem_free_*.rrd -1 >a_mem_free.txtfor i in `cat a_mem_free.txt`dorrdtool tune $i -a mem_free:300000000;done;ls *_mem_cache_*.rrd -1 >a_mem_cache.txtfor i in `cat a_mem_cache.txt`dorrdtool tune $i -a mem_cache:300000000;done;ls *_mem_buffers_*.rrd -1 >a_mem_buffers.txtfor i in `cat a_mem_buffers.txt`dorrdtool tune $i -a mem_buffers:300000000;done;

直接sh /root/rrdtool_increate_mem.sh即可。

 
【補充】

調試cacti的graph,步驟如下:

(1)     Console ,再進入Graph Manager ,再進入,選擇對於的Host,搜尋Memory,選中你要的圖,點選連結,比如我這裡是Memory Usage,如所示:

 

(2)     再 點擊Memory Usage連結進去,點擊右上方的Debug模式:

 

(3)     就會看到如下的debug介面,可以慢慢來觀察RRDTool Command命令,為何是-nan值。

 

 

(八):雙網卡 Traffic 網卡流量問題

如,em1和em2全部指向一個ip地址,只是em1不生效,em2生效了,但是ip地址在em1上,沒有顯示在em2一欄。

所以,在graph圖上,就沒有資料,全為-nan-值,如下所示:

在cacti伺服器上面執行check:

[root@squid-2 rra]# snmpwalk -v 2c -c public 10.254.3.72 IF-MIB::ifDescr

IF-MIB::ifDescr.1 = STRING: lo

IF-MIB::ifDescr.2 = STRING: em1

IF-MIB::ifDescr.3 = STRING: em2

IF-MIB::ifDescr.4 = STRING: em3

IF-MIB::ifDescr.5 = STRING: em4

[root@squid-2 rra]#

確實有4個網卡資訊記錄,這些都沒事,正常,經過仔細排查發現主要原因在下拉選框裡面要選擇Interface – Traffic (bits/sec),不要選擇Interface – Traffic (bytes/sec),如所示:

 

當選擇了Interface – Traffic (bits/sec)之後graph就會出資料,有了。

 


(九):InnoDB Active/Locked Transactions

RRDTool Says:

ERROR: opening '/var/www/html/cacti/rra/db-m1-slave-1_locked_transactions_215.rrd': No such file or directory

 

原因是mysql伺服器上的讓cacti訪問的mysql資料庫帳號沒有建立,建立mysql帳號好,問題解決。

 

(十):Tomcat - Connection Rate

 

RRDTool Says:

ERROR: invalid y-grid format

 依次進入Console -->Graph templates->Tomcat - Connection Rate->Unit Grid Value (--unit/--y-grid)
預設的值為1  改成為0即可。



 

 


相關文章

聯繫我們

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