Linux下如何安裝Cacti
Cacti的安裝
該安裝文檔的平臺(tái)是Linux,其它平臺(tái)上的安裝方法請(qǐng)參照Cacti的官方網(wǎng)站。
本文講述的是Linux下如何安裝Cacti、Linux下如何配置Cacti、Linux下如何使用Cacti
在FreeBSD下也沒(méi)問(wèn)題。
運(yùn)行Cacti需要Apache(Lighttpd)+PHP+MySQL的環(huán)境,搭建該環(huán)境的方法很簡(jiǎn)單,很多文章有過(guò)詳細(xì)的安裝教程,就不在此贅述了。下面是安裝Cacti的步驟:
1、設(shè)置mysql
創(chuàng)建數(shù)據(jù)庫(kù)、數(shù)據(jù)庫(kù)用戶(hù),調(diào)整權(quán)限、密碼:
- # mysql -u root
- Welcome to the MySQL monitor. Commands end with ; or g.
- Your MySQL connection id is 10 to server version: 4.0.23-standard
- Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the buffer.
- mysql>; create database cactidb;
- Query OK, 1 row affected (0.00 sec)
- mysql>; grant all on cactidb.* to root;
- Query OK, 0 rows affected (0.01 sec)
- mysql>; grant all on cactidb.* to root@localhost;
- Query OK, 0 rows affected (0.01 sec)
- mysql>; grant all on cactidb.* to cactiuser;
- Query OK, 0 rows affected (0.00 sec)
- mysql>; grant all on cactidb.* to cactiuser@localhost;
- Query OK, 0 rows affected (0.01 sec)
- mysql>; set password for cactiuser@localhost=password(’cactipw’);
- Query OK, 0 rows affected (0.00 sec)
- mysql>; exit
2.安裝RRDTool
從RRDTool官方網(wǎng)站(見(jiàn)文章最后的“資源”)下載最新的RRDTool包,當(dāng)前最新的版本是rrdtool-1.2.12。在該下載頁(yè)面上,還可以看到有一個(gè)“l(fā)ibs”的目錄,里面的包也要全部下載。
那么,我們下載了下面的幾個(gè)包:
◆libart_lgpl-2.3.17
◆libpng-1.2.8-config
◆zlib-1.2.2
◆freetype-2.1.9
安裝方法:
- ./configure –prefix=/usr #把東西裝到 /usr 目錄下
- make ; make install #編譯及安裝
安裝完上述lib包后,我們就可以進(jìn)行RRDTool的安裝了:
rrdtool-1.2.12包的安裝方法:
- cd rrdtool-1.2.12
- ./configure –prefix=/usr
- make && make install
測(cè)試:
運(yùn)行rrdtool –v
可以看到RRDTool的用法以及版本信息:
- RRDtool 1.2.12 Copyright 1997-2005 by Tobias Oetiker
- Compiled Apr 30 2006 11:30:36
- Usage: rrdtool [options] command command_options
- Valid commands: create, update, updatev, graph, dump, restore,
- last, 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
RRDTool官方的詳細(xì)安裝方法可以在下載的RRDTool源碼里的doc/rrdbuild.pod文件里找到。
3.安裝SNMP采集工具
SNMP全名是簡(jiǎn)單網(wǎng)絡(luò)管理協(xié)議,幾乎所有的網(wǎng)絡(luò)設(shè)備(交換機(jī)、路由器等)和操作系統(tǒng)默認(rèn)都安裝了snmp服務(wù)。
Cacti 系統(tǒng)所在的服務(wù)器并不一定要安裝SNMP服務(wù),但是Cacti系統(tǒng)采集數(shù)據(jù)要用到Net-SNMP包里面的幾個(gè)工具,所以最好也在Cacti服務(wù)器上安裝 SNMP服務(wù)。我們可以直接在系統(tǒng)中運(yùn)行snmpwalk和snmpget看是否有該命令,如果有則無(wú)需安裝了。
如果操作系統(tǒng)沒(méi)有安裝SNMP,可以到本文最后的資源里的Net-SNMP官方網(wǎng)站上下載源碼或二進(jìn)制包進(jìn)行安裝。
4.安裝Cacti
Cacti是一套PHP程序,當(dāng)前最新版本是0.8.6h。安裝時(shí)需要對(duì)Cacti包文件和數(shù)據(jù)庫(kù)進(jìn)行部分設(shè)置。
假設(shè)apache的DocumentRoot目錄為/www/htdocs:
- cp cacti-0.8.6h.tar.gz /www/htdocs
- tar xzvf cacti-0.8.6h.tar.gz
- mv cacti-0.8.6h cacti
- useradd cactiuser –d /www/htdocs/cacti
導(dǎo)入數(shù)據(jù)庫(kù)、設(shè)置權(quán)限:
- cd /www/htdocs/cacti
- mysql -u root cactidb < cacti.sql
- chown -R cactiuser rra/ log/
編輯配置文件/www/htdocs/cacti/include/config.php :
- $database_type = “mysql”;
- $database_default = “cactidb”;
- $database_hostname = “l(fā)ocalhost”;
- $database_username = “cactiuser”;
- $database_password = “cactipw”;
定時(shí)讓Cacti的poller取數(shù)據(jù):
- crontab –u cactiuser –e
加入:
- */5 * * * * /www/php/bin/php /www/htdocs/cacti/poller.php > /dev/null 2>&1
注意:不要使用root用戶(hù)運(yùn)行上面的“poller.php”命令,否則請(qǐng)?jiān)俅芜\(yùn)行chown –R cactiuser rra/ log/
本文講述的是Linux下如何安裝Cacti、Linux下如何配置Cacti、Linux下如何使用Cacti
【編輯推薦】