首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 开源软件 >

cacti装配总结

2012-06-27 
cacti安装总结前前后后装cacti应该不下5次了,每次都是找书签,看视频才能装好,主要是不记得那些命令还有坑

cacti安装总结

前前后后装cacti应该不下5次了,每次都是找书签,看视频才能装好,主要是不记得那些命令还有坑爹的一大堆依赖软件,今天有时间,自己总结一下,结合他人的高见以及自己安装的经验,万一以后还要装的话,就直接看自己写的这个文章了,省的东看西查的,不过很多出错的情况都忘记了,以后要是在装的话就补上。。

?

我的cacti环境是这样子的:

centos 5.5 +??mysql +?php、php-fpm +?nginx(ruby → rubygems → passenger?→ passenger-install-nginx-module) + rrdtool + net-snmp?+?cacti-0.8.7g + spine

没错,我的环境跟大家是一样的,全程都是root身份在装,mysql没有cactiuser,nginx也不是www

?

安装mysql

?

yum search mysql ==》 yum install mysql mysql-devel mysql-server ==》 service mysqld start ==》 chkconfig mysqld on ==》 mysql -uroot -p ==》?set password for root@localhost=password('flw521521');

?

OK,mysql装完

如果有报错ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

解决方法:service mysqld start

?

安装php、php-fpm

?

1、yum search php ==》yum install php php-mysql php-devel php-cli php-common php-gd php-pdo

?

不好意思,这个方法有点低级,但是这样可以很好的解决依赖软件的问题,若有提示缺少依赖软件,可以继续yum search一下,把缺少的装上,当然,这样安装的php没有fastcgi的功能,所以我们需要从源码重新编译安装php。这个过程大家可以参考http://hi.baidu.com/snailzzz/blog/item/d61de8452e477d2dcefca3b0.html,不过他提供的php-fpm链接无法下载

我自己也简单描述一下安装过程

?

2、我用的php、php-fpm版本是5.2.17

php:wget http://cn.php.net/get/php-5.2.17.tar.gz/from/this/mirror

php-fpm:wget http://php-fpm.org/downloads/php-5.2.17-fpm-0.5.14.diff.gz

如果你想自己安装更新版本的话,请注意php跟php-fpm补丁的版本一定要一样

?

?

tar zxvf php-5.2.17.tar.gz
gzip -cd php-5.2.17-fpm-0.5.14.diff.gz | patch -d php-5.2.17 -p1
???

?

#注:把fpm以打补丁的方式放到php安装目录。据官方http://php-fpm.org/

消息php-fpm已经放到php的核心代码的svn中,相信不久就不用以打补丁安装了

?

cd php-5.2.17/


./configure --enable-fastcgi --prefix=/data1/server/php-cgi --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-mbstring --with-mysql --with-mysqli --with-pdo-mysql --enable-sockets --with-curl --with-ttf --with-libxml-dir --with-config-file-path=/data1/server/php-cgi/etc --with-zlib --enable-exif --enable-ftp --with-xmlrpc --enable-zip --with-iconv-dir --with-libxml-dir --with-mcrypt --with-tidy=/usr --enable-fpm --enable-force-cgi-redirect


make ==》 make install?==》?cp php.ini-dist /data1/server/php-cgi/etc/php.ini?

?

?

==》?ulimit -SHn 65535?==》?/data1/server/php-cgi/sbin/php-fpm start

?

OK,安装完毕

如果这个时候php -v 显示的不是5.2.17的版本,那么没关系,粗人自有粗方法,进入到php-5.2.17目录下,执行cp sapi/cli/php /usr/bin/php

?

?

这样php的版本就是5.2.17了,其他问题不用考虑?

?

出现错误

[ERROR] fpm_unix_conf_wp(), line 124: please specify user and group other than root, pool 'default'

注释取消掉

./etc/php-fpm.conf中的

<value name="user">nobody</value>???

<value name="group">nobody</value>

?

?

?

?

?tail -f /data1/server/php-cgi/logs/php-fpm.log

可以查看log

如果是出现9000端口被占用的话,执行“killall -9 php-cgi”杀掉进程,在重新启动就OK了

?

Cannot modify header information – headers already sent by...

?

这个问题如果有人在配置cacti web界面碰到的话,修改php.ini(find / -name "php.ini"可以用来查找该文件)文件,找到output_buffering = On这一行,将on改成4096即可解决这个问题

?

?

Fatal error: Maximum execution time of 30 seconds exceeded in。。。

这个问题也是在配置cacti web界面的时候碰到的,也是跟php有关的,

修改php.ini,把max_execution_time = 30(默认值)的值进行修改,将超时时间30s改成300s,我是这么改的。

?

?

?

?

安装nginx

?

1、装ruby

?

    yum install gcc gcc-c++首先从官方下载ruby1.8.7的源代码,目前(2010.12.22)ruby1.8.7最新版本号为:1.8.7p302,下载链接:wgetftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p302.tar.gz下载后解压出源码:tar zxf ruby-1.8.7-p302.tar.gz解压完成之后,直接到ruby目录执行./configure;make;make install安装三部曲,即完成ruby安装。

?

2、装rubygems

?

    首先从官方下载rubygem的源码,目前最新版本为1.3.7,下载链接:wget?http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz下载后解压出源码:tar zxf rubygems-1.3.7.tgz进入源码目录:cd rubygems-1.3.7以管理员身份安装:ruby setup.rb
  1. 执行gem -v查看rubygem是否安装成功

?

3、装passenger

?

gem i passenger

?

4、装nginx

?

passenger-install-nginx-module ==》 安装过程中会提示你缺少什么依赖软件,并且会告诉你需要执行什么命令来安装缺少的依赖软件,装完依赖软件后在执行passenger-install-nginx-module,不断重复,直到正确安装完毕,其中选择路径等问题可以直接ENTER选择默认即可。

?

安装rrdtool

?

wget?http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.4.4.tar.gz ==》 tar zxvf rrdtool-1.4.4.tar.gz ==》 cd rrdtool-1.4.4 ==> ./configure ==> make && make install

?

rrdtool安装貌似没遇到过错误,一般也不会出错,挺多就是缺少依赖软件,少哪个装哪个就好了

?

安装net-snmp

?

yum search snmp ==> yum install net-snmp net-snmp-devel net-snmp-libs net-snmp-utils

?

安装完成后,启动snmpd:service snmpd start

?

修改cacti服务器snmpd的配置文件snmpd.conf,默认情况下,该文件在/etc/snmpd/snmpd.conf,参考下列文件进行修改

?

#       sec.name  source          communitycom2sec notConfigUser  127.0.0.1         public#com2sec readonly  192.168.1.2       public#com2sec readwrite default         private##### Second, map the security names into group names:#               sec.model  sec.namegroup notConfigGroup v1       notConfigUsergroup notConfigGroup v2c      notConfigUsergroup MyROSystem usm       paranoidgroup MyROGroup v1         readonlygroup MyROGroup v2c        readonlygroup MyROGroup usm        readonlygroup MyRWGroup v1         readwritegroup MyRWGroup v2c        readwritegroup MyRWGroup usm        readwrite##### Third, create a view for us to let the groups have rights to:#           incl/excl subtree                          maskview all    included  .1                               80view system included  .1.3.6.1.2.1.1
#                context sec.model sec.level match  read   write  notifaccess notConfigGroup ""     any       noauth    exact  all none   noneaccess MyROGroup ""      any       noauth    exact  all    none   noneaccess MyRWGroup ""      any       noauth    exact  all    all    none

?

?

顺便贴一下被监控服务器的snmpd配置文件

?

?

#       sec.name  source          communitycom2sec notConfigUser  127.0.0.1         publiccom2sec readonly  192.168.1.2       public     两个文件的差别就在这一行,192.168.1.2即为cacti
服务器的IP地址,这个地址也可以为公网地址
#com2sec readwrite default         private##### Second, map the security names into group names:#               sec.model  sec.namegroup notConfigGroup v1       notConfigUsergroup notConfigGroup v2c      notConfigUsergroup MyROSystem usm       paranoidgroup MyROGroup v1         readonlygroup MyROGroup v2c        readonlygroup MyROGroup usm        readonlygroup MyRWGroup v1         readwritegroup MyRWGroup v2c        readwritegroup MyRWGroup usm        readwrite##### Third, create a view for us to let the groups have rights to:#           incl/excl subtree                          maskview all    included  .1                               80view system included  .1.3.6.1.2.1.1
#                context sec.model sec.level match  read   write  notifaccess notConfigGroup ""     any       noauth    exact  all none   noneaccess MyROGroup ""      any       noauth    exact  all    none   noneaccess MyRWGroup ""      any       noauth    exact  all    all    none

?

?

安装cacti、spine

?

wget?http://www.cacti.net/downloads/cacti-0.8.7g.tar.gz ==》 tar zxvf cacti-0.8.7g.tar.gz?

我的cacti目录是/opt/web/cacti-0.8.7g,后面nginx配置以这个路径进行配置

?

wget?http://www.cacti.net/downloads/spine/cacti-spine-0.8.7g.tar.gz ==》 tar zxvf cacti-spine-0.8.7g.tar.gz ==> ?mv cacti-spine-0.8.7g /opt/web/cacti-0.8.7g/ ==> ?cd cacti-spine-0.8.7g ==> ./configure ==> make && make install

?

?

配置nginx、fastcgi

?

由于公司有多个web界面再跑,所以nginx配置有点不太一样,nginx主配置文件/opt/nginx/conf/nginx.conf如下

?

?

# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';

#access_log logs/access.log main;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
#client_max_body_size 8m;

sendfile on;
tcp_nopush on;

keepalive_timeout 60;

tcp_nodelay on;

fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;

gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;

#sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;

#gzip on;

server {
listen 80;
server_name localhost;
root /opt/release/current/public;
passenger_enabled on;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
passenger_enabled on;
#root html;
#index index.html index.htm;
}

error_page 500 502 503 504 /50x.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fcgi.conf;
#}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}


# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;

# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443;
# server_name localhost;

# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;

# ssl_session_timeout 5m;

# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
# ssl_prefer_server_ciphers on;

# location / {
# root html;
# index index.html index.htm;
# }
#}
include /opt/web/123456/config/nginx.conf;
include /opt/web/789/config/nginx.conf;
include /opt/web/5565/config/nginx.conf;
include /opt/web/cacti-0.8.7g/nginx.conf;
}?

?

/opt/web/cacti-0.8.7g/nginx.conf文件如下

?

# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';

#access_log logs/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;


#gzip on;

server {
# listen 80;
# server_name localhost;

listen 80; #监听8080端口
server_name localhost;
index index.html index.htm index.php;
root /opt/web/CSSM; #指定CSSM代码所在目录
passenger_enabled on;
#charset koi8-r;

#access_log logs/host.access.log main;

#location / {
# root html;
# index index.html index.htm;
#}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
#error_page 500 502 503 504 /50x.html;
#location = /50x.html {
# root html;
#}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
#root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fcgi.conf;
}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}


# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;

# location / {
# root html;
# index index.html index.htm;
# }
#}


# HTTPS server
#
#server {
# listen 443;
# server_name localhost;

# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;

# ssl_session_timeout 5m;

# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;

# location / {
# root html;
# index index.html index.htm;
# }
#}

}?

?

?

/opt/web/cacti-0.8.7g/fcgi.conf文件如下

?

?写道fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;

fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;

fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;

fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;

?

?

/opt/nginx/sbin/nginx即可启动nginx

?

配置cacti

?

首先建立数据库

mysql> create database cacti;

mysql> grant all on cacti.* to?root@localhost;?

mysql> flush privileges;
mysql> exit;

导入数据库文件

mysql -uroot -p cacti < cacti.sql

?

首先是修改include下的config.php文件,修改数据库部分如下

写道

$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "root";
$database_password = "flw521521";
$database_port = "3306";

?

修改同目录下global.php文件,修改数据库部分如下

?

?写道$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "root";
$database_password = "flw521521";
$database_port = "3306";

?

?修改spine的配置文件,在/usr/local/spine/etc/spine.conf,修改数据库部分

?

?写道DB_Host localhost
DB_Database cacti
DB_User root
DB_Pass flw521521
DB_Port 3306
DB_PreG 0
?

?

配置轮询

?

crontab -e ==》* * * * * php /opt/web/cacti-0.8.7g/poller.php > /dev/null 2>&1?

保存退出

?

OK,该配的貌似都差不多了,下面去浏览器上配置吧,浏览器输入配置的cacti访问地址,不出意外可以看到你想看到的内容

输入用户名密码,

有一次我碰到一个很诡异的事情,就是当我输入完初始的用户名admin密码admin后,cacti死活不进去配置界面,也没提示输入新的密码,一直停留在输入用户名密码这一界面

解决方法:chmod 777?/var/lib/php/session

配置各种软件的路径,包括spine的路径,填写路径后,颜色是绿色的就说明该路径没有问题。

记得将poller选择为spine,并且轮询时间为每分钟,配置完后查看log有没有错误

?

?

安装插件

?

wget?http://mirror.cactiusers.org/downloads/plugins/cacti-plugin-0.8.7g-PA-v2.8.tar.gz ==》 tar zxvf cacti-plugin-0.8.7g-PA-v2.8.tar.gz ==》 mv?cacti-plugin-0.8.7g-PA-v2.8.diff qa.sql /opt/web/cacti-0.8.7g/

==》 patch -p1 -N< cacti-plugin-0.8.7g-PA-v2.8.diff ==> mysql -uroot -p cacti<pa.sql ==> web界面Console -> User Management -> admin -> 勾上plugin management -> save

?

monitor、settings、thold插件安装

?

wget?http://cactiusers.org/downloads/monitor.tar.gz

wget http://cactiusers.org/downloads/settings.tar.gz

wget http://cactiusers.org/downloads/thold.tar.gz

?

解压后将他们文件夹移到cacti目录下的plugins目录中

进入monitor的目录中 mysql -uroot -p cacti<monitor.sql

进入thold的目录中 mysql -uroot -p cacti<thold.sql

?

修改include/config.php文件,部分修改如下

?

?写道/* load up old style plugins here */
$plugins = array();
$plugins[] = 'monitor';
$plugins[] = 'settings';
$plugins[] = 'thold';

?

?

进入cacti web界面的Plugin Management应该就可以看到这三个插件

如果出现看不到thold插件,但是配置又完全正确时,修改config.php文件,将$plugins[] = 'thold';这一行删掉,然后刷新web界面,你就可以看到thold,把thold装上去之后,在此修改config.php文件,将$plugins[] = 'thold';这一行重新加上去即可

?

?

添加监控服务器

?

这个实在没什么好说的,因为添加这个太简单了,就copy一点别人的东西过来

?

?写道. Console->Management->Devices->add (增加监控设备)
Description:主机描述,可随便写
Hostname:主机IP地址
Host Template:主机模板,可以选UCD/Net snmp Host,也可以选None
SNMP Community:主机中的Community字段值,默认是public
SNMP Version:一般选Version1或Version2
2.2. Console->Management->Devices 选中刚才添加的主机,进入编辑界面(给监控主机增加要生成的"图像模板"和进行的"数据查询")
Associated Graph Templates:加入
1) ucd/net - CPU Usage
2) ucd/net - Load Average
3) ucd/net - Memory Usage
如果是本机,可以加入以下模板:
1) Linux - Memory Usage
2) Unix - Ping Latency
3) Unix - Load Average
4) Unix - Logged in Users
5) Unix - Processes
Associated Data Queries:加入
1) SNMP - Interface Statistics
2.3. Console->Create ->New Graphs(生成2.2步骤中增加的图象和数据)
在列表框中选中刚添加的主机,再选中所有Graph Templates和Data Query,再Create。
2.4. Console->Management->Graph Trees->Default Tree->Add(使生成的图象和数据能在"查看图象"即在"Graphs"中以图象的方式显示出来)
Parent Item:父节点,默认是根
Tree Item Type:节点类型,Host
Host:选择主机
Sorting Type:排序方式 1 楼 yuan 2011-07-06   那个富文本编辑器就别用啦,我都没用过。 2 楼 flw521521 2011-07-06   yuan 写道那个富文本编辑器就别用啦,我都没用过。

啊?哪个是富文本编辑器啊?
BBcode?

热点排行