cacti-0.8.7e 安裝筆記

cacti-0.8.7e 安裝筆記

環境 AS4-UPDATE5
下載需要的軟件
cacti主頁
http://cactiusers.org/index.php
cacti下載
# wget http://www.cacti.net/downloads/cacti-0.8.7e.tar.gz
cacti插件下載
# wget http://mirror.cactiusers.org/downloads/plugins/cacti-plugin-0.8.7e-PA-v2.5.zip
# wget http://cactiusers.org/downloads/monitor.tar.gz
# wget http://cactiusers.org/downloads/settings.tar.gz
# wget http://cactiusers.org/downloads/thold.tar.gz

apache主頁
http://httpd.apache.org/
apahce下載
# wget http://archive.apache.org/dist/httpd/httpd-2.2.6.tar.gz

mysql主頁
http://www.mysql.com/
mysql下載
mysql-5.1.26

php主頁
http://cn2.php.net/
php下載
# wget  wget http://cn2.php.net/distributions/php-5.3.0.tar.gz

zlib主頁
http://www.zlib.net/
zlib下載
# wget http://www.zlib.net/zlib-1.2.3.tar.gz

libpng主頁
http://www.libpng.org/
libpng下載
# wget http://prdownloads.sourceforge.net/libpng/libpng-1.2.40.tar.gz?download

freetype主頁
http://www.freetype.org/index2.html
freetype下載
# wget http://ftp.twaren.net/Unix/NonGNU/freetype/freetype-2.3.9.tar.gz

xml主頁
http://xmlsoft.org/
xml下載
# wget ftp://xmlsoft.org/libxml2/libxml2-2.7.4.tar.gz

libgd主頁
http://www.libgd.org/Main_Page
libgd下載
# wget http://www.libgd.org/releases/gd-2.0.35.tar.gz

jpeg庫下載
# wget ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz

rrdtool主頁
http://oss.oetiker.ch/rrdtool/index.en.html
rrdtool下載
# wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.2.27.tar.gz

安裝部分

apache安裝
#tar zxvf httpd-2.2.6.tar.gz
#cd httpd-2.2.6
#./configure
--prefix=/usr/local/apache
--enable-so
--enable-ssl
--with-ssl=/usr/local/ssl
--enable-track-vars
--enable-rewrite
--with-zlib
--enable-modules=all
--enable-mods-shared=all 
--with-suexec-caller=daemon 
#make
#make install

編輯apache配置文件httpd.conf,以apache支持php
# vi /etc/httpd/httpd.conf
1、添加如下二行
  AddType application/x-httpd-php  .php
  AddType application/x-httpd-php-source  .phps

2、定位至DirectoryIndex index.html
  修改爲:
   DirectoryIndex  index.php  index.html

3、按照使用習慣,這裏將網站根目錄指定到/var/www:
找到DocumentRoot “/usr/local/apache/htdocs”
修改爲:DocumentRoot “/var/www”

找到<Directory “/usr/local/apache/htdocs”>
修改爲:<Directory “/var/www”>

說明:這個對本文來說並非是不可少的。


#echo "/usr/local/apache/bin/apachectl start" >> /etc/rc.local(系統啓動時服務自動啓動)


mysql安裝
#groupadd mysql
#useradd -g mysql -s /bin/false -M mysql
#tar zxvf mysql-5.1.26.tar.gz
#cd mysql-5.1.26

#./configure
--prefix=/usr/local/mysql
--enable-thread-safe-client
--enable-local-infile
--enable-static
--enable-assembler
--with-charset=gbk
--with-extra-charset=all
--with-low-memory
--with-mysqld-user=mysql
--with-big-tables
--with-charset=latin1
--with-collation=latin1_swedish_ci
--with-pthread
--with-client-ldflags=-all-static
--with-mysqld-ldflags=-all-static
--without-ndb-debug
--without-debug
#make
#make install
#cp support-files/my-medium.cnf  /etc/my.cnf
#cd  /usr/local/mysql
#chown -R mysql .
#chgrp -R mysql .
#bin/mysql_install_db --user=mysql
#chown -R root .
#chown -R mysql var
#bin/mysqld_safe --user=mysql &

#cd  ……/mysql-5.1.26     (這裏的目錄指的是原壓縮包解壓後的目錄)
#cp  support-files/mysql.server  /etc/rc.d/init.d/mysqld
#chmod  700  /etc/rc.d/init.d/mysqld
加入自動啓動服務隊列:
#chkconfig --add mysqld
#chkconfig  --level  345  mysqld  on

啓動
/usr/local/mysql/bin/mysqld_safe &
如果啓動報如下錯
 InnoDB: Setting file ./ibdata1 size to 10 MB
需要執行mysql安裝目錄下的這個命令
scripts/mysql_install_db

測試
#/usr/local/mysql/bin/mysqladmin  ping
#/usr/local/mysql/bin/mysqladmin  version
#/usr/local/mysql/bin/mysql

添加root密碼
#/usr/local/mysql/bin/mysqladmin -uroot -p 舊密碼 password 新密碼
說明:此時mysql的root用戶的密碼爲空

配置庫文件搜索路徑
# echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf
# ldconfig

添加/usr/local/mysql/bin到環境變量PATH中
#export PATH=$PATH:/usr/local/mysql/bin

日誌管理
開啓錯誤日誌 (在[safe_mysqld]項下添加)
# vi /etc/my.cnf
[safe_mysqld]
err-log=/var/log/mysqld/err.log

開啓常規日誌和更新日誌 (在[mysqld]項下添加)
# vi /etc/my.cnf
[mysqld]
log=/var/log/mysqld/log.log
log-update=/var/log/mysqld/update.log

創建日誌文件並設置權限
# mkdir /var/log/mysqld
# touch /var/log/mysqld/err.log /var/log/mysqld/log.log /var/log/mysqld/update.log
# chown -R mysql.mysql /var/log/mysqld

# service mysqld restart


安裝zlib2
# tar zxvf tar zxvf zlib-1.2.3.tar.gz,進入目錄
# ./configure --prefix=/usr/local/zlib
# make
# make install

安裝PNG
# tar zxvf tar zxvf libpng-1.2.40.tar.gz,進入目錄
# cp scripts/makefile.linux ./makefile
# ./configure –prefix=/usr/local/png
# make
# make install

安裝JPEG6
# tar zxvf jpegsrc.v6b.tar.gz
# cd jpeg-6b
# mkdir -pv /usr/local/libjpeg/{,bin,lib,include,man/man1,man1}
# ./configure –prefix=/usr/local/libjpeg –enable-shared –enable-static
# make
# make install

安裝freetype
# tar xzvf freetype-2.3.9.tar.gz
# cd freetype-2.3.9
# ./configure --prefix=/usr/local/freetype
# make && make install

安裝libxml
# tar zxvf libxml2-2.7.4.tar.gz
# cd libxml2-2.7.4
# ./configure --prefix=/usr/local/xml
# make
# make install
# cp xml2-config /usr/bin

php的安裝
# tar zxvf php-5.3.0.tar.gz
# cd php-5.3.0
#  ./configure
--prefix=/usr/local/php
--with-apxs2=/usr/local/apache/bin/apxs
--with-mysql=/usr/local/mysql
--with-mysqli=/usr/local/mysql/bin/mysql_config 
--with-png-dir=/usr/local/png
--with-jpeg-dir=/usr/local/jpeg 
--with-zlib-dir=/usr/local/zlib
--with-freetype-dir=/usr/local/freetype
--with-xml-dir=/usr/local/xml
--with-gd
--enable-mbstring=all
--enable-sockets
--with-iconv-dir
--enable-bcmath
--with-ttf 
--with-openssl
--enable-sqlite-utf8 
--enable-mbstring
# make
# make install
# cp php.ini-dist  /usr/local/php/lib/php.ini

優化設置
# vi /usr/local/php/lib/php.ini
;default_charset = "iso-8859-1"
在這行下面加一行
default_charset = "gbk"

max_execution_time = 600 ; // 改爲600 (增加處理腳本的時間限制)
max_input_time = 600 ; //最大輸出時間600秒
memory_limit = 40M ;
register_global =On
post_max_size = 2M ; //php可接受的 post 方法大小 2M
file_uploads = On ; //允許上載文件
upload_max_filesize = 2M ; //最大上載文件2M
session.auto_start = 1 ; //session自動啓動

測試
vi test.php    放到apache的目錄下
<?
phpinfo();
?>

安裝rrdtool
# tar zxvf rrdtool-1.2.27.tar.gz
# cd rrdtool-1.2.27
# ./configure --prefix=/usr/local/rrdtool
# make;make install
如果下面這個錯誤
make[3]: *** [tclrrd.o] Error 1
就需要在配置里加上
configure --disable-tcl

配置mysql數據庫
# /usr/local/mysql/bin/mysql
mysql> set password for root@localhost=password('cactipw');
mysql> Query OK, 0 rows affected (0.00 sec)
mysql> create database cactidb;
mysql> grant all on cactidb.* to root;
mysql> grant all on cactidb.* to root@localhost;
mysql> grant all on cactidb.* to cactiuser;
mysql> grant all on cactidb.* to cactiuser@localhost;
mysql> set password for cactiuser@localhost=password('cactipw');
mysql> flush privileges; (See cacti docs/INSTALL)
mysql> exit

安裝cacti
# tar zxvf cacti-0.8.7e.tar.gz
# mv cacti-0.8.7e.tar.gz /var/www/cacti
# cd /var/www/cacti
# /usr/local/mysql/bin/mysql cactidb < cacti.sql
# vi include/config.php
  $database_type = “mysql”;
  $database_default = “cactidb”;
  $database_hostname = “localhost”;
  $database_username = “cactiuser”;
  $database_password = “cactipw”;
#crontab -e -u 用戶名
添加如下內容:
*/5 * * * * /usr/local/php/bin/php /var/www/cacti/poller.php > /dev/null 2>&1
編輯apache配置文件
# vi /usr/local/apache/conf/httpd.conf
加入下面內容
Alias /cacti /var/www/cacti
<Directory /var/www/cacti>
DirectoryIndex index.php
AllowOverride all
order deny,allow
deny from all
allow from all
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc on
php_flag track_vars on
</Directory>
重啓apache服務
# /usr/local/apache/bin/apachectl restart

到此cacti就安裝完成了,現在可以登錄去配置cacti了
http://localhost/cacti
默認賬號密碼都是admin

默認下cacti沒有monitor、thold等插件,需要安裝
安裝插件
進入下載插件的目錄
安裝cacti-plugin
# unzip cacti-plugin-0.8.7e-PA-v2.5.zip
# cp cacti-plugin-0.8.7e-PA-v2.5.diff pa.sql /var/www/cacti/
# cd /var/www/cacti/
# /usr/local/mysql/bin/mysql cactidb < pa.sql
# patch -p1 -N < cacti-plugin-0.8.7e-PA-v2.5.diff
# vi /var/www/cacti/include/config.php
  修改下面的內容
   $config['url_path'] = '/';
  改爲
  $config['url_path'] = '/cacti/';
  不然你的頁面無法正常顯示

安裝monitor thold settings
# tar zxvf monitor-0.8.2.tar.gz
# tar zxvf thold-0.4.1.tar.gz
# tar zxvf settings-0.5.tar.gz
# mv monitor/ thold/ settings/ /var/www/cacti/plugins/
# cd /var/www/cacti/plugins/monitor/
# /usr/local/mysql/bin/mysql cactidb < monitor.sql
# cd /var/www/cacti/plugins/thold/
# /usr/local/mysql/bin/mysql cactidb < thold.sql
# vi /var/www/cacti/include/config.php
  找到下面的內容
   $plugins = array();
  在下面添加
   $plugins[] = 'thold';
   $plugins[] = 'monitor';
   $plugins[] = 'settings';
保存退出

現在在登錄你的cacti
http://localhost/cacti
就會發現標籤出現了monitor,但沒有出現thold,是因爲需要在cacti裏面配置
登錄cacti後點擊
Plugin Management進入管理界面
找到Thresholds配置頁面
點install和enable就ok了
這時候刷新頁面就會發現thold也出現在標籤欄中

需要注意的地方
進入settings在進入paths裏
查看那些路徑不對,不對的會顯示紅色並提示沒有找到,一定修改正確,不然cacti會不正常!

到此cacti就已經成功的安裝了!
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章