温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

centos 7 cacti搭建

发布时间:2020-06-14 11:56:02 来源:网络 阅读:460 作者:卜谷鸟 栏目:系统运维

1、关掉selinux
setenforce 0
2、安装相应的工具
yum -y install wget unzip vim
3、安装httpd、mariadb数据库、php、php数据库相关、rrdtool绘图工具相关及对应的图形库,snmp等
yum -y install httpd mariadb-server mysql-devel php php-mysql php-gd php-pear rrdtool rrdtool-devel rrdtool-php rrdtool-perl gd gd-devel php-gd net-snmp net-snmp-utils php-snmp net-snmp-libs
3.1、配置httpd
systemctl start httpd
systemctl enable httpd
firewall-cmd --reload
3.2、配置mariadb数据库
systemctl start mariadb
mysql_secure_installation
Set root password? [Y/n] n
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
mysql -u root -p
3.2.1、创建用于测试php和mariadb连通性的用户
grant all privileges on . to test@localhost identified by 'test';
flush privileges;
systemctl restart mariadb
systemctl enable mariadb
firewall-cmd --permanent --add-port=3306/tcp
firewall-cmd --reload
3.3、配置PHP时区
vim /etc/php.ini
date.timezone =PRC 修改时区
systemctl restart httpd
3.4、建立测试页,注意红色标记部分和测是账户的一致;
vim /var/www/html/index.php
<?php
$conn=mysql_connect('localhost','test','test');
if ($conn)
echo "database connect ok";
else
echo "database connect failure";
?>
<?php
phpinfo()
?>
systemctl restart httpd
3.4.1、测试连通性,ok没问题,开始cacti的安装。
4、在tmp目录下创建cacti文件夹用户下载cacti相应的安装包
cd /tmp
mkdir cacti
5、进入到cacti目录,开始安装
cd /tmp/cacti/
wget http://www.cacti.net/downloads/cacti-0.8.8f.tar.gz
tar zxvf cacti-0.8.8f.tar.gz
mv cacti-0.8.8f /var/www/html/cacti
5.1、创建cacti数据库和cacti用户,赋予权限
mysql -u root -p
create database cacti default character set utf8;
grant all privileges on cacti. to cacti@localhost identified by 'cacti';
flush privileges;
5.2、把cacti.sql导入数据库
mysql -ucacti -predhat cacti < /var/www/html/cacti/cacti.sql
5.3、修改config.php和global.php中对应数据库的信息
vim /var/www/html/cacti/include/config.php
vim /var/www/html/cacti/include/global.php

/ make sure these values refect your actual database/host/user/password /
$database_type = "mysql"; 数据库名称
$database_default = "cacti";数据库名称
$database_hostname = "127.0.0.1";主机名称
$database_username = "cacti";数据库用户名
$database_password = "cacti";数据库密码
$database_port = "3306";
$database_ssl = false;

/
6、配置snmp,修改一下对应行信息
vim /etc/snmp/snmpd.conf

41 com2sec notConfigUser default public
62 access notConfigGroup "" any noauth exact systemview none none
85 #view all included .1 80

systemctl restart snmpd.service
systemctl enable snmpd.service
7、创建cacti用户,授权目录权限
useradd -r -M cacti
chown -R cacti /var/www/html/cacti/rra/
chown -R cacti /var/www/html/cacti/log/
8、配置一个抓图的计划任务
crontab -e
/5 /usr/bin/php /var/www/html/cacti/poller.php >> /tmp/cacti_rrdtool.log
执行poller.php, 生成图形
/usr/bin/php /var/www/html/cacti/poller.php
9、访问安装界面开始cacti的安装,http://ip/cacti/安装即可
下面为对应插件的安装,注意插件的版本与cacti的对应即可,老版本可能会报错
cacti插件setting、thold、monitor、wethermap、realtime、spine的安装

wget https://docs.cacti.net/media/plugin:settings-v0.71-1.tgz
mv plugin\:settings-v0.71-1.tgz /tmp/cacti/settings-v0.71-1.tgz
tar -zxvf settings-v0.71-1.tgz
mv settings /var/www/html/cacti/plugins/*

wget https://docs.cacti.net/media/plugin:thold-v0.5.0.tgz
mv plugin\:thold-v0.5.0.tgz /tmp/cacti/thold-v0.5.0.tgz
tar -zxvf thold-v0.5.0.tgz
mv thold /var/www/html/cacti/plugins/

wget https://docs.cacti.net/media/plugin:monitor-v1.3-1.tgz
mv plugin\:monitor-v1.3-1.tgz /tmp/cacti/monitor-v1.3-1.tgz
tar -zxvf monitor-v1.3-1.tgz
mv monitor /var/www/html/cacti/plugins/

wget https://github.com/howardjones/network-weathermap/releases/download/version-0.98a/php-weathermap-0.98a.zip
unzip php-weathermap-0.98a.zip
mv weathermap/ /var/www/html/cacti/plugins/
插件安装完毕后,进入weathermap视图,点击edit,如出现错误,需要修改weathermap/editor.php文件,将$ENABLED=false;改为$ENABLED=ture;
cd /var/www/html/cacti/plugins/weathermap/
vi editor.php
$ENABLED=true;
然后修改weathermap/configs/ 和weathermap/output/宿主权限:
chown -R apache:apache configs/
chown -R cacti:apache output/
修改完毕后就可以创建配置文件,添加图形。若出现不能编辑图形等问题,请关闭SElinux。
wget wget https://docs.cacti.net/media/plugin:realtime-v0.5-1.tgz --no-check-certificate
mv plugin\:realtime-v0.5-1.tgz /tmp/cacti/realtime-v0.5-1.tgz
tar -zxvf realtime-v0.5-1.tgz
mv realtime /var/www/html/cacti/plugins/
mkdir /var/www/html/cacti/cache
chown apache:apache -R /var/www/html/cacti/cache

wget http://www.cacti.net/downloads/spine/cacti-spine-0.8.8f.tar.gz
yum -y install libtool net-snmp-devel mysql-devel
tar zxvf cacti-spine-0.8.8f.tar.gz
cd cacti-spine-0.8.8f
./configure
make && make install
cp /usr/local/spine/etc/spine.conf.dist /etc/spine.conf

vim /etc/spine.conf
DBHost localhost
DBDatabase cacti
DBUser cacti
DBPass cacti
DBPort 3306
/usr/local/spine/bin/spine
SPINE: Using spine config file [/etc/spine.conf]
SPINE: Version 0.8.8f starting
SPINE: Time: 0.0913 s, Threads: 5, Hosts: 2

cat /var/www/html/cacti/log/cacti.log

firewall-cmd --permanent --add-port=161/udp
firewall-cmd --reload
然后进入cacti的Plugin Management上的页面对插件进行安装。**

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI