Вы находитесь на странице: 1из 5

1、 安裝 mysql

下載源碼:
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

shell> groupadd 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.justdn.org/httpd/httpd-2.0.53.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

2、 安裝 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

加入:

AddType application/x-tar .tgz


AddType application/x-httpd-php .php
AddType image/x-icon .ico
DirectoryIndex index.php index.html
index.html.var
../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

下載源碼:

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 = “localhost”;
$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、Cacti 頁面設置

登入 Cacti:
http://IP/cacti
進入 cacti 的初始設置頁面:
NEXT-》輸入一些資訊,如 rrdtool、php、snmpwalk、snmpget 的位置,使用 ucd-
snmp 還是 net-snmp 等-》輸入原始的用戶和密碼:admin/admin-》更改 admin 用戶
的密碼-》點擊 Save 安裝完成!現在可以在流覽器中進入 Cacti 的世界了!

Вам также может понравиться