转载自 http://liyaoyi.blog.51cto.com/442933/846891
一、准备所需要的软件包
Apache http://www.apache.org/
Mysql http://www.mysql.com/
Php http://www.php.net
Rrdtool http://oss.oetiker.ch/rrdtool/
Net-snmp http://www.net-snmp.org/
Cacti http://www.cacti.net/
其中apache、mysql、php通过yum安装
二、安装所需要的软件
1.安装LAMP
[root@cacti ~]# yum -y install httpd mysql-server php php-mysql mysql-devel
[root@cacti ~]# chkconfig httpd on
[root@cacti ~]# chkconfig mysqld on
[root@cacti ~]# /etc/init.d/httpd start
[root@cacti ~]# /etc/init.d/mysqld start
安装完成后,可通过以下程序测试
[root@cacti html]# cat inex.php
<?php
phpinfo();
?>
2.安装rrdtool
Rrdtool安装需要cairo、libxml2、pango库支持,可通过yum安装
[root@cacti ~]# yum -y install cairo-devel libxml2-devel pango-devel
[root@cacti ~]# tar zxvf rrdtool-1.4.7.tar.tar
[root@cacti ~]# cd rrdtool-1.4.7
[root@cacti rrdtool-1.4.7]# ./configure --prefix=/usr/local/rrdtool
[root@cacti rrdtool-1.4.7]# make && make install
[root@cacti rrdtool-1.4.7]# ln -s /usr/local/rrdtool/bin/* /usr/local/bin/
3.安装net-snmp
[root@cacti ~]# tar zxvf net-snmp-5.6.1.1.tar.gz
[root@cacti ~]# cd net-snmp-5.6.1.1
[root@cacti net-snmp-5.6.1.1]# ./configure --prefix=/usr/local/net-snmp
[root@cacti net-snmp-5.6.1.1]# make && make install
[root@cacti net-snmp-5.6.1.1]# cp EXAMPLE.conf /etc/snmpd.conf
[root@cacti ~]# ln -s /usr/local/net-snmp/bin/* /usr/local/bin/
[root@cacti ~]# vim /etc/snmpd.conf
rocommunity public localhost #去掉注释
[root@cacti ~]# /usr/local/net-snmp/sbin/snmpd -c /etc/snmpd.conf
加入开机启动
[root@cacti ~]# echo "/usr/local/net-snmp/sbin/snmpd -c /etc/snmpd.conf " >>/etc/rc.local
4.安装cacti
[root@cacti ~]# tar zxvf cacti-0.8.7i-PIA-3.1.tar.gz
[root@cacti ~]# mv cacti-0.8.7i-PIA-3.1/* /var/www/html/
#将cacti中的内容移到 web目录
[root@cacti ~]# chown -R apache:apache /var/www/html/
[root@cacti ~]# mysql -uroot
#连接到mysql创建数据库
mysql> create database cacti;
#创建cacti数据库
mysql> insert into mysql.user(host,user,password) values ('localhost','cacti',password('cacti123'));
#建立用户cacti,密码cacti123
mysql> flush privileges;
#重载mysql授权表
mysql> grant all on cacti.* to cacti@'localhost' identified by 'cacti123';
#把数据库cacti授权于用户cacti
[root@cacti ~]# cd /var/www/html/
[root@cacti html]# mysql -ucacti -pcacti123 cacti<cacti.sql #将cacti数据库导入
修改网站配置文件,使用正确连接数据库参数
[root@cacti html]# vim include/config.php
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cacti123";
$database_port = "3306";
使用浏览器打开http://192.168.209.130/install/
会看到安装向导,点下两个NEXT之后,出现以下:
默认用户名和密码admin,第一次登录会要求更改密码
5.设置cacti数据采集轮询时间
[root@cacti ~]# crontab –e
*/5 * * * * env LANG=C /usr/bin/php /var/www/html/poller.php
6.图像乱码问题
下载中文字体: http://ftp.tw.debian.org/debian/pool/main/t/ttf-arphic-ukai/ ttf-arphic-ukai_0.2.20080216.1.orig.tar.gz
cp ukai.ttc /usr/share/fonts/ukai.ttc
在cacti中,设置console->setting->path->RRDTool Default Font: /usr/share/fonts/ukai.ttc