CentOs安裝cacti

來源:互聯網
上載者:User

標籤:

虛擬機器地址 192.168.24.69,

附件中的三個檔案可以用SSH FILE工具上傳到root檔案夾下,方便後續操作

一、安裝所需要的軟體
(1)在主監控機上安裝apache+php+gd的web環境,推薦編譯安裝,在此直接用yum安裝。

#yum install -y php php-mysql php-snmp mysql mysql-server net-snmp net-snmp-libs net-snmp-utils php-pdo perl-DBD-MySQL
(2)在主監控機上安裝rrdtool,rrdtool依賴的包過多,所以選擇增加源,然後用yum安裝

#yum install -y rrdtool rrdtool-devel rrdtool-php

(3)配置snmp

#vi /etc/snmp/snmpd.conf

#service snmpd start
#service mysqld start

#加入開機啟動

#chkconfig snmpd on

#chkconfig --level 345 mysqld on


(4)安裝cacti
#把解壓後的包移動到你的相應的web目錄

#tar xvf cacti-0.8.7g.tar.gz
#mv cacti-0.8.7g /var/www/html/cacti

(5)在資料庫中建庫、授權、匯入資料庫結構
#注意匯入cacti.sql時該檔案的路徑

#mysql -p
mysql> create database cacti;
mysql> grant all privileges on cacti.* to [email protected] identified by ‘cacti‘ with grant option;
mysql> grant all privileges on cacti.* to [email protected] identified by ‘cacti‘ with grant option;
mysql> use cacti;
mysql> source /var/www/html/cacti/cacti.sql;
#配置cacti以串連資料庫,主要修改串連資料庫所對應的使用者和密碼

#vi /var/www/html/cacti/include/config.php

#啟動httpd開啟web服務

#service httpd start

 

#加入開機啟動

 

#chkconfig --level 345 httpd on

(6)瀏覽器開啟 http://192.168.24.69/cacti

 

#如果遇到403fobidden,關閉selinux服務

不需要重啟,但是重啟後還要再次執行

#setenforce 0

或者直接修改config,將SELINUX設定為disable,需要重啟

#vi /etc/selinux/config

   

 

  • 第一次訪問時點擊2次next,點擊finish(確保頁面中所有路徑都是File Found),
  • 預設登入帳號密碼都是admin
  • 登入後會提示修改密碼

(7)增加入一個計劃任務,使得 cacti 每五分鐘產生一個監控圖表。
#crontab -e
# 加入如下內容。注意poller.php的路徑
*/5 * * * * php /var/www/html/cacti/poller.php > /dev/null 2>&1

# 確保 /var/www/html/cacti/rra/目錄存在
# 如果暫時未看到圖表,可以手工執行,組建圖表
#php /var/www/html/cacti/poller.php > /dev/null 2>&1

 

二、cacti常用外掛程式安裝

#先安裝patch命令工具

#yum install patch

#tar xvf cacti-plugin-0.8.7g-PA-v2.8.tar.gz
#cp -R cacti-plugin-arch/* /var/www/html/cacti/
#cd /var/www/html/cacti/

#mysql -ucacti -pcacti cacti < pa.sql
#patch -p1 -N < cacti-plugin-0.8.7g-PA-v2.8.diff

#vi include/config.php
修改為$url_path = “/cacti/”;

 

 

 

三、安裝Monitor監控外掛程式

 

Monitor:http://docs.cacti.net/plugin:monitor

#tar zxvf monitor-latest.tgz
#mv monitor/ /var/www/html/cacti/plugins/monitor

 

開啟後便能在導覽列中看到Monitor了

四、安裝mysql監控

(1)

#tar zxvf better-cacti-templates-1.1.8.tar.gz
#cd better-cacti-templates-1.1.8

#cp scripts/ss_get_mysql_stats.php /var/www/html/cacti/scripts/ 修改ss_get_myqsl_stats.php#vi /var/www/html/cacti/scripts/ss_get_mysql_stats.php

(2)配置MySQL伺服器,讓cacti所在機器能夠訪問MySQL伺服器的狀態資訊,必須擁有”process”許可權。如果要監控InnoDB狀態,還必須有”SUPER”許可權。

mysql> grant process,super on *.* to ‘cacti‘@‘%‘ identified by ‘cacti‘;
mysql> grant all privileges on cacti.*  to [email protected]"%" identified by "cacti";

 

 

(3)在瀏覽器中匯入模版

(4)Console->Device->Localhost中添加Templates

按save儲存

(5)在頁面上方,點擊Create Graphs for this host

(6)在graphs就能看到mysql監控的圖了(等待一會資料就會出來)

 

參考資料,個人實踐中發現參考資料中有些錯誤,在本文中已經改正

http://foreveryan.blog.51cto.com/3508502/671274

附件下載:https://app.yinxiang.com/shard/s41/res/6d7e088b-faf5-4345-8358-621df8362e91/cacti-0.8.7g.tar.gzhttps://app.yinxiang.com/shard/s41/res/bd2ed818-ebb9-46b1-9917-a4f2b818db6c/cacti-plugin-0.8.7g-PA-v2.8.tar.gzhttps://app.yinxiang.com/shard/s41/res/1ed398ad-38fd-4192-a77c-87a475fa6790/monitor-v1.2-1.tgzhttps://app.yinxiang.com/shard/s41/res/27e42b8c-1345-466b-9060-59ae34a5a200/better-cacti-templates-1.1.8.tar.gz 

CentOs安裝cacti

相關文章

聯繫我們

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