免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1020 | 回复: 0
打印 上一主题 下一主题

Linux下的Cacti安装配置 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-01-15 12:12 |只看该作者 |倒序浏览

cacti是一套PHP程序,它运用snmpget采集数据,使用rrdtool绘图。使用Cacti能统计网络设备的流量
、CPU、系统负载等参数,也可以自定义监测的指标。
所有的软件都放在/opt目录下
1、安装apache
[root@script opt]# # tar vxzf  httpd-2.0.54.tar.gz
[root@script opt]# cd httpd-2.0.54
[root@script httpd-2.0.54]# ./configure --prefix=/usr/local/apache --enable-so
[root@script httpd-2.0.54]# make && make install
[root@script httpd-2.0.54]# /usr/local/apache/bin/apachectl start
[root@script httpd-2.0.54]# cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
[root@script httpd-2.0.54]# chmod a+x /etc/init.d/httpd
[root@script httpd-2.0.54]# vi /etc/init.d/httpd
      在第三行加入如下两行:
      # chkconfig: 345 85 15
      # description: Starts and stops the Apache HTTP Server.
      保存退出:wq
[root@script httpd-2.0.54]# chkconfig --add httpd

[separator]
2、安装mysql
[root@script opt]# tar vxzf mysql-4.0.18.tar.gz
[root@script opt]# cd mysql-4.0.18
[root@script mysql-4.0.18]# ./configure --prefix=/usr/local/mysql
[root@script mysql-4.0.18]# make && makeinstall
[root@script mysql-4.0.18]# ./scripts/mysql_install_db
[root@script mysql-4.0.18]# /usr/local/mysql/bin/mysqld_safe --user=root &
[root@script mysql-4.0.18]# /usr/local/mysql/bin/mysqladmin -u root password 888888
[root@script mysql-4.0.18]# cp /usr/local/mysql/share/mysql/mysql.server
/etc/rc.d/init.d/mysqld
[root@script mysql-4.0.18]# chkconfig --add mysqld
3、安装php
[root@script opt]# tar vxzf php-4.4.2.tar.gz
[root@script opt]# cd php-4.4.2
[root@script php-4.4.2]# ./configure --prefix=/usr/local/php \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-config-file-path=/usr/local/php \
--with-mysql=/usr/local/mysql \
--with-zlib-dir=/usr/include \
--enable-sockets \
--with-gd
    最后可能会提示缺少libxml,就需要下载回来安装,很简单 ./configure 然后 make && make
install
[root@script php-4.4.2]# make && make install
[root@script php-4.4.2]# cp php.ini-dist /usr/local/php/php.ini
[root@script php-4.4.2]# vi /usr/local/apache/conf/httpd.conf
    按 I 键添加
    AddType application/x-tar .tgz
    AddType application/x-httpd-php .php
    AddType image/x-icon .ico
    DirectoryIndex index.php index.html index.html.var
    保存退出 :wq
[root@script php-4.4.2]# /usr/local/apache/bin/apachectl restart
4、设置mysql
[root@script opt]# /usr/local/mysql/bin/mysql -uroot -p888888
    mysql> create database cacti;
    mysql> GRANT ALL ON cacti.* TO
[email=cactiuser@localhost]cactiuser@localhost[/email]
IDENTIFIED BY 'cactipwd';
    mysql> flush privileges;
注:以上语句输出 Query OK, 0 rows affected (0.01 sec) 表示成功
  mysql> exit
5、检查apache+php+mysql
[root@script opt]# cd /usr/local/apache/htdocs
[root@script htdocs]# touch test.php
[root@script htdocs]# vi test.php
   
保存退出 :wq
[root@script htdocs]# touch mysqltest.php
[root@script htdocs]# vi mysqltest.php
      
         
            
         
             Host
             User
             Password
         
     
         
            
            
            
         
            
         
      
保存退出 :wq
重启mysql + apache 服务
[root@script htdocs]# service mysql restart
[root@script htdocs]# service httpd restart
进入浏览器检查
http://localhost/test.php

http://localhost/mysqltest.php
6、安装rrtool
与mrtg相比,rrdtool自带了gd库,所以不用先安装gd库。(不过由于rrdtool自带的gd库不支持中文,
所以rrdtool画出來的图也不能有中文,否则会出现乱码)。
注意:rrdtool1.2的版本由于已经不再自带外部的lib库(如cgilib,zlib等),所以需要从
http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/pub/libs/
下载这些库來安装。建议还是使用
1.0的版本,比较方便。
[root@script opt]# tar vxzf rrdtool-1.0.50.tar.gz
[root@script local]# cd rrdtool-1.0.50
[root@script rrdtool-1.0.50]# ./configure --prefix=/usr/local/rrdtool
[root@script rrdtool-1.0.50]# make && make install
7、安装net-snmp、snmpwalk和snmpget命令
[root@script opt]# rpm -qa | grep net-snmp
    net-snmp-5.0.9-2.30E.15
    net-snmp-devel-5.0.9-2.30E.15
    net-snmp-libs-5.0.9-2.30E.15
    net-snmp-utils-5.0.9-2.30E.15
[root@script opt]# vi /etc/snmp/snmpd.conf
       更改 com2sec notConfigUser  default       public
       改为 com2sec notConfigUser  127.0.0.1     public
       更改 access  notConfigGroup ""      any       noauth    exact  systemview  none
none
       改为 access  notConfigGroup ""      any       noauth    exact  all         none
none
       将 #view all    included  .1         80 前面的 # 注释去掉
保存退出 :wq
[root@script opt]# service snmpd restart
注:如果你机器内没有snmpwalk和snmpge命令,请到安装盘里查找 net-snmp-utils 包,执行 rpm -
ivh net-snmp-utils-5.0.9-2.30E.15.i386.rpm 之后这两个命令就在系统里了。其他包也都在安装盘
里 确保安装这四个包就OK
8、安装配置cacti
[root@script opt]# cp cacti-0.8.6g.tar.gz /usr/local/apache/htdocs/
[root@script opt]# cd /usr/local/apache/htdocs/
[root@script htdocs]# tar vxzf cacti-0.8.6g.tar.gz
[root@script htdocs]# mv cacti-0.8.6g cacti
[root@script htdocs]# cd cacti
[root@script cd cacti]# /usr/local/mysql/bin/mysql -uroot -p888888 cacti
/dev/null 2>&1
保存退出:wq
9、最后说明
全部设置完后打开浏览器
http://localhost/cacti
进入cacti的初始设置页面,第一次默认登陆账号
:admin 密码 cactipwd ,登陆后再新改个密码,再用admin和密码登陆就OK
需要说明的还有路径
snmpwalk Binary Path : /usr/bin/snmpwalk
snmpget Binary Path: /usr/bin/snmpget
RRDTool Binary Path: /usr/local/rrdtool/bin/rrdtool
PHP Binary Path: /usr/local/php/bin/php
Cacti Log File Path: /usr/local/apache/htdocs/cacti/log/cacti.log
Cactid Poller File Path: /usr/local/apache/htdocs/cacti/poller.php
最好确认一下路径是否正确
注:此时graphs还不能显示图形,需要将服务重新启动一下
[root@script /]# service snmpd restart
[root@script /]# /usr/local/mysql/bin/mysqld_safe --user=root &
[root@script /]# /usr/local/apache/bin/apachectl start
OK ,现在打开或刷新
http://192.168.1.99/cacti
选 graphs 选项一定能出图形
另:cacti 不支持 mysql 5 ,请确认你的mysql 版本


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/29971/showart_232154.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP