- 論壇徽章:
- 0
|
你還在用mrtg嗎?--使用cacti監(jiān)測(cè)系統(tǒng)性能
第二部分:Cacti的安裝
該安裝文檔是我參照www.cacti.net上的官方文檔進(jìn)行安裝后,總結(jié)出來(lái)的。平臺(tái)是Linux或FreeBSD。
1、安裝mysql
cacti從0.4.8g版本開(kāi)始支持mysql5數(shù)據(jù)庫(kù) (2006/1/12更新)
下載源碼:
http://www.signal42.com/mirrors/mysql/Downloads/MySQL-4.0/mysql-4.0.23.tar.gz
for linux:
http://www.signal42.com/mirrors/mysql/Downloads/MySQL-4.0/mysql-standard-4.0.23-pc-linux-i686.tar.gz
for freebsd47:
http://www.signal42.com/mirrors/mysql/Downloads/MySQL-4.0/mysql-standard-4.0.22-unknown-freebsd4.7-i386.tar.gz
上面的鏈接已經(jīng)失效,請(qǐng)到
http://dev.mysql.com/downloads/mysql/4.1.html
或
http://www.mysql.com
下載mysql數(shù)據(jù)庫(kù)
安裝:
- shell>; groupadd mysql
- shell>; useradd -g mysql mysql
- shell>; cd /usr/local
- shell>; gunzip < /PATH/TO/MYSQL-VERSION-OS.tar.gz | tar xvf -
- shell>; ln -s FULL-PATH-TO-MYSQL-VERSION-OS mysql
- shell>; cd mysql
- shell>; scripts/mysql_install_db --user=mysql
- shell>; chown -R root .
- shell>; chown -R mysql data
- shell>; chgrp -R mysql .
- shell>; bin/mysqld_safe --user=mysql &
復(fù)制代碼
./bin/mysqladmin -u root password "yourpasswd" 基于安全的原因,為root用戶設(shè)置密碼才能讓root用戶登陸mysql,不然會(huì)有2002錯(cuò)誤出現(xiàn)
建立啟動(dòng)腳本:
- cp ./support-files/mysql.server /etc/init.d/mysql
- ln -s ../init.d/mysql S85mysql
- ln -s ../init.d/mysql K85mysql
復(fù)制代碼
2、安裝apache
下載:
http://apache.freelamp.com/httpd/httpd-2.0.54.tar.bz2
安裝:
- ./configure --prefix=/www --enable-so
- make && make install
復(fù)制代碼
建立啟動(dòng)腳本
- cp /www/bin/apachectl /etc/init.d/httpd
- cd /etc/rc3.d
- ln -s ../init.d/httpd S85httpd
- ln -s ../init.d/httpd K85httpd
復(fù)制代碼
啟動(dòng)
/www/bin/apachectl start
3、安裝php
下載:
http://us4.php.net/get/php-4.3.10.tar.gz/from/cn2.php.net/mirror
安裝:
- /configure --prefix=/www/php --with-apxs2=/www/bin/apxs --with-config-file-path=/www/php --enable-sockets --with-mysql=/usr/local/mysql --with-zlib-dir=/usr/include --with-gd
- make && make install
- cp php.ini-dist /www/php/php.ini
- vi /www/conf/httpd.conf
- 加入:
- ###############for php and cacti###################
- AddType application/x-tar .tgz
- AddType application/x-httpd-php .php
- AddType image/x-icon .ico
- DirectoryIndex index.php index.html index.html.var
- #######################over########################
- ../bin/apachectl restart
復(fù)制代碼
4、設(shè)置mysql
- # mysql -u root -prootroot
- 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
復(fù)制代碼
5、安裝rrdtool
下載:
http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/pub/rrdtool-1.0.x/rrdtool-1.0.50.tar.gz
然后
./configure
make && make install 即可
與mrtg相比,rrdtool自帶了gd庫(kù),所以不用先安裝gd庫(kù).(不過(guò)由于rrdtool自帶的gd庫(kù)不支持中文,所以rrdtool畫(huà)出來(lái)的圖也不能有中文,否則會(huì)出現(xiàn)亂碼).
注意:rrdtool1.2的版本由于已經(jīng)不再自帶外部的lib庫(kù)(如cgilib,zlib等),所以需要從http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/pub/libs/下載這些庫(kù)來(lái)安裝。建議還是使用1.0的版本,比較方便。
6、安裝net-snmp
幾乎所有的網(wǎng)絡(luò)設(shè)備和操作系統(tǒng)默認(rèn)都安裝了snmp服務(wù)。
unix系統(tǒng)安裝的都是net-snmp或ucd-snmp(其實(shí)兩個(gè)都是同一組人寫(xiě)的)。
如果沒(méi)有安裝snmp,可以到net-snmp.sourceforge.org上下載源碼編譯安裝。
我這里說(shuō)的安裝SNMP服務(wù)并不是要求安裝SNMPD,其實(shí)是Cacti需要用到net-snmp中的兩個(gè)命令――snmpwalk和snmpget進(jìn)行數(shù)據(jù)的采集。
我們可以直接在系統(tǒng)中運(yùn)行snmpwalk和snmpget看是否有該命令,如果有則不用安裝了。
7、安裝cacti
注意:寫(xiě)該文檔時(shí)cacti的最高版本時(shí)0.8.6c,現(xiàn)在的最高版本是0.8.6f。由于0.8.6f以下的版本有SQL注入漏洞,請(qǐng)大家下載0.8.6f或以上的版本進(jìn)行安裝。
下載:
http://www.cacti.net/downloads/cacti-0.8.6c.tar.gz
安裝:
- cp cacti-0.8.6c.tar.gz /www/htdocs
- tar xzvf cacti-0.8.6c.tar.gz
- mv cacti-0.8.6c cacti
- cd cacti
復(fù)制代碼
導(dǎo)入表:
- /usr/local/mysql/bin/mysql –u root –prootroot cactidb < cacti.sql
- chown –R cactiuser rra/ log/
復(fù)制代碼
設(shè)置配置文件:
- vi /www/htdocs/cacti/include/config.php
- $database_type = “mysql”;
- $database_default = “cactidb”;
- $database_hostname = “l(fā)ocalhost”;
- $database_username = “cactiuser”;
- $database_password = “cactipw”;
復(fù)制代碼
核對(duì)以上幾項(xiàng)是否正確
- Crontab –u cactiuser –e
- 為cactiuser用戶加入
- */5 * * * * /www/php/bin/php /www/htdocs/cacti/poller.php >; /dev/null 2>;&1
復(fù)制代碼
(不要使用root用戶運(yùn)行上面的命令,否則要再運(yùn)行一次chown –R cactiuser rra/ log/)
8、頁(yè)面設(shè)置:
在瀏覽器上輸入:
http://IP/cacti
進(jìn)入cacti的初始設(shè)置頁(yè)面:
在這里我們要輸入一些原始的信息:
NEXT -》
輸入一些信息,如rrdtool、php、snmpwalk、snmpget的位置,使用ucd-snmp還是net-snmp等 -》
輸入原始的用戶和密碼:admin/admin -》
更改admin用戶的密碼 -》
點(diǎn)擊 Save
安裝完成。!
現(xiàn)在可以在瀏覽器中進(jìn)入Cacti的世界了!
[ 本帖最后由 joecen 于 2006-1-13 10:36 編輯 ] |
|