- 论坛徽章:
- 0
|
你还在用mrtg吗?--使用cacti监测系统性能
第二部分:Cacti的安装
该安装文档是我参照www.cacti.net上的官方文档进行安装后,总结出来的。平台是Linux或FreeBSD。
1、安装mysql
cacti从0.4.8g版本开始支持mysql5数据库 (2006/1/12更新)
下载源码:
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
上面的链接已经失效,请到
http://dev.mysql.com/downloads/mysql/4.1.html
或
http://www.mysql.com
下载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.freelamp.com/httpd/httpd-2.0.54.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
3、安装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
- 加入:
- ###############for php and cacti###################
- AddType application/x-tar .tgz
- AddType application/x-httpd-php .php
- AddType image/x-icon .ico
- DirectoryIndex index.php index.html index.html.var
- #######################over########################
- ../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
注意:写该文档时cacti的最高版本时0.8.6c,现在的最高版本是0.8.6f。由于0.8.6f以下的版本有SQL注入漏洞,请大家下载0.8.6f或以上的版本进行安装。
下载:
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、页面设置:
在浏览器上输入:
http://IP/cacti
进入cacti的初始设置页面:
在这里我们要输入一些原始的信息:
NEXT -》
输入一些信息,如rrdtool、php、snmpwalk、snmpget的位置,使用ucd-snmp还是net-snmp等 -》
输入原始的用户和密码:admin/admin -》
更改admin用户的密码 -》
点击 Save
安装完成!!!
现在可以在浏览器中进入Cacti的世界了!
[ 本帖最后由 joecen 于 2006-1-13 10:36 编辑 ] |
|