Linux ·

CentOS 7.3下安装Cacti 监控 Linux 主机

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 主机 Linux 第1张

测试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 主机 Linux 第2张

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

CentOS 7.3下安装Cacti 监控 Linux 主机 Linux 第3张

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

CentOS 7.3下安装Cacti 监控 Linux 主机 Linux 第4张

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

CentOS 7.3下安装Cacti 监控 Linux 主机 Linux 第5张

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

CentOS 7.3下安装Cacti 监控 Linux 主机 Linux 第6张

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

参与评论