centos7 安装Cacti

安装环境:3.10.0-123.el7.x86_64

1、关闭防火墙和SElinux

# systemctl stop iptables.servce

# systemctl disable iptables.sercice

# setenforce 0

2:yum设置

具体见更换centos7的yum源文档

3:安装cacti依赖的软件(mysql可能会安装不成功,后面在另行安装)

#yum -y install mysql mysql-server mysql-devel httpd php php-pdo php-snmp php-mysql lm_sensors net-snmp net-snmp-utils net-snmp-libs rrdtool rrdtool-devel perl-PlRPC perl-DBI perl-rrdtool perl-DBD-MySQL

4:装好依赖软件之后,snmp有3个地方需要配置一下

#vim /etc/snmp/snmpd.conf

第41行:将 com2sec notConfigUser default public 中的 "default" 改为 "127.0.0.1"

第62行:将 access notConfigGroup "" any noauth exact systemview none none 中的 "systemview" 改为 "all"

第85行:将 #view all include .1 80 这一行前面的 # 号去掉

5:配置好snmp以后我们来启动3个重要的服务(httpd\snmp\mysql)

#systemctl start snmpd.service(启动snmpd)

#systemctl enable snmpd.service(开机启动)

#systemctl start httpd.service

#systemctl enable httpd.service

其中在启动mysql的时候会出现这个报错,是由于之前没有安装成功导致。

重新安装一下Mysql,步骤如下:

A、# wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm 

B、# rpm -ivh mysql-community-release-el7-5.noarch.rpm

C、# yum install mysql-server

安装成功后

#systemctl start mysql.service

#systemctl enable mysql.service

6:安装并配置cacti 

#wget http://www.cacti.net/downloads/cacti-0.8.8b.tar.gz //cacti官网最新版

#tar -zxvf cacti-0.8.8b.tar.gz

#mv cacti-0.8.8b /var/www/html/cacti //将cacti-0.8.8b文件夹移到/var/www/html目录下,并将cacti-0.8.8b重命名为cacti

7:设置mysql数据库

#mysql -uroot -p //新装的mysql没有密码,直接回车进入mysql数据库

mysql>create database cacti; //首先创建cacti数据库,注意别丢了分号

mysql>grant all privileges on cacti.* to cacti@localhost identified by 'cacti' with grant option; //创建cacti用户并授权

mysql>use cacti

mysql>source /var/www/html/cacti/cacti.sql; //导入cacti数据库文件

mysql>exit;

8:配置cacti

#vim /var/www/html/cacti/include/config.php

$database_type = "mysql";

$database_default = "cacti";

$database_hostname = "localhost";

$database_username = "cactiuser"; //因为我们先前在数据库建的是 "cacti" 用户,所以这里默认的 "cactiuser" 要改为 "cacti"

$database_password = "cactiuser"; //这里默认的密码我们也要改为 "cacti"

$database_port = "3306";

9:增加 cacti 用户以用来写入rrd和log目录的数据,否则就会生成不了图片

#useradd cacti

#cd /var/www/html/cacti

#chown -R cacti rra/

#chown -R cacti log/

10、配置Apache

#vim /etc/httpd/conf/httpd.conf

ServerSignature On  #添加,在错误页中显示Apache的版本,Off为不显示

Options Indexes FollowSymLinks  #修改为:Options Includes ExecCGI FollowSymLinks(允许服务器执行CGI及SSI,禁止列出目录)

#AddHandler cgi-script .cgi#修改为:AddHandler cgi-script .cgi .pl (允许扩展名为.pl的CGI脚本运行)

AllowOverride None#修改为:AllowOverride All (允许.htaccess)

AddDefaultCharset UTF-8#修改为:AddDefaultCharset GB2312 (添加GB2312为默认编码)

DirectoryIndex index.html   #修改为:DirectoryIndex index.html index.htm Default.html Default.htm index.php(设置默认首页文件,增加index.php)

systemctl restart httpd.service #重启apache

11、添加任务计划

具体多长时间让cacti生成一次监控图表自己决定,这里以cacti的默认时间5分钟生成一次为例

#crontab -e

加入这一行保存即可

*/5 * * * * php /var/www/html/cacti/poller.php > /dev/null 2>&1

12:配置好之后重启输入 http://ip/cacti,如下图所示

第一次登入时默认账号和密码为 admin/admin

然后会要求强制改密码


 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值