Linux监控---安装cacti

1.cacti简介php

aHR0cHM6Ly9tbWJpei5xbG9nby5jbi9tbWJpei9j

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

2.cacti安装前准备mysql

1安装snmplinux

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

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

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

修改snmp的配置文件:centos

[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

检查端口及进程

2.png

测试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则会出现

去去去.png

点击Next,若是配置正确则全部的都会变蓝,不然会出现红色

4.png

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

5.png

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

6.png

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

7.png



此文是在CentOS7.3下的操做,转载请联系做者

相关文章
相关标签/搜索