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
* 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
* 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]#
还需要修改mysql的配置文件,让服务器使用GB2312的编码,然后再生成cacti用到的数据库,并修改
site/lib/database.php
function db_connect_real($host,$user,$pass,$db_name,$db_type, $port = "3306", $retries = 20) {
global $cnn_id;
$i = 0;
$cnn_id = NewADOConnection($db_type);
$hostport = $host . ":" . $port;
while ($i <= $retries) {
if ($cnn_id->PConnect($hostport,$user,$pass,$db_name)) {
$cnn_id->Execute("SET NAMES 'GB2312'");
return(1);
}
$i++;
usleep(400000);
}
cacti_log("ERROR: Cannot connect to MySQL server on '$host'. Please make sure you have specified a valid MySQL database name in 'include/config.php'
.");