[原创]个人笔记:Cacti 0.8.7f安装记录
时间:2010-05-26 来源:yangzhigang
以前在我的Blog中写过关于cacti的安装方法,是通过yum远程软件仓库安装的,其版本是cacti 0.8.7e,现在www.cacti.net中发布最新版本是cacti 0.8.7f了,所以,本次通过在www.cacti.net中下载tar.gz的包进行安装,并进行相对应的patch安装,以及测试一两个Plugin的安装,记录下来,以供各位网友参考。 ============================= Cacti 0.8.7f 安装 ==============================
// 配置远程软件仓库,通过软件仓库来安装cacti所需要的软件环境(为了以后测试,问题诊断,再开发等,可以多安装一部分非必须的安装包)
[root@centos54 /]# vi /etc/yum.repos.d/dag.repo
[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=1
enabled=1
导入非官方库的GPG:
[root@centos53 /]# rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt 安装cacti需要的环境包 [root@centos54 /]# yum install -y httpd mysql mysql-server php php-mysql net-snmp net-snmp-utils
[root@centos54 /]# yum install -y zlib libpng freetype libjpeg fontconfig gd libxml2
[root@centos54 /]# yum install -y rrdtool
// 进行snmp,http的配置文件的改动 本机net-snmp的配置 [root@centos54 /]# vi /etc/snmp/snmpd.conf 更改配置如下: com2sec notConfigUser localhost public access notConfigGroup "" any noauth exact all none none view all included .1 httpd的配置 [root@centos54 /]# vi /etc/httpd/conf/httpd.conf 更改或增加: ServerName xxx.xxx.xxx.xxx AddDefaultCharset GB2312 httpd中cacti目录的配置 [root@centos54 /]# vi /etc/httpd/conf.d/cacti.conf
Alias /cacti /var/www/cacti/
<Directory /var/www/cacti/>
DirectoryIndex index.php
Options -Indexes
AllowOverride all
order deny,allow
allow from all
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc on
php_flag track_vars on
</Directory> // mysqld的配置,为cacti创建db和user [root@centos54 /]# service mysqld start [root@centos54 /]# mysql -uroot mysql> select user,host,password from mysql.user; mysql> delete from mysql.user where user=''; mysql> select user,host,password from mysql.user; mysql> set password for root@localhost=password("rootpw"); mysql> create database cactidb; mysql> grant all on cactidb.* to root@localhost; mysql> grant all on cactidb.* to cacti@localhost; mysql> set password for cacti@localhost=password("cactipw"); mysql> flush privileges; mysql> select user,host,password from mysql.user; mysql> show databases; mysql> exit // 下载最新版本Cacti 0.8.7f,解压、MV [root@centos54 /]# cd /usr/local/src [root@centos54 src]# wget http://www.cacti.net/downloads/cacti-0.8.7f.tar.gz [root@centos54 src]# tar zxvf cacti-0.8.7f.tar.gz [root@centos54 src]# mv cacti-0.8.7f /var/www/cacti [root@centos54 src]# useradd cacti [root@centos54 src]# cd /var/www/ [root@centos54 www]# chown -R root:root cacti/ [root@centos54 www]# chown -R cacti:cacti cacti/rra/ cacti/log/ [root@centos54 /]# cd /var/www/cacti/ [root@centos54 cacti]# mysql --user=root --password=rootpw cactidb <cacti.sql [root@centos54 cacti]# vi /var/www/cacti/include/config.php
/* make sure these values refect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cactidb";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cactipw";
$database_port = "3306";
// 设置crontab定时任务
[root@centos54 cacti]# vi /etc/crontab
*/5 * * * * cacti /usr/bin/php /var/www/cacti/poller.php > /dev/null 2>&1
// 设置服务开机自启动,重启服务
[root@centos54 /]# chkconfig snmpd on
[root@centos54 /]# chkconfig httpd on
[root@centos54 /]# chkconfig mysqld on
[root@centos54 /]# service httpd restart
[root@centos54 /]# service snmpd restart
[root@centos54 /]# service mysqld restart
// WEB页完成安装 浏览http://xxx.xxx.xxx.xxx/cacti/index.php或http://xxx.xxx.xxx.xxx/cacti/ 就可以出再Cacti Installation Guide的页面了。NEXT--NEXT--FINISH。 用户名和密码为:admin/admin,之后输入新的密码,就完成了最基本的安装。 ========================= Cacti 0.8.7f Patch安装 ========================== // 下载Patch安装包,并安装(到http://cactiusers.org/中下载cacti 0.8.7f对应的patch文件,也叫做Plugin Architecture,即插件架构) [root@centos54 cacti]# cd /usr/local/src[root@centos54 src]# wget http://mirror.cactiusers.org/downloads/plugins/cacti-plugin-0.8.7f-PA-v2.7.tar.gz [root@centos54 src]# tar zxvf cacti-plugin-0.8.7f-PA-v2.7.tar.gz
[root@centos54 src]# cp -R cacti-plugin-arch/* /var/www/cacti cp: overwrite `/var/www/cacti/LICENSE'? y
cp: overwrite `/var/www/cacti/README'? y
[root@centos54 src]# cd /var/www/cacti/
[root@centos54 cacti]# mysql -ucacti -pcactipw cactidb <pa.sql [root@centos54 cacti]# patch -p1 -N <cacti-plugin-0.8.7f-PA-v2.7.diff
patching file auth_changepassword.php
patching file auth_login.php
patching file data_sources.php
patching file graph_image.php
patching file graph.php
patching file graphs_new.php
patching file graphs.php
patching file host.php
patching file include/auth.php
patching file include/bottom_footer.php
patching file include/global_arrays.php
patching file include/global_constants.php
patching file include/global_form.php
patching file include/global.php
patching file include/global_settings.php
patching file include/plugins.php
patching file include/top_graph_header.php
patching file include/top_header.php
patching file index.php
patching file lib/api_device.php
patching file lib/auth.php
patching file lib/functions.php
patching file lib/html_form.php
patching file lib/html.php
patching file lib/plugins.php
patching file lib/poller.php
patching file lib/rrd.php
patching file lib/variables.php
patching file plugins/index.php
patching file plugins.php
patching file poller.php
patching file user_admin.php
patching file utilities.php
如果是通过"http://xxx.xxx.xxx.xxx/cacti/“的URL访问,要修改global.php:
[root@centos54 cacti]# vi /var/www/cacti/include/global.php
/* Default database settings*/
$database_type = "mysql";
$database_default = "cactidb";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cactipw";
$database_port = "3306";
/*
Edit this to point to the default URL of your Cacti install
ex: if your cacti install as at http://serverip/cacti/ this
would be set to /cacti/
*/
$config['url_path'] = '/cacti/';
// 授权admin用户"plugin Management":
登录后,Utilities--User Management--admin--Realm Permissions,选中“Plugin Management",Save。OK啦,后面的工作就是要安装相关的插件了