- 論壇徽章:
- 0
|
你還在用mrtg嗎?--使用cacti監(jiān)測系統性能
第二部分:Cacti的安裝
該安裝文檔是我參照www.cacti.net上的官方文檔進行安裝后,總結出來的。平臺是Linux或FreeBSD。
1、安裝mysql
cacti從0.4.8g版本開始支持mysql5數據庫 (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
上面的鏈接已經失效,請到
http://dev.mysql.com/downloads/mysql/4.1.html
或
http://www.mysql.com
下載mysql數據庫
安裝:
- 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 &
復制代碼
./bin/mysqladmin -u root password "yourpasswd" 基于安全的原因,為root用戶設置密碼才能讓root用戶登陸mysql,不然會有2002錯誤出現
建立啟動腳本:
- cp ./support-files/mysql.server /etc/init.d/mysql
- ln -s ../init.d/mysql S85mysql
- ln -s ../init.d/mysql K85mysql
復制代碼
2、安裝apache
下載:
http://apache.freelamp.com/httpd/httpd-2.0.54.tar.bz2
安裝:
- ./configure --prefix=/www --enable-so
- make && make install
復制代碼
建立啟動腳本
- cp /www/bin/apachectl /etc/init.d/httpd
- cd /etc/rc3.d
- ln -s ../init.d/httpd S85httpd
- ln -s ../init.d/httpd K85httpd
復制代碼
啟動
/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
復制代碼
4、設置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
復制代碼
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庫,所以不用先安裝gd庫.(不過由于rrdtool自帶的gd庫不支持中文,所以rrdtool畫出來的圖也不能有中文,否則會出現亂碼).
注意:rrdtool1.2的版本由于已經不再自帶外部的lib庫(如cgilib,zlib等),所以需要從http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/pub/libs/下載這些庫來安裝。建議還是使用1.0的版本,比較方便。
6、安裝net-snmp
幾乎所有的網絡設備和操作系統默認都安裝了snmp服務。
unix系統安裝的都是net-snmp或ucd-snmp(其實兩個都是同一組人寫的)。
如果沒有安裝snmp,可以到net-snmp.sourceforge.org上下載源碼編譯安裝。
我這里說的安裝SNMP服務并不是要求安裝SNMPD,其實是Cacti需要用到net-snmp中的兩個命令――snmpwalk和snmpget進行數據的采集。
我們可以直接在系統中運行snmpwalk和snmpget看是否有該命令,如果有則不用安裝了。
7、安裝cacti
注意:寫該文檔時cacti的最高版本時0.8.6c,現在的最高版本是0.8.6f。由于0.8.6f以下的版本有SQL注入漏洞,請大家下載0.8.6f或以上的版本進行安裝。
下載:
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
復制代碼
導入表:
- /usr/local/mysql/bin/mysql –u root –prootroot cactidb < cacti.sql
- chown –R cactiuser rra/ log/
復制代碼
設置配置文件:
- vi /www/htdocs/cacti/include/config.php
- $database_type = “mysql”;
- $database_default = “cactidb”;
- $database_hostname = “l(fā)ocalhost”;
- $database_username = “cactiuser”;
- $database_password = “cactipw”;
復制代碼
核對以上幾項是否正確
- Crontab –u cactiuser –e
- 為cactiuser用戶加入
- */5 * * * * /www/php/bin/php /www/htdocs/cacti/poller.php >; /dev/null 2>;&1
復制代碼
(不要使用root用戶運行上面的命令,否則要再運行一次chown –R cactiuser rra/ log/)
8、頁面設置:
在瀏覽器上輸入:
http://IP/cacti
進入cacti的初始設置頁面:
在這里我們要輸入一些原始的信息:
NEXT -》
輸入一些信息,如rrdtool、php、snmpwalk、snmpget的位置,使用ucd-snmp還是net-snmp等 -》
輸入原始的用戶和密碼:admin/admin -》
更改admin用戶的密碼 -》
點擊 Save
安裝完成!!
現在可以在瀏覽器中進入Cacti的世界了!
[ 本帖最后由 joecen 于 2006-1-13 10:36 編輯 ] |
|