阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

CentOS 6.4搭建Cacti中遇到的问题及解决

118次阅读
没有评论

共计 7868 个字符,预计需要花费 20 分钟才能阅读完成。

我在 CentOS 6.4 下搭建一个 Cacti,本来感觉很容易,可是后来感觉都快赶上红军长征了,下面我来介绍一下我在搭建 cacti 的过程中,出现的的问题及解决方法。

RHEL6.4 中使用 Cacti+Spine 监控主机实现发送邮件报警 http://www.linuxidc.com/Linux/2013-11/92795.htm

RHEL6.4 中使用 Cacti+Spine 监控远程主机 http://www.linuxidc.com/Linux/2013-11/92796.htm

CentOS 5.5 完整安装 Cacti+Spine http://www.linuxidc.com/Linux/2011-12/49701.htm

CentOS 6 下 Cacti 搭建文档 http://www.linuxidc.com/Linux/2013-06/86595.htm

RHEL5.9 下 Cacti 监控部署详解 http://www.linuxidc.com/Linux/2013-06/85427.htm

CentOS 6.3 下 Cacti 安装详解 http://www.linuxidc.com/Linux/2013-05/84279.htm

CentOS Linux 下快速安装配置 Cacti 中文版 http://www.linuxidc.com/Linux/2013-03/81627.htm

1. 安装 snmp 软件不成功, 总是说缺一些插件,都有什么没有安装,最后被我攻克了

yum -y install lm_sensors net-snmp net-snmp-utils

2. 安装 rrdtool 报错

首先要把 rrdtool 所需要的依赖包安装好,否则,总是报错

yum -y install cairo-devel glib2-devel pango-devel intltoolwget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.4.7.tar.gz

./configure –prefix=/usr/local

make &&  make install

然后就是下载 cacti 的安装包了

wget http://www.cacti.net/downloads/cacti-0.8.7i.tar.gz

tar -zxvf cacti-0.8.7i.tar.gz

cp -r cacti-0.8.7i /usr/local/nginx/html/cacti  # 复制到 html 目录

useradd cactiuser -M -s /sbin/nologin          # 创建 cacti 用户

chown -R cactiuser.cactiuser /usr/local/nginx/html/cacti/rra/ # 改变属主和属组

chown -R cactiuser.cactiuser /usr/local/nginx/html/cacti/log/

然后创建数据库:

create database cactidb default character set utf8;  #创建数据库

grant all on cactidb.* to cactiuser@localhost identified by ‘123456’; # 创建一个 mysql 用户

use cactidb  # 使用刚才创建的数据库

source /usr/local/nginx/html/cacti/cacti.sql # 导入 cacti 数据

接下来我们编辑 cacti 配置文件 /usr/local/nginx/html/cacti/include/config.php

cd /usr/local/nginx/html/cacti/

vi include/config.php

编辑下面内容:

$database_type=”mysql”;            # 数据库类型

$database_default=”cactidb”;      # 数据库名字

$database_hostname=”localhost”;    # 数据库主机

$database_username=”cactiuser”;    # 数据库用户

$database_password=”123456″;      # 数据库密码

$database_port=”3306″;            # 数据库端口

$database_ssl=false; 然后修改 nginx 配置文件像下面:

vi /usr/local/nginx/config/nginx.conf

location / {
              root  html;
            index  index.php;
        }

        location ~ \.php$ {
            fastcgi_pass        127.0.0.1:9000;
            fastcgi_index      index.php;
            include fastcgi.conf;
            fastcgi_buffers 8 8k;

fastcgi_buffer_size 8k;

}

后两条一定要加上,否则会报请求的页面过大之类的, 不过,这样设置之后这个网站只能用来查看 cacti 了。

重启 nginx

service nginx restart

然后设置 php 时区,

cd /usr/local/nginx/html/cacti/vi include/global_constants.php

如果不写时区的话,会在访问 cacti 的页面上出现日志

It is not safe to rely on the system’s timezone settings

在写 php 程序中有时会出现这样的警告:PHP Warning: date(): It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ‘UTC’ for ‘8.0/no DST’ instead in D:\PHPWEB\news\file.php on line 17。

这是因为 PHP 所取的时间是格林威治标准时间,所以和你当地的时间会有出入格林威治标准时间和北京时间大概差 8 个小时左右,我们可以按照下面的方法解决:

1、在页头使用 date_default_timezone_set() 设置我的默认时区为北京时间,即 <?phpdate_default_timezone_set(“PRC”);?> 就可以了。

2、在 php.ini 中设置 date.timezone 的值为 PRC,设置好以后的为:date.timezone=PRC,同时取消这一行代码的注释,即去掉前面的分号就可以了。

或在第二行添加

date_default_timezone_set(“Asia/Chongqing”);

接下来配置 snmp, 编辑 /etc/snmp/snmpd.conf

vi /etc/snmp/snmpd.conf

然后找到 41 行将 public 改成一个较为复杂的名字:

com2sec notConfigUser  default      public

然后找到 62 行

access  notConfigGroup “”      any      noauth    exact  systemview none none

将 systemview 改成 all:

access  notConfigGroup “”      any      noauth    exact  all none none

然后去掉 85 行的注释:

view all    included  .1                              80

保存配置文件后启动 snmp

service snmpd start

时区的问题解决了,可是出现了令一个 bug:

Error

The following PHP extensions are missing:

* sockets

Please install those PHP extensions and retry

更多详情见请继续阅读下一页的精彩内容 :http://www.linuxidc.com/Linux/2014-08/105112p2.htm

到网上一搜索,原因是在编译 php 时没有配置 socket 支持

解决方法一:重新编译 php

解决方法二:单独编译 socket 模块,之后手动为 php 添加此模块。

编译 php 时需要加上参数./configure –enable-sockets

可以通过 #php - m 查看可以有 sockets 支持,如果支持的话 php - m 后会输出 sockets

如果编译时没有添加,也不需要 LAMP 环境都重新配置。

方法:

1、进入 php 源文件下 ext/sockets 目录

[root@68Q ~]# cd /aa/php-5.3.6/ext/sockets/

2、执行命令

[root@68Q ~]# /usr/local/php5/bin/phpize

3、编译安装

[root@68Q sockets]# ./configure –enable-sockets –with-php-config=/usr/local/php5/bin/php-config

make

make install

4、配置 php.ini

[root@68Q ~]# ll /usr/local/php5/lib/php/extensions/no-debug-non-zts-20090626/

总用量 96

-rwxr-xr-x 1 root root 97482 9 月  11 17:32 sockets.so

[root@68Q ~]#

[root@68Q ~]# vi /usr/local/php5/php.ini

搜索 extension,并添加扩展模块引用

extension_dir =  “/usr/local/php5/lib/php/extensions/no-debug-non-zts-20090626/”

extension = sockets.so

5、检查 php.ini 配置文件正确性

/usr/local/php5/bin/php -v

6、检查已安装模块

/usr/local/php5/bin/php -m

7、重启 php-fpm

killall php-fpm

/usr/local/sbin/php-fpm

cacti 生成不了图像,这样处理;根据自己的路径来设置一下~~~~

[root@68Q sockets]# /usr/local/php5/bin/php -q /usr/local/nginx/html/cacti/poller.php –force -d

还有客户端的 SNMP 服务器是否有问题

至此,这样就能访问了。

更多 CentOS 相关信息见 CentOS 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=14

我在 CentOS 6.4 下搭建一个 Cacti,本来感觉很容易,可是后来感觉都快赶上红军长征了,下面我来介绍一下我在搭建 cacti 的过程中,出现的的问题及解决方法。

RHEL6.4 中使用 Cacti+Spine 监控主机实现发送邮件报警 http://www.linuxidc.com/Linux/2013-11/92795.htm

RHEL6.4 中使用 Cacti+Spine 监控远程主机 http://www.linuxidc.com/Linux/2013-11/92796.htm

CentOS 5.5 完整安装 Cacti+Spine http://www.linuxidc.com/Linux/2011-12/49701.htm

CentOS 6 下 Cacti 搭建文档 http://www.linuxidc.com/Linux/2013-06/86595.htm

RHEL5.9 下 Cacti 监控部署详解 http://www.linuxidc.com/Linux/2013-06/85427.htm

CentOS 6.3 下 Cacti 安装详解 http://www.linuxidc.com/Linux/2013-05/84279.htm

CentOS Linux 下快速安装配置 Cacti 中文版 http://www.linuxidc.com/Linux/2013-03/81627.htm

1. 安装 snmp 软件不成功, 总是说缺一些插件,都有什么没有安装,最后被我攻克了

yum -y install lm_sensors net-snmp net-snmp-utils

2. 安装 rrdtool 报错

首先要把 rrdtool 所需要的依赖包安装好,否则,总是报错

yum -y install cairo-devel glib2-devel pango-devel intltoolwget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.4.7.tar.gz

./configure –prefix=/usr/local

make &&  make install

然后就是下载 cacti 的安装包了

wget http://www.cacti.net/downloads/cacti-0.8.7i.tar.gz

tar -zxvf cacti-0.8.7i.tar.gz

cp -r cacti-0.8.7i /usr/local/nginx/html/cacti  # 复制到 html 目录

useradd cactiuser -M -s /sbin/nologin          # 创建 cacti 用户

chown -R cactiuser.cactiuser /usr/local/nginx/html/cacti/rra/ # 改变属主和属组

chown -R cactiuser.cactiuser /usr/local/nginx/html/cacti/log/

然后创建数据库:

create database cactidb default character set utf8;  #创建数据库

grant all on cactidb.* to cactiuser@localhost identified by ‘123456’; # 创建一个 mysql 用户

use cactidb  # 使用刚才创建的数据库

source /usr/local/nginx/html/cacti/cacti.sql # 导入 cacti 数据

接下来我们编辑 cacti 配置文件 /usr/local/nginx/html/cacti/include/config.php

cd /usr/local/nginx/html/cacti/

vi include/config.php

编辑下面内容:

$database_type=”mysql”;            # 数据库类型

$database_default=”cactidb”;      # 数据库名字

$database_hostname=”localhost”;    # 数据库主机

$database_username=”cactiuser”;    # 数据库用户

$database_password=”123456″;      # 数据库密码

$database_port=”3306″;            # 数据库端口

$database_ssl=false; 然后修改 nginx 配置文件像下面:

vi /usr/local/nginx/config/nginx.conf

location / {
              root  html;
            index  index.php;
        }

        location ~ \.php$ {
            fastcgi_pass        127.0.0.1:9000;
            fastcgi_index      index.php;
            include fastcgi.conf;
            fastcgi_buffers 8 8k;

fastcgi_buffer_size 8k;

}

后两条一定要加上,否则会报请求的页面过大之类的, 不过,这样设置之后这个网站只能用来查看 cacti 了。

重启 nginx

service nginx restart

然后设置 php 时区,

cd /usr/local/nginx/html/cacti/vi include/global_constants.php

如果不写时区的话,会在访问 cacti 的页面上出现日志

It is not safe to rely on the system’s timezone settings

在写 php 程序中有时会出现这样的警告:PHP Warning: date(): It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ‘UTC’ for ‘8.0/no DST’ instead in D:\PHPWEB\news\file.php on line 17。

这是因为 PHP 所取的时间是格林威治标准时间,所以和你当地的时间会有出入格林威治标准时间和北京时间大概差 8 个小时左右,我们可以按照下面的方法解决:

1、在页头使用 date_default_timezone_set() 设置我的默认时区为北京时间,即 <?phpdate_default_timezone_set(“PRC”);?> 就可以了。

2、在 php.ini 中设置 date.timezone 的值为 PRC,设置好以后的为:date.timezone=PRC,同时取消这一行代码的注释,即去掉前面的分号就可以了。

或在第二行添加

date_default_timezone_set(“Asia/Chongqing”);

接下来配置 snmp, 编辑 /etc/snmp/snmpd.conf

vi /etc/snmp/snmpd.conf

然后找到 41 行将 public 改成一个较为复杂的名字:

com2sec notConfigUser  default      public

然后找到 62 行

access  notConfigGroup “”      any      noauth    exact  systemview none none

将 systemview 改成 all:

access  notConfigGroup “”      any      noauth    exact  all none none

然后去掉 85 行的注释:

view all    included  .1                              80

保存配置文件后启动 snmp

service snmpd start

时区的问题解决了,可是出现了令一个 bug:

Error

The following PHP extensions are missing:

* sockets

Please install those PHP extensions and retry

更多详情见请继续阅读下一页的精彩内容 :http://www.linuxidc.com/Linux/2014-08/105112p2.htm

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-20发表,共计7868字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中