1.安装LAMP环境
# yum install httpd* php* mariadb* net-snmp* rrdtool rrdtool-php rrdtool-perl rrdtool-devel gd gd-devel php-gd
2.配置snmp
# vi /etc/snm/snmpd.conf
41 default >
127.0.0.1
62 systemview >
all
85 #
删掉
3.Mariadb配置
1)启动
# systemctl start mariadb.service
2)为root设置密码
# mysql -uroot -p(密码) 没有密码去掉-p直接回车
# use mysql;
# update user set password=password(新密码) where user='root'
# grant all privileges on *.* to root@localhost identified by '123.org' with grant option;
# flush privilegs; //立即生效
3)创建cacti数据库并创建用户
# create database cacti default character set utf8; //创建cacti数据库
# flush privilegs; //立即生效
# grant all privileges on cacti.* to cacti@localhost identified by '123.org' with grant option; //创建cacti用户并授权
# flush privilegs;
4.cacti配置
1)下载
# wget http://www.cacti.net/downloads/cacti-0.8.8f.tar.gz
2)配置
# tar zxvf cacti-0.8.8f.tar.gz
# mv cacti-0.8.8f /var/www/html/cacti //移动
# mysql -urcacti -p123.org cacti < /var/www/html/cacti/cacti.sql //导入数据库
# vi /var/www/html/cacti/include/config.php
# vi /var/www/html/cacti/include/global.php //修改两个文件,一样,如下
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "
cacti";
$database_password = "
123.org";
$database_port = "3306";
$database_ssl = false;
# useradd -r -M cacti
# chown -R cacti /var/www/html/cacti/rra/
# chown -R cacti /var/www/html/cacti/log/ //修改这两个文件属性
5.创建计划任务
# crontab -e
*/5 * * * * php /var/www/html/cacti/poller.php > dev/null 2>&1
6.调试
1)启动服务
# systemlctl stat httpd.service //启动http服务
若无法访问修改firewalld
# friewall-cmd --permanent --zone=public --add-port=80/tcp
# friewall-cmd --permanent --zone=public --add-port=3306/tcp
# friewall-cmd --permanent --zone=public --add-port=161/udp
再次访问
# vi /var/www/html/index.php //编辑一个php测试文档
phpinfo();
?>
2)修改服务属性
# systemctl enable snmpd
# systemctl enable mariadb
# systemctl enable httpd
# systemctl enable crond
# systemctl start crond
# systemctl start snmpd
7.安装
web访问127.0.0.1/cacti安装
8.安装spine
因cacti自带cmd.php轮询数据较慢,可以安装spine。
1)下载
# wget http://www.cacti.net/downloads/spine/cacti-spine-0.8.8f.tar.gz
2)安装
# tar zxvf cacti-spine-0.8.8f.tar.gz
# cd cacti-spine-0.8.8f
# ./configure
# make && make install
3)配置
# cp /usr/local/spine/etc/spine.conf.dist /etc/spine.conf
4)测试
# /usr/local/spine/bin/spine
6)cacti设置
进入cacti页面设置spine路径
Console -> Configuration -> Settings -> Paths -> Alternate Poller Path -> Spine Poller File Path/usr/local/spine/bin/spine
修改Cacti使用的Poller TypeConsole -> Cacti Settings->Poller->Poller Type在下拉中选择spine
修改计划任务
# crontab -e
*/1 * * * * php /var/www/html/cacti/poller.php > /dev/null 2>&1
查看