Linux-Cacti监控{Verson:1.2.8}
秦宇-laopa 人气:4首先需要一个LAMP平台 或LNMP平台
yum -y install httpd mariadb php mariadb-server mariadb-devel zlib freetype libjpeg \
fontconfig gd libxml2 php-gd php-mysql cairo-devel libxml2-devel glib2 glib2-devel libpng \
libpng-devel freetype-devel libart_lgpl pango pango-devel perl-CPAN //所有环境
关闭防火墙和黑盒子 以免排错问题
Systemctl stop firewalld && systemctl disable firewalld Service firewalld stop Setenforce 0
测试LAMP平台:
Vim /var/www/html/index.php 添加 <?php Phpinfo(); ?> Systemctl start httpd && systemctl enable httpd Systemctl start mariadb && systemctl enable mariadb 访问测试:
成功
下一步
cacti监控需要协议: snmp
Yum -y install net-snmp
Yum -y install net-snmp-utils ///需要在被监控的PC 与监控PC上下载
Systemctl start snmpd
- 下载 rddtool 链接:https://oss.oetiker.ch/rrdtool/pub/rrdtool-1.7.0.tar.gz
Cd /root/rrd-version
./configre --prefix=/usr/local --做这一步 可以直接跳过优化路径
Make && make install
2.下载cacti:https://www.cacti.nethttps://img.qb5200.com/download-x/downloads/cacti-1.2.8.tar.gz //cacti 包 绿色免安装
3.添加用户cacti
Useradd cacti
- 将cacti包放在html目录下 并基于属组属主
Tar zxf cacti-1.2.8.tar.gz -C /var/www/html/
Cd /var/www/html
Mv cacti-1.2.8 cacti
Chown -R cacti.cacti cacti/
- 创建cacti数据库 并授权,并导入数据
CREATE DATABASE cacti DEFAULT CHARACTER SET utf8;
GRANT all ON cacti.* TO 'cacti'@'localhost' IDENTIFIED BY '123.com';
------------进入数据库,并且导入数据------------
mysql>use cacti;
mysql> source /var/www/html/cacti/cacti.sql
Mysql>flush privileges; //刷新数据库
Mysqladmin -u root password 123.com //为root用户设置一个密码
- 修改cacti配置文件
Vim /var/www/html/cacti/include/config.php
修改以下配置文件为自己所需的
$database_type = 'mysql';
$database_default = 'cacti';
$database_hostname = 'localhost';
$database_username = 'cacti';
$database_password = '123.com';
$database_port = '3306';
$database_retries = 5;
$database_ssl = false;
$database_ssl_key = '';
$database_ssl_cert = '';
$database_ssl_ca = '';
- 访问cacti页面 并进行排错
http://192.168.9.6/cacti/index.php
访问报错:System log file is not available for writing, please enable write access Log: /var/www/html/log/cacti.log
Touch /var/www/html/log/cacti.log && chmod a+w /var/www/html/log/cacti.log
chown -R cacti.cacti /var/www/html/cacti/rra
若一直无法访问 则
[root@swarm-node-work1192 html]# chmod -R a+r cacti
开始一个错一个错解决
PHP推荐配置;
version |
5.4.16 |
>= 5.4.0 |
通过 |
PHP 5.4.0 是最低版本要求 |
memory_limit |
128M |
>= 800M |
警告 |
至少 800M MB 内存 |
max_execution_time |
30 |
>= 60 |
警告 |
至少 60 m 执行时间 |
date.timezone |
|
>= |
错误 |
A valid timezone that matches MySQL and the system |
Vim /etc/php.ini
成功
MySQL - 时区支持
Shell>mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql
输入密码 解决mysql 的时区问题
最后 MYSQL设置
首先vim /etc/my.cnf
再mysqld下添加一条
version |
5.5.64-MariaDB |
>= |
5.6 |
可忽略版本问题
collation_server |
latin1_swedish_ci |
= |
utf8mb4_unicode_ci |
解决:
Set global collation_server=utf8mb4_unicode_ci;
character_set_client |
latin1 |
= |
utf8mb4 |
解决:
Set global character_set_client=utf8mb4;
max_allowed_packet |
1048576 |
>= |
16777216 |
解决:
Set global max_allowed_packet=17700000;
join_buffer_size |
0M |
>= |
15M |
解决:
set global join_buffer_size=20971520;
innodb_file_per_table |
OFF |
= |
ON |
解决;
Set global innodb_file_per_table=ON
innodb_file_format |
Antelope |
= |
Barracuda |
解决;
Set global innodb_file_format=Barracuda
innodb_large_prefix |
OFF |
= |
1 |
解决;
Set global innodb_large_prefix=1
innodb_flush_log_at_trx_commit |
1 |
= |
2 |
解决;
Set global innodb_flush_log_at_trx_commit=2
然后点击下一页,继续安装.
目录权限检查
脚本:
#!/bin/bash
chmod a+w /var/www/html/cacti/resource/snmp_queries/
chmod a+w /var/www/html/cacti/resource/script_server/
chmod a+w /var/www/html/cacti/resource/script_queries/
chmod a+w /var/www/html/cacti/scripts/
chmod a+w /var/www/html/cacti/log/
chmod a+w /var/www/html/cacti/cache/boost/
chmod a+w /var/www/html/cacti/cache/mibcache/
chmod a+w /var/www/html/cacti/cache/realtime/
chmod a+w /var/www/html/cacti/cache/spikekill/
设置监控周期时间 范围填写自己网段范围[需要监控的] 点击附加选项值 下一步
一路下一页 开始安装
-------添加设备--------
在被监控的客户机上
Yum -y install net-snmp
Vim /etc/snmp/snmpd.conf 添加
//取消注释
Vim /etc/hosts
添加新设备;
成功
---------如不显示图像------
如要快速收集 则在监控服务端输入
/usr/bin/php /var/www/html/cacti/poller.php
完成数据采集
若要实现自动采集;
添加计划周期表:
在监控服务墙上:
#: crontab -u cacti -e
*/5 * * * * /usr/bin/php /var/www/html/cacti/poller.php > https://img.qb5200.com/download-x/dev/null
意义: 每五分钟输入一次 php /var/www/html/cacti/poller.php 实现自动采集
加载全部内容