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

CentOS 7.3下安装Cacti 监控 Linux 主机

159次阅读
没有评论

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

1.Cacti 简介

Cacti 在英文中的意思是仙人掌的意思,Cacti 是一套基于 PHP、MySQL、SNMP 及 RRDTool 开发的网络流量监测图形分析工具。主要功能是用 snmp 服务获取数据,然后用 rrdtool 储存和更新数据,当用户需要查看数据的时候用 rrdtool 生成图表呈现给用户。

2.CentOS 7.3 下 Cacti 安装前准备

1 安装 snmp

[root@localhost~]# yum install -y net-snmp* (注意:这里是 net-snmp 的所有软件包)

查看是否存在默认配置文件:

[root@localhost~]# ll /etc/snmp/snmpd.conf

修改 snmp 的配置文件:

[root@localhost ~]# cd /etc/snmp/

[root@localhost snmp]# cp snmpd.conf{,.bak}  // 备份

[root@localhost snmp]# vim snmpd.conf

修改如下:

1)com2sec notConfigUser default public

(将 default 改为 127.0.0.1)

2)access notConfigGroup”” any noauth exact systemview none none(将 systemview 改为 all)

3)#view all included .1(去掉前面的 #)

保存并启动 snmp:

[root@localhost snmp]# systemctl startsnmpd

检查端口及进程

CentOS 7.3 下安装 Cacti 监控 Linux 主机

测试 snmp 服务

[root@localhost snmp]# snmpget -v 1 -c publiclocalhost system.sysUpTime.0

2. 安装 RRDTool

1 安装 libart_lgpl

[root@localhost~]# yum install libart_lgpl libart_lgpl-devel

2 安装 rrdtool

[root@localhost~]# yum install -yftp://rpmfind.net/linux/centos/7.3.1611/os/x86_64/Packages/rrdtool-1.4.8-9.el7.x86_64.rpmftp://rpmfind.net/linux/centos/7.3.1611/os/x86_64/Packages/rrdtool-devel-1.4.8-9.el7.x86_64.rpm

3.yum 安装 LAMP 环境

1 安装 Apache

[root@localhost ~]# yum install -y httpdhttpd-devel

2 安装数据库 mariadb

[root@localhost ~]# yum install -y mariadbmariadb-server

3 安装 php

[root@localhost ~]# yum install phpphp-mysql php-common php-gd php-xml –y

4 安装相关 lib 库

[root@localhost ~]# yum install gcc glibcglibc-common cairo pango zlib zlib-devel freetype freetype-devel gd  -y

5 安装 gd-devel

[root@localhost ~]# yum install -ygd-devel

(rhel6 中没有自带的需要下载手动安装,rhel7 中不需要)

6Apache 操作

1)启动 Apache 并检查

[root@localhost ~]# systemctl start httpd

[root@localhost ~]# lsof -i :80

[root@localhost ~]# netstat -lntp | grep 80

2)测试文件

[root@localhost~]# echo -e “<?php \nphpinfo(); \n?>”>/var/www/html/index.php

(在浏览器中访问 http://ip,出现 PHP 页面即表示安装正常)

[root@localhost~]#  rm -rf /var/www/html/index.php  // 删除测试文件

7. 数据库操作

1)启动并检测数据库

[root@localhost ~]# systemctl startmariad[root@localhost ~]# lsof -i :3306

[root@localhost ~]# netstat -lntp | grep3306

2)创建 cacti 数据库,并查看

3)创建 cactiuser 用户并授权

[root@localhost ~]# mysql -e “grantall on cacti.* to cactiuser@localhost identified by ‘cactiuser’;”

[root@localhost ~]# mysqladminflush-privileges  // 刷新权限表

4. 安装并配置 cacti

1)解压

[root@localhost ~]# tar xfcacti-0.8.8f.tar.gz -C /var/www/html/

[root@localhost ~]# cd /var/www/html/

[root@localhost html]# ln -sv cacti-0.8.8f/cacti    // 做个软连接

2)初始化 cacti 数据库

[root@localhost html]# cd cacti

[root@localhost cacti]# mysql cacti <cacti.sql

3)修改 cacti 配置文件

由于之前设置的配置一致,所以这里不需要修改。

路径:vim include/config.php

4)创建 cacti 用户访问 cacti 的 rra 和 log 的权限 [root@localhost cacti]# useradd cactiuser[root@localhost cacti]# chown -Rcactiuser:cactiuser log/ rra/

5)修改 /etc/php.ini, 增加时区设置

[root@localhost cacti]# vim /etc/php.ini

;date.timezone = 改为 date.timezone =Asia/Shanghai

重启 Apache:

[root@localhost cacti]# systemctl restarthttpd

6)切换用户操作 [root@localhost cacti]# su – cactiuser

[cactiuser@localhost ~]$ /usr/bin/php/var/www/html/cacti/poller.php  // 采集结果保存在 rra 下,日志记录在 log 下

5. 页面配置 cacti

浏览器输入 http://ip/cacti 则会出现

CentOS 7.3 下安装 Cacti 监控 Linux 主机

点击 Next,如果配置正确则所有的都会变蓝,否则会出现红色

CentOS 7.3 下安装 Cacti 监控 Linux 主机

点击右下角的 finsh, 会出现登录界面,在系统默认的第一次登录用户名和密码都是 admin

CentOS 7.3 下安装 Cacti 监控 Linux 主机

为了安全起见,系统会在第一次登录时强制修改密码

CentOS 7.3 下安装 Cacti 监控 Linux 主机

最后就是登录成功的界面了

CentOS 7.3 下安装 Cacti 监控 Linux 主机

Cacti 监控内网本机 TCP 连接状况  http://www.linuxidc.com/Linux/2016-08/133869.htm

CentOS 6.6 下 Cacti 安装部署  http://www.linuxidc.com/Linux/2015-11/125039.htm

CentOS7 下 Cacti 0.8.8g 安装及 SNMP 简介  http://www.linuxidc.com/Linux/2017-03/141998.htm

Cacti 监控内网本机 TCP 连接状况  http://www.linuxidc.com/Linux/2016-08/133869.htm

CentOS7 下安装搭建 Cacti 详解  http://www.linuxidc.com/Linux/2017-03/141995.htm

Linux 监控工具 Cacti 安装部署详解  http://www.linuxidc.com/Linux/2017-03/141612.htm

Cacti 的详细介绍 :请点这里
Cacti 的下载地址 :请点这里

本文永久更新链接地址 :http://www.linuxidc.com/Linux/2017-10/147672.htm

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