安装步骤
- 安装apache
- 安装mysql
- 安装rrdtool
- 安装snmp
- 安装php
- 安装cacti及cacti-plugin
- 安装weathermap
详细步骤
1、安装apache
下载源码包:
wget http://apache.freelamp.com/httpd/httpd-2.2.14.tar.bz2
指定apache的安装目录为/home/httpd,并让其可支持动态模块加载
tar jxvf httpd-2.2.14.tar.bz2
cd httpd-2.2.14
./configure --prefix=/home/httpd --enable-so
make
make install
启动apache,并测试访问
2、安装mysql
下载地址
http://dev.mysql.com/downloads/mysql/5.1.html#linux-rhel4-x86-32bit-rpms
rpm -e mysql-4.1.20-1.RHEL4.1.i386 --nodeps
rpm -ivh MySQL-server-community-5.1.39-0.rhel4.i386.rpm
rpm -ivh MySQL-client-community-5.1.39-0.rhel4.i386.rpm
rpm -ivh MySQL-devel-community-5.1.39-0.rhel4.i386.rpm
rpm -ivh MySQL-shared-community-5.1.39-0.rhel4.i386.rpm
3、安装rrdtool
阅读doc/rrdbuild.txt,按照文档安装rrdtool的依赖包,在此我将编译依赖包的命令整理了一下(仅针对rrdtool-1.3.8,根椐自己的实际情况,更改脚本前的几个变量),放在了文章的最后。
为了使生成的图形中显示中文日期,可作以下修改文件src/rrd_graph.c:
a、定位至xlab_t处
"%d" 改为 “%d日”
"%a" 改为 "周%a"
"Week %V"改为 "%V周"
b、定位至setlocale处:
setlocale(LC_ALL,"zh_CN")
编译rrdtool,注意此处的几个变量,应和前面脚本中的相同
export INSTALL_DIR="/usr/local/rrdtool"
export BUILD_DIR="/opt/rrdtool"
export CFLAGS="-O3 -fPIC"
export LDFLAGS="-Wl,--rpath -Wl,${INSTALL_DIR}/lib"
export PKG_CONFIG=$INSTALL_DIR/bin/pkg-config
cd $BUILD_DIR/rrdtool-1.3.8
./configure --prefix=$INSTALL_DIR --disable-tcl --disable-python
make clean
make
make install
4、安装snmp
安装以下几个RPM包:
net-snmp-perl
net-snmp-libs
net-snmp-devel
net-snmp-utils
net-snmp
5、安装php
可以自己的情况设定./configure的参数:
./configure --prefix=/home/php --with-apxs2=/home/httpd/bin/apxs --enable-sockets --with-mysql --with-zlib-dir=/usr/local/rrdtool/ --with-freetype-dir=/usr/local/rrdtool/ --with-png-dir=/usr/local/rrdtool/ --with-iconv-dir --with-ttf --with-gd --with-snmp --enable-mbstring
make && make install
httpd.conf中添加以下几条指令使其识别php文件:
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
DirectoryIndex index.html index.htm index.php
6、安装cacti及cacti-plugin
首先创建库及mysql账号
[root@localhost htdocs]# mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.39-community MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database cacti;
Query OK, 1 row affected (0.13 sec)
mysql> grant all on cacti.* to cactiuser@localhost identified by 'cactiuser';
Query OK, 0 rows affected (0.13 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
修改include/config.php配置cacti连接mysql的参数(偷懒了一下,在上一步操作中建立的库为cacti,用户名、密码都是cactiuser。
导入数据
mysql -ucactiuser -p cacti
添加cron
*/5 * * * * /home/php/bin/php /var/www/html/cacti/poller.php > /dev/null 2>&1
设置目录权限(因为运行apache的用户是nobody)
chown -R nobody rra/ log/
下载cacti-plugin,并将其解压至cacti目录下
unzip /home/cacti-plugin-0.8.7e-PA-v2.5.zip
less Readme.txt
打补丁
patch -p1 -N < cacti-plugin-0.8.7e-PA-v2.5.diff
导入数据
mysql -ucactiuser -p cacti
更改include/global.php,在$plugins = array();下一行添加
$plugins[] = 'weathermap';
通过浏览器访问cacti,并对其进行设置
7、安装配置weathermap
将weathermap解压至plugins目录下,并设定文件的属主
登陆cacti
console-->user managerment-->admin-->Realm Permissions:
上面三项打勾
刷新console
在Management段多出Weathermaps
在Configuration段多出Plugin management
关于weatherap中node标签的中文问题:
可使用web编缉器定位node的位置,手动编缉weather.conf文件,修改需要添写中文信息部分(如节点的标签名等)。(使用在web编缉器编缉weathermap.conf时中文可能会出现乱码)(我的系统编码设定为zh_CN.UTF-8)。
参考文章
相关链接
- http://oss.oetiker.ch
- http://net-snmp.sourceforge.net/
- http://cactiusers.org/index.php
- http://www.cacti.net/
- http://dev.mysql.com/downloads/mysql/5.1.html#linux-rhel4-x86-32bit-rpms
其他
rrdtool依赖包编译脚本内容
#!/bin/sh
export INSTALL_DIR="/usr/local/rrdtool"
export BUILD_DIR="/opt/rrdtool"
export CFLAGS="-O3 -fPIC"
export LDFLAGS="-Wl,--rpath -Wl,${INSTALL_DIR}/lib"
test -d $BUILD_DIR || mkdir -p $BUILD_DIR
#download software
download_software (){
cd $BUILD_DIR
wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.3.8.tar.gz
wget http://pkgconfig.freedesktop.org/releases/pkg-config-0.23.tar.gz
wget http://oss.oetiker.ch/rrdtool/pub/libs/zlib-1.2.3.tar.gz
wget http://oss.oetiker.ch/rrdtool/pub/libs/libpng-1.2.18.tar.gz
wget http://oss.oetiker.ch/rrdtool/pub/libs/freetype-2.3.5.tar.gz
wget http://oss.oetiker.ch/rrdtool/pub/libs/libxml2-2.6.32.tar.gz
wget http://oss.oetiker.ch/rrdtool/pub/libs/fontconfig-2.4.2.tar.gz
wget http://oss.oetiker.ch/rrdtool/pub/libs/pixman-0.10.0.tar.gz
wget http://oss.oetiker.ch/rrdtool/pub/libs/cairo-1.6.4.tar.gz
wget http://oss.oetiker.ch/rrdtool/pub/libs/glib-2.15.4.tar.gz
wget http://oss.oetiker.ch/rrdtool/pub/libs/pango-1.21.1.tar.bz2
}
check_error (){
echo "安任意键将安装$1";
read hello;
}
download_software;
check_error pkg-config
gunzip -c pkg-config-0.23.tar.gz | tar xf -
cd pkg-config-0.23
./configure --prefix=$INSTALL_DIR
make
make install
export PKG_CONFIG=$INSTALL_DIR/bin/pkg-config
check_error zlib
cd $BUILD_DIR
gunzip -c zlib-1.2.3.tar.gz | tar xf -
cd zlib-1.2.3
./configure --prefix=$INSTALL_DIR --shared
make
make install
check_error libpng
cd $BUILD_DIR
gunzip -c libpng-1.2.18.tar.gz | tar xf -
cd libpng-1.2.18
./configure --prefix=$INSTALL_DIR
make
make install
check_error freetype
cd $BUILD_DIR
gunzip -c freetype-2.3.5.tar.gz | tar xf -
cd freetype-2.3.5
./configure --prefix=$INSTALL_DIR CFLAGS="-O3 -fPIC"
make
make install
export EGREP=egrep
check_error libxml2
cd $BUILD_DIR
gunzip -c libxml2-2.6.32.tar.gz | tar xf -
cd libxml2-2.6.32
./configure --prefix=$INSTALL_DIR
make
make install
check_error fontconfig
cd $BUILD_DIR
gunzip -c fontconfig-2.4.2.tar.gz | tar xf -
cd fontconfig-2.4.2
./configure --prefix=$INSTALL_DIR --with-freetype-config=$INSTALL_DIR/bin/freetype-config
make
make install
check_error pixman
cd $BUILD_DIR
gunzip -c pixman-0.10.0.tar.gz | tar xf -
cd pixman-0.10.0
./configure --prefix=$INSTALL_DIR
make
make install
check_error pixman
cd $BUILD_DIR
gunzip -c cairo-1.6.4.tar.gz | tar xf -
cd cairo-1.6.4
./configure --prefix=$INSTALL_DIR \
--enable-xlib=no \
--enable-xlib-render=no \
--enable-win32=no
make
make install
check_error glib
cd $BUILD_DIR
gunzip -c glib-2.15.4.tar.gz | tar xf -
cd glib-2.15.4
./configure --prefix=$INSTALL_DIR
make
make install
check_error pango
cd $BUILD_DIR
bunzip2 -c pango-1.21.1.tar.bz2 | tar xf -
cd pango-1.21.1
./configure --prefix=$INSTALL_DIR --without-x
make
make install


