Linux下如何安裝Cacti
Cacti的安裝
該安裝文檔的平臺是Linux,其它平臺上的安裝方法請參照Cacti的官方網(wǎng)站。
本文講述的是Linux下如何安裝Cacti、Linux下如何配置Cacti、Linux下如何使用Cacti
在FreeBSD下也沒問題。
運行Cacti需要Apache(Lighttpd)+PHP+MySQL的環(huán)境,搭建該環(huán)境的方法很簡單,很多文章有過詳細的安裝教程,就不在此贅述了。下面是安裝Cacti的步驟:
1、設置mysql
創(chuàng)建數(shù)據(jù)庫、數(shù)據(jù)庫用戶,調整權限、密碼:
- # 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)站(見文章最后的“資源”)下載最新的RRDTool包,當前最新的版本是rrdtool-1.2.12。在該下載頁面上,還可以看到有一個“l(fā)ibs”的目錄,里面的包也要全部下載。
那么,我們下載了下面的幾個包:
◆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包后,我們就可以進行RRDTool的安裝了:
rrdtool-1.2.12包的安裝方法:
- cd rrdtool-1.2.12
- ./configure –prefix=/usr
- make && make install
測試:
運行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官方的詳細安裝方法可以在下載的RRDTool源碼里的doc/rrdbuild.pod文件里找到。
3.安裝SNMP采集工具
SNMP全名是簡單網(wǎng)絡管理協(xié)議,幾乎所有的網(wǎng)絡設備(交換機、路由器等)和操作系統(tǒng)默認都安裝了snmp服務。
Cacti 系統(tǒng)所在的服務器并不一定要安裝SNMP服務,但是Cacti系統(tǒng)采集數(shù)據(jù)要用到Net-SNMP包里面的幾個工具,所以最好也在Cacti服務器上安裝 SNMP服務。我們可以直接在系統(tǒng)中運行snmpwalk和snmpget看是否有該命令,如果有則無需安裝了。
如果操作系統(tǒng)沒有安裝SNMP,可以到本文最后的資源里的Net-SNMP官方網(wǎng)站上下載源碼或二進制包進行安裝。
4.安裝Cacti
Cacti是一套PHP程序,當前最新版本是0.8.6h。安裝時需要對Cacti包文件和數(shù)據(jù)庫進行部分設置。
假設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
導入數(shù)據(jù)庫、設置權限:
- 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”;
定時讓Cacti的poller取數(shù)據(jù):
- crontab –u cactiuser –e
加入:
- */5 * * * * /www/php/bin/php /www/htdocs/cacti/poller.php > /dev/null 2>&1
注意:不要使用root用戶運行上面的“poller.php”命令,否則請再次運行chown –R cactiuser rra/ log/
本文講述的是Linux下如何安裝Cacti、Linux下如何配置Cacti、Linux下如何使用Cacti
【編輯推薦】