歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> Linux資訊 >> Linux文化 >> 安裝Cacti的記錄

安裝Cacti的記錄

日期:2017/2/27 12:11:16   编辑:Linux文化

Cacti已經聽說過很久,而且還領略過其風采,由於懶,未曾自己實際安裝,這兩天終於找了個時間,裝了起來,感覺越用越好用,值得推薦.我就把我安裝的過程,還有碰到的一些問題,記錄在此,以作參考. 若有錯漏,多多包涵. 在這個論壇學習了很多, 權當自己的一份作業吧.

安裝的原則(自我感覺,歡迎拍磚): 1. 認真看清楚官方文檔. 當然,官方文檔很多,有時候抓到一個便以為是救生圈,所以我的建議是先多看,如果覺得差不多,就可以動手了. 2. 利用google. 我想這個就不用多說了. 3. 不斷嘗試. 我裝了兩次,第一次是因為沒有耐性,php沒法把gd編譯進去(不知道這種說法對否),就放棄,重新在一個Redhat AS 3 上完整的又裝了一次. 回頭又把原來的系統再弄好.

1. 必需的軟件 這裡的安裝包基本都是源代碼,需要編譯. 有興趣的可以都用rpm包安裝,我是裝rpm給裝怕了. mysql (建議使用4.x, 試過用5.x,但是碰到在用的過程中,mysql出現問題,換了4.x,就好了,未深入研究什麼原因) --> --> 下載 php --> 下載 Apache --> 下載 zlib --> 下載 libpng --> 下載 freetype --> 下載 GD --> 下載 Net-snmp --> 搜索和下載 (建議安裝rpm包,省點事,包括下面三個net-snmp net-snmp-devel net-snmp-utils) Libart --> 下載 RRDtool --> 下載 Cacti --> 下載

2. 安裝過程 a. 安裝順序 mysql -> apache -> net-snmp -> zlib -> libpng -> freetype -> Libart -> GD -> php -> RRDtool -> Cacti 當然, 這個順序也不是必然, 但是, 編譯php之前一定要把GD裝上, 而GD前面的庫, 肯定也是在裝GD之前裝上咯,而且有些也是rrdtool必須的.

b. 安裝步驟

mysql:

groupadd mysql useradd -g mysql mysql gunzip < mysql-VERSION.tar.gz | tar -xvf - cd mysql-VERSION ./configure --prefix=/usr/local/mysql make make install cp support-files/my-medium.cnf /etc/my.cnf cd /usr/local/mysql bin/mysql_install_db --user=mysql chown -R root . chown -R mysql var chgrp -R mysql . bin/mysqld_safe --user=mysql &

Apache: ./configure --prefix=/usr/local/apache --enable-shared=max --enable-cache --enable-speling --enable-rewrite --enable-so --with-mpm=worker --enable-ssl make make install

Net-snmp: 因為是rpm包, rpm -ivh Net-snmp* 就好了.

libpng libjpeg freetype Libart RRDtool GD: 這幾個比較重要,而且Cacti有安裝的指導,涉及一些環境變量的設置,所以放在一起說.

* 設置環境變量 BUILD_DIR=/tmp/rrdbuild NSTALL_DIR=/usr/local/rrdtool-1.2.12

* zlib cd $BUILD_DIR wget http://people.ee.ethz.ch/oetiker ... s/zlib-1.2.2.tar.gz tar zxf zlib-1.2.2.tar.gz cd zlib-1.2.2 env CFLAGS="-O3 -fPIC" ./configure --prefix=$BUILD_DIR/lb make make install

* libpng cd $BUILD_DIR wget http://people.ee.ethz.ch/oetiker ... 1.2.8-config.tar.gz tar zxvf libpng-1.2.8-config.tar.gz cd libpng-1.2.8-config env CPPFLAGS="-I$BUILD_DIR/lb/include" LDFLAGS="-L$BUILD_DIR/lb/lib" CFLAGS="-O3 -fPIC" \ ./configure --disable-shared --prefix=$BUILD_DIR/lb make make install

* freetype cd $BUILD_DIR wget http://people.ee.ethz.ch/oetiker ... eetype-2.1.9.tar.gz tar zxvf freetype-2.1.9.tar.gz cd freetype-2.1.9 env CPPFLAGS="-I$BUILD_DIR/lb/include" LDFLAGS="-L$BUILD_DIR/lb/lib" CFLAGS="-O3 -fPIC" \ ./configure --disable-shared --prefix=$BUILD_DIR/lb make make install

* libart_lgpl cd $BUILD_DIR wget http://people.ee.ethz.ch/oetiker ... _lgpl-2.3.17.tar.gz tar zxvf libart_lgpl-2.3.17.tar.gz cd libart_lgpl-2.3.17 env CFLAGS="-O3 -fPIC" ./configure --disable-shared --prefix=$BUILD_ DIR/lb make make install

* 再次設置環境變量 IR=-I$BUILD_DIR/lb/include CPPFLAGS="$IR $IR/libart-2.0 $IR/freetype2 $IR/libpng" LDFLAGS="-L$BUILD_DIR/lb/lib" CFLAGS=-O3 export CPPFLAGS LDFLAGS CFLAGS

* rrdtool cd $BUILD_DIR/rrdtool-1.2.12 ./configure --prefix=$INSTALL_DIR --disable-python --disable-tcl make clean make make install

* GD ./configure --prefix=/usr/local/gd --with-freetype=/usr/local/freetype -- with-libpng=/usr/local/libpng make make install

PHP: ./configure --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql --with-gd=/usr/local/gd --with-zlib --with-png=/usr/local/libpng --with-jpeg --with-freetype=/usr/local/freetype --enable-sockets make make install

Cacti: cp cacti-0.8.6g.tar.gz /usr/local/apache/htdocs cd /usr/local/apache/htdocs tar zxvf cacti-0.8.6g.tar.gz mv cacti-0.8.6g cacti cd cacti /usr/local/mysql/bin/mysqladmin -uroot create cacti /usr/local/mysql/bin/mysql -uroot < cacti.sql 創建帳號: /usr/local/mysql/bin/mysql -uroot grant all privileges on cacti.* to cactiuser@localhost identified by 'cacti'; flush privileges; chown –R cactiuser rra/ log/ vi ./include/config.php $database_type = “mysql”; $database_default = “cacti”; $database_hostname = “localhost”; $database_username = “cactiuser”; $database_password = “cacti”; vi /etc/crontab */5 * * * * cactiuser /usr/local/php/bin/php /user/local/apache/htdocs/cacti/poller.php > /dev/null 2>&1

3. 測試

試執行 /usr/local/php/bin/php /user/local/apache/htdocs/cacti/poller.php 如果得到類似: OK u:0.00 s:0.00 r:1.01 OK u:0.00 s:0.00 r:1.01 OK u:0.00 s:0.00 r:1.01 OK u:0.00 s:0.00 r:1.01 OK u:0.00 s:0.00 r:1.01 說明運行正常. 測試完, 把 /rra裡面的rrd文件刪除,原因是用root帳號執行的,可能引起權限的問題.

4. 碰到的問題 a. mysql的問題,前面已經提到.

b. 編譯GD時候出現的錯誤: gd_png.c:802: syntax error before '&' token gd_png.c:802: warning: data definition has no type or storage class gd_png.c:404: storage size of `open' isn't known make[2]: *** [gd_png.lo] Error 1 make[2]: Leaving directory `/tmp/gd-2.0.26gif' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/tmp/gd-2.0.26gif' make: *** [all] Error 2 [root@RHEL3 gd-2.0.26gif]#

解決方法: 修改gd_png.c #include "/usr/local/libpng/include/png.h"

可能漏了一些問題,我想起來再更新

5. 參考資料

http://linux.chinaunix.net/jh/4/594019.html http://www.phpv.net/article.php/272 http://bbs.chinaunix.net/archiver/?tid-644567-page-1.html http://bbs.chinaunix.net/archiver/?tid-686668.html http://www.cacti.net/downloads/docs/html rrdtool-version/doc/rrdbuild.txt

若有遺漏,敬請原諒.


Copyright © Linux教程網 All Rights Reserved