189 8069 5689

centos7cacti搭建

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
$conn=mysql_connect('localhost','test','test');
if ($conn)
echo "database connect ok";
else
echo "database connect failure";
?>
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

创新互联建站-专业网站定制、快速模板网站建设、高性价比武冈网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式武冈网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖武冈地区。费用合理售后完善,10多年实体公司更值得信赖。

/ 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上的页面对插件进行安装。**


分享标题:centos7cacti搭建
文章位置:http://jkwzsj.com/article/ihedph.html

其他资讯