linux cpu占用率如何看
282
2022-11-13
Linux监控---安装cacti
1.cacti简介
Cacti在英文中的意思是仙人掌的意思,Cacti是一套基于PHP、MySQL、SNMP及RRDTool开发的网络流量监测图形分析工具。主要功能是用snmp服务获取数据,然后用rrdtool储存和更新数据,当用户需要查看数据的时候用rrdtool生成图表呈现给用户。
2.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
检查端口及进程
测试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 ~]# 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 ~]# lsof -i :80
[root@localhost ~]# netstat -lntp | grep 80
2)测试文件
[root@localhost~]# echo -e "">/var/-rf /var/ //删除测试文件
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/~]# cd /var/html]# ln -sv cacti-0.8.8f/cacti //做个软连接
2)初始化cacti数据库
[root@localhost html]# cd cacti
[root@localhost cacti]# mysql cacti 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 restartcacti]# su – cactiuser [cactiuser@localhost ~]$ /usr/bin/php/var/ //采集结果保存在rra下,日志记录在log下 5.页面配置cacti 浏览器输入http://ip/cacti则会出现 为了安全起见,系统会在第一次登录时强制修改密码 最后就是登录成功的界面了
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~