1、yum 安装所需的lamp 环境。
yum install mysql mysql-server -y
yum install http -y
yum install php php-mysql -y
2、安装cacti 需要的大量库,(一般系统都默认安装了)
yum install zlib libpng freetype jpeg fontconfig gd libxml2 -y
3、安装绘图工具rrdtool ,去http://packages.express.org/rrdtool/ 下载rpm包
rrdtool-1.2.30-1.el5.wrl.i386.rpm
rrdtool-perl-1.2.30-1.el5.wrl.i386.rpm
rpm-ivh rrdtool-1.2.30-1.el5.wrl.i386.rpm rrdtool-perl-1.2.30-1.el5.wrl.i386.rpm
4、安装snmp
yum install net-snmp net-snmp-utils
5、安装cacti ,去http://www.cacti.net/downloads 下载cacti-xx-xx.tar.gz
tar -zxvf cacti-xx-xx.tar.gz
mv cacti-xx-xx /var/www/html/cacti
cd /var/www/html/cacti/include
vi config.php
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cacti";
$database_port = "3306"
6、添加cacti用户
groupadd cacti
useradd -g cacti cacti
chown -R cacti:cacti /var/www/html/cacti
chmod 755 /var/www/html/cacti
7、创建cacti数据库&& 导入cacti sql文件
service mysqld start
mysqladmin -uroot -p password "123456"
mysql -uroot -p123456
>create database cacti;
>grant all on cacti.* to 'cacti'@'localhost' identified by 'cacti';
>flush privileges;
>source /var/www/html/cacti/cacti.sql;
>exit
8、配置Apache
找到AddType添加下面两句
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
找到DirectoryIndex index.html
改成DirectoryIndex index.php index.html
9启动服务
service httpd start
service mysqld restart
service snmpd start
chkconfig httpd on
chkconfig mysql on
chkconfig snmpd on
10、打开浏览器,http://ip/cacti
next
new install
登陆 admin admin
首次登陆要修改密码
如果有防火墙,记得开启snmp的161 tcp udp 端口
Cacti 监控apache
1、下载apache监控模板
http://forums.cacti.net/about25227.html&highlight=apachestats
ApacheStats_0.8.2.tar
2、如果apache是用rpm 包安装的则是则在apache的mouldes 目录下面有mod_status.so 模
块 编译安装要选上该模块也可手动加载
vim httpd.conf
LoadModule status_module modules/mod_status.so
<location /server-status>
SetHandler server-status
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from 192.168.2.194 注: 该项是允许从那个主机能够通过web的形式查看apache运行状态
</location>
3、解压模块
cp ss_apache_status.php /var/www/html/cacti/scripts
登陆浏览器导入cacti_host_template_webserver_-_apache.xml
给Cacti安装监控mysql插件
一,脚本下载以及设置
下载http://mysql-cacti-templates.googlecode.com/files/mysql-cacti-templates-1.1.2.tar.gz
tar -xzvf mysql-cacti-templates-1.1.2.tar.gz
cd mysql-cacti-templates-1.1.2
cp ss_get_mysql_stats.php /var/www/html/cacti/scripts
修改ss_get_mysql_stats.php 文件 第30行
$mysql_user = 'cacti';
$mysql_pass = 'cacti';
$cache_dir = "/var/www/html/cacti/cacti/cache/";
设置准备监控的数据库的账户相关信息
mkdir /var/www/html/cacti/cache/
chown -R cacti:cacti /var/www/html/cacti/cache/
chmod 755 /var/www/html/cacti/cache/
默认在获取的数据/tmp/下,会有cacti不能读取的情况。所以放在cacti目录来。
二,创建监控Mysql需要的账户以及权限
配置MySQL服务器,让cacti所在机器能够访问MySQL服务器的状态信息,必须拥 有”process”权限。如果要监控InnoDB状态,还必须有”SUPER”权限。
mysql> grant process,super on *.* to 'cacti'@'%' identified by 'cacti';
三,模板导入
同apache