Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2499988
  • 博文数量: 867
  • 博客积分: 10010
  • 博客等级: 上将
  • 技术积分: 9800
  • 用 户 组: 普通用户
  • 注册时间: 2006-07-27 14:44
文章分类

全部博文(867)

文章存档

2007年(6)

2006年(861)

我的朋友

分类: LINUX

2006-08-28 22:44:00

1、安装mysql 

[color=Green]cacti从0.4.8g版本开始支持mysql5数据库 (2006/1/12更新)[/color]

下载源码:


for linux: 


for freebsd47: 


[color=red]上面的链接已经失效,请到
http://dev.mysql.com/downloads/mysql/4.1.html


下载mysql数据库[/color]


安装:

shell>; groupadd mysql 
shell>; useradd -g mysql mysql 
shell>; cd /usr/local 
shell>; gunzip < /PATH/TO/MYSQL-VERSION-OS.tar.gz | tar xvf - 
shell>; ln -s FULL-PATH-TO-MYSQL-VERSION-OS mysql 
shell>; cd mysql 
shell>; scripts/mysql_install_db --user=mysql 
shell>; chown -R root . 
shell>; chown -R mysql data 
shell>; chgrp -R mysql . 
shell>; bin/mysqld_safe --user=mysql & 



./bin/mysqladmin -u root password "yourpasswd" 基于安全的原因,为root用户设置密码才能让root用户登陆mysql,不然会有2002错误出现

建立启动脚本:
cp ./support-files/mysql.server /etc/init.d/mysql 

ln -s ../init.d/mysql S85mysql 
ln -s ../init.d/mysql K85mysql


2、安装apache 
下载:


安装:
./configure --prefix=/www --enable-so 

make && make install 


建立启动脚本
cp /www/bin/apachectl /etc/init.d/httpd 

cd /etc/rc3.d 
ln -s ../init.d/httpd S85httpd 
ln -s ../init.d/httpd K85httpd 


启动
/www/bin/apachectl start 

3、安装php
下载: 


安装:
/configure --prefix=/www/php --with-apxs2=/www/bin/apxs --with-config-file-path=/www/php --enable-sockets --with-mysql=/usr/local/mysql --with-zlib-dir=/usr/include --with-gd

make && make install 
cp php.ini-dist /www/php/php.ini 
vi /www/conf/httpd.conf 
加入: 
###############for php and cacti################### 
AddType application/x-tar .tgz 
AddType application/x-httpd-php .php 
AddType image/x-icon .ico 
DirectoryIndex index.php index.html index.html.var 
#######################over######################## 

../bin/apachectl restart 


4、设置mysql 
# mysql -u root -prootroot 

Welcome to the MySQL monitor. Commands end with ; or \g. 
Your MySQL connection id is 10 to server version: 4.0.23-standard 

Type 'help;' or '\h' for help. Type '\c' to clear the buffer. 

mysql>; create database cactidb; 
Query OK, 1 row affected (0.00 sec) 

mysql>; grant all on cactidb.* to root; 
Query OK, 0 rows affected (0.01 sec) 

mysql>; grant all on cactidb.* to root@localhost; 
Query OK, 0 rows affected (0.01 sec) 

mysql>; grant all on cactidb.* to cactiuser; 
Query OK, 0 rows affected (0.00 sec) 

mysql>; grant all on cactidb.* to cactiuser@localhost; 
Query OK, 0 rows affected (0.01 sec) 

mysql>; set password for cactiuser@localhost=password('cactipw'); 
Query OK, 0 rows affected (0.00 sec) 

mysql>; exit 


5、安装rrdtool
下载:
~oetiker/webtools/rrdtool/pub/rrdtool-1.0.x/rrdtool-1.0.50.tar.gz
然后
./configure
make && make install 即可
与mrtg相比,rrdtool自带了gd库,所以不用先安装gd库.(不过由于rrdtool自带的gd库不支持中文,所以rrdtool画出来的图也不能有中文,否则会出现乱码).

注意:rrdtool1.2的版本由于已经不再自带外部的lib库(如cgilib,zlib等),所以需要从~oetiker/webtools/rrdtool/pub/libs/下载这些库来安装。建议还是使用1.0的版本,比较方便。

6、安装net-snmp
几乎所有的网络设备和操作系统默认都安装了snmp服务。
unix系统安装的都是net-snmp或ucd-snmp(其实两个都是同一组人写的)。
如果没有安装snmp,可以到net-snmp.sourceforge.org上下载源码编译安装。
我这里说的安装SNMP服务并不是要求安装SNMPD,其实是Cacti需要用到net-snmp中的两个命令――snmpwalk和snmpget进行数据的采集。

我们可以直接在系统中运行snmpwalk和snmpget看是否有该命令,如果有则不用安装了。

7、安装cacti 
[color=red]注意:写该文档时cacti的最高版本时0.8.6c,现在的最高版本是0.8.6f。由于0.8.6f以下的版本有SQL注入漏洞,请大家下载0.8.6f或以上的版本进行安装。[/color]
下载: 


安装:
cp cacti-0.8.6c.tar.gz /www/htdocs 

tar xzvf cacti-0.8.6c.tar.gz 
mv cacti-0.8.6c cacti 
cd cacti


导入表:
/usr/local/mysql/bin/mysql –u root –prootroot cactidb < cacti.sql 

chown –R cactiuser rra/ log/


设置配置文件:

vi /www/htdocs/cacti/include/config.php 

$database_type = “mysql”; 
$database_default = “cactidb”; 
$database_hostname = “localhost”; 
$database_username = “cactiuser”; 
$database_password = “cactipw”;


核对以上几项是否正确

Crontab –u cactiuser –e 

为cactiuser用户加入 
*/5 * * * * /www/php/bin/php /www/htdocs/cacti/poller.php >; /dev/null 2>;&1 

[color=red](不要使用root用户运行上面的命令,否则要再运行一次chown –R cactiuser rra/ log/)[/color]

8、页面设置: 

在浏览器上输入: 

进入cacti的初始设置页面: 
在这里我们要输入一些原始的信息: 

NEXT -》 
输入一些信息,如rrdtool、php、snmpwalk、snmpget的位置,使用ucd-snmp还是net-snmp等 -》 
输入原始的用户和密码:admin/admin -》 
更改admin用户的密码 -》 
点击 Save 

安装完成!!!
现在可以在浏览器中进入Cacti的世界了!

[ 本帖最后由 joecen 于 2006-1-13 10:36 编辑 ]


  回复于:2005-08-15 15:44:21

第三部分,cacti的部分界面



树状结构显示图形





主控制台




  回复于:2005-08-15 15:44:56

开始考虑到大家都用过MRTG,应该对snmp有所了解,所有没有将snmp的配置写上来。现在发现有些朋友发贴说不能取到CPU和系统负载的数据,其原因应该是snmp设置默认没有允许取这些数据造成的。下面是我对linux和FreeBSD下的net-snmp的一些简单的配置。

一、Linux(RedHat)的配置

打开默认的/etc/snmp/snmpd.conf文件,更改如下配置:


[color=darkblue]1、查找以下字段:[/color]
#       sec.name  source          community

com2sec notConfigUser  default       public


将"comunity"字段改为你要设置的密码.比如"public".

将“default”改为你想哪台机器可以看到你的snmp信息,如10.10.10.10。

[color=darkblue]2、查找以下字段:[/color]
####

# Finally, grant the group read-only access to the systemview view.


#       group          context sec.model sec.level prefix read   write  notif
access  notConfigGroup ""      any       noauth    exact  all none none

将"read"字段改为[color=red]all[/color].
#access  notConfigGroup ""      any       noauth    exact  systemview none none



[color=darkblue]3、查找以下字段:[/color]
##           incl/excl subtree                          mask

#view all    included  .1                               80

将该行前面的"#"去掉.




保存关闭.


[color=darkblue]4、运行/etc/init.d/snmpd start命令运行snmpd.[/color]

最后运行netstat -ln查看161端口是否打开了.


二、FreeBSD
如果使用port安装net-snmp,默认的配置文件应该是在/usr/local/share/snmp/snmpd.conf(没有默认的文件)。
可以建立一个简单的配置文件,如:
syslocation  YourDefineName


syscontact  YourEmailAddress

sysservices 77

rocommunity  public  (请更改)

load  12 12 12


然后运行snmpd,netstat 看是否打开了161端口。
阅读(956) | 评论(0) | 转发(0) |
0

上一篇:MySQL的系统管理员

下一篇:mysql+php+apache

给主人留下些什么吧!~~