1、做事器配置
构建cacti监控平台时要前辈行LAMP架构,这边实验我直接用yum一键安装、在生产环境中最好利用手工编译安装
(1)yum安装LAMP
yum -y install httpd
yum -y install mariadb mariadb-server
yum -y install php php-mysql
#编写php首页进行测试机
cd /var/www/html/
vim index.php
<?php
phpinfo();
?>
#关闭防火墙、SELinux
systemctl stop firewalld
setenforce 0
vi /etc/selinux/config
systemctl start httpd
chkconfig httpd on
(2)安装工具包,snmp协议,rrdtool
yum -y install zlib freetype libjpeg fontconfig gd libxml2 php-gd libart_lgpl libpng
yum -y install net-snmp net-snmp-utils
yum -y install rrdtool rrdtool-devel
(3)安装cacti监控源码包
#用wget下载最新的源码包
yum install wget
wget https://www.cacti.net/downloads/cacti-1.1.38.tar.gz
#解压到/var/www/html底下然后用mv重命名为cacti
tar zxvf cacti-1.1.38.tar.gz -C /var/www/html/
mv /var/www/html/cacti-1.1.38/ /var/www/html/cacti
#创建cacti管理用户
useradd -M -s /sbin/nologin cacti
#修正cacti属主和数组
chown -R cacti.cacti /var/www/html/cacti/
#修正cacti底下include底下config.php文件
$database_type = "mysql";
$database_default = "cacti"; #修正数据库名称
$database_hostname = "localhost";
$database_username = "cacti"; #修正授权用户
$database_password = "123456"; #修正授权密码
$database_port = "3306";
$database_ssl = false;
(4)创建数据库斌付与权限
#首先开启数据库并数据库设置密码
systemctl start mariadb.service
mysqladmin -uroot password abc@123
#进入数据库船舰cacti数据库并付与权限
mysql -u root -p
#创建名为cacti的数据库并设定字符集utf-8
create database cacti default character set utf8;
#付与cacti用户权限上岸密码为
grant all on cacti. to 'cacti'@'localhost' identified by '123456';
#设置韶光
grant select on mysql.time_zone_name to 'cacti'@'localhost' identified by '123456';
quit
#把cacti目录底下的cacti.sql导入到cacti数据库里面(这边利用的用户时cacti用户付与的密码时asd123)
mysql -u root -p cacti < cacti.sql
(5)进入安装页面http://192.168.1.84/cacti/install
#打开php.ini配置文件找到date.timezone原来是注释状态须要去掉前面的;分号然后在=即是后面空格加上Asia/Shanghai
date.timezone = Asia/Shanghai
重启HTTP做事
# yum -y install php-ldap php-mbstring php-process
yum install php-snmp
systemctl restart httpd
mysql -uroot -p
Set global collation_server=utf8_general_ci;
Set global character_set_client=utf8;
Set global max_heap_table_size=419430400;
Set global max_allowed_packet=17700000;
Set global tmp_table_size=73400320;
Set global join_buffer_size=73400320;
Set global innodb_file_per_table=ON;
Set global innodb_flush_log_at_trx_commit=2;
wget https://www.cacti.net/downloads/spine/cacti-spine-1.1.38.tar.gz
./configure && make && make install
cp /usr/local/spine/etc/spine.conf.dist /usr/local/spine/etc/spine.conf
vi /usr/local/spine/etc/spine.conf
vi cacti.log
chown cacti.cacti cacti.log
chmod 777 cacti.log
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 install perl-devel perl-CPAN perl-YAML
cacti有实时流量图,但大图没流量,而且不能天生rrd文件,可能缘故原由总结:
1.system utilities->Rebuild poller cache
2.系统韶光不准确,重新设置韶光
3.图像没有天生,运行php /var/www/html/poller.php --force
4.权限问题,修正权限chmod 777 -R /var/www/html/rra
5.数据库表有破坏,修复mysqlcheck -ao cacti --auto-repair -uroot -p
6.重启snmpd做事service snmpd restart
或者:snmpd -Lsd -Lf /dev/null -p /var/run/snmpd.pid -a