Cacti的安装

这里假设已经安装了apche ,mysql ,php ,rrdtool, net-snmp,  lamp(apache,mysql,php)的安装见其他文档,rrdtool, net-snmp的安装比较简单

一.             安装cacti

1.       下载

Wget http://www.cacti.net/downloads/cacti-0.8.7g.tar.gz

2.       安装

tar xvfz cacti-0.8.7g.tar.gz

cp -R cacti-0.8.7g /usr/local/cacti

3.       cacti设置mysql数据库

Mysql  -u root –p

Create database cacti;

4.       cacti创建mysql用户

 Use mysql

GRANT select,insert,delete,update ON cacti.* TO cactiuser@'127.0.0.1' IDENTIFIED BY 'cactipass';

 FLUSH PRIVILEGES;

5.       导入cacti 数据库

mysql  cacti  <  cacti.sql  -p

6.       修改cacti配置文件

vi include/config.php

$database_type = "mysql";

$database_default = "cacti";

$database_hostname = "127.0.0.1";

$database_username = "cactiuser";

$database_password = "cactipass";

$database_port = "3306";

/* Default session name - Session name must contain alpha characters */

#$cacti_session_name = "Cacti";

$config['url_path']="/cacti/";

7.       apache配置文件上增加cacti目录

 Alias /cacti "/usr/local/cacti/"

<Directory "/usr/local/cacti">

  Options None

  AllowOverride AuthConfig

  Order allow,deny

  Allow from all

  AuthType basic

  AuthName "Cacti access"

  AuthUserFile /dev/null

  #Require valid-user

</Directory>

8.       增加cacti用户,默认的组是cacti
useradd cacti

cacti的整个目录的属主和属组改为cacti

Chown  –R  cacti:cacti  cacti

9.       添加信息收集定时器

Crontab –e

*/5 * * * * /software/php/bin/php /usr/local/cacti/poller.php > /dev/null 2>&1

 

二.             配置cacti

1. 在浏览器中输入:http://ip/cacti/

默认用户名:admin 密码:admin

2. .更改密码

3. 设置cacti用到的命令路径,一般情况下cacti会自动寻找到所需命令的路径,如果找不到可以手动更改

4. 安装spine

Wget http://www.cacti.net/downloads/spine/cacti-spine-0.8.7g.tar.gz

tar -xzvf cacti-spine-0.8.7g.tar.gz

cd cacti-spine-0.8.7g

./configure --prefix=/usr/local/spine --with-mysql=/usr/local/mysql

make; make install

5. 编辑 spine.conf 文件,输入数据库名、数据库用户名和密码等信息

6. vim /usr/local/spine/etc/spine.conf

DB_Host 127.0.0.1

DB_Database cacti

DB_User cactiuser

DB_Pass cactipass

DB_Port 3306

7. 修改相关配置

Console>Settings>General

指定RRDTOOL的版本Cacti的安装_cacti

Console>Settings>Poller>Poller Type,有两个选项:cmd.phpspine,选择[spine]。选择spine是为了加快速度,cmd.php是一个php写的调度程序,而spine是用C写的,spine的性能远远优于cmd.php,当监控的设备有很多时,cmd.php的性能就跟不上了,只能用spine来调度,因此选择spine

Cacti的安装_cacti_02

 指定spine路径

Console>Settings>paths

Cacti的安装_职场_03