CentOS7搭建Cacti监控平台

笛里谁知壮士心,沙头空照征人骨。这篇文章主要讲述CentOS7搭建Cacti监控平台相关的知识,希望能为你提供帮助。

?搭建环境:一台CentOS7服务器,Cacti版本为1.2.2
一、首先关闭selinux,关闭防火墙,或者防火墙放行对应规则
vim /etc/selinux/config      #将SELINUX修改为disabled

CentOS7搭建Cacti监控平台

文章图片

systemctl disable firewalld   
systemctl status firewalld


二、安装epel源以及wlnmp软件源
安装epel源
yum install epel-release -y
安装wlnmp软件源
rpm -ivh http://mirrors.wlnmp.com/centos/wlnmp-release-centos.noarch.rpm


三、安装nginx、php、mysql以及相关依赖包
yum install wnginx wphp71 wmysql57 -y


yum install wphp71-ldap wphp71-snmp wrrdtool wnet-snmp wspine-1.2.2 sendmail -y


四、设置软链接以及取消被禁用的php函数


ln -sv /usr/local/mysql/lib/libmysqlclient.so.20 /usr/lib64/libmysqlclient.so.20


ln -sv /usr/local/mysql/lib/libmysqlclient.so /usr/lib64/libmysqlclient.so


 


取消被禁用的php函数


vim /usr/local/php/etc/php.ini


在disable_functions那一栏,将exec、shell_exec、popen等函数删除
CentOS7搭建Cacti监控平台

文章图片

重启php服务
/etc/init.d/php-fpm71 restart


重启nginx、mysql、snmpd服务
/etc/init.d/nginx restart
/etc/init.d/mysql restart
/etc/init.d/snmpd restart


五、修改mysql密码,原始密码默认为空,创建cacti数据库,修改相应权限
mysql -uroot -p
mysql> set password = password(\'test\');
mysql> CREATE DATABASE cacti DEFAULT CHARACTER SET utf8;
mysql> GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY \'test.com\';
mysql> GRANT SELECT ON mysql.time_zone_name TO cacti@localhost IDENTIFIED BY \'test.com\';
mysql> ALTER DATABASE cacti CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
mysql> flush privileges;
mysql> exit;
加载时区到mysql数据库
/usr/local/mysql/bin/mysql_tzinfo_to_sql /usr/share/zoneinfo/ | mysql -uroot -ptest mysql
 
六、cacti下载安装与配置修改


mkdir /data/www


cd /data/www


wget https://www.cacti.net/downloads/cacti-1.2.2.tar.gz


tar xf cacti-1.2.2.tar.gz
mv cacti-1.2.2 cacti
修改cacti数据库配置
vim /data/www/cacti/include/config.php
修改为如图
CentOS7搭建Cacti监控平台

文章图片

导入cacti.sql数据库
mysql -uroot -ptest cacti < /data/www/cacti/cacti.sql


touch一下日志文件
touch /data/www/cacti/log/cacti.log
touch /data/www/cacti/log/cacti_stderr.log
七、设置一下软链
ln -sv /usr/local/rrdtool/bin/rrdtool /usr/local/bin/rrdtool
ln -sv /usr/local/php/bin/php /usr/bin/php
ln -sv /usr/local/snmp/bin/snmpwalk /usr/local/bin/snmpwalk
ln -sv /usr/local/snmp/bin/snmpget /usr/local/bin/snmpget
ln -sv /usr/local/snmp/bin/snmpbulkwalk /usr/local/bin/snmpbulkwalk
ln -sv /usr/local/snmp/bin/snmpgetnext /usr/local/bin/snmpgetnext
ln -sv /usr/local/snmp/bin/snmptrap /usr/local/bin/snmptrap
【CentOS7搭建Cacti监控平台】修改cacti目录权限
chown -R www:www /data/www/cacti/
 
修改一下nginx配置文件
vim /usr/local/nginx/conf/vhost/demo.conf
root路径修改为root /data/www
php取消注释include enable-php71.conf
server_name修改为本机IP
CentOS7搭建Cacti监控平台

文章图片

重启一下nginx服务
nginx -t
/etc/init.d/nginx restart


八、设置一下轮询引擎,使用spine
cd /usr/local/spine/etc/
cp spine.conf.dist spine.conf
vim spine.conf
CentOS7搭建Cacti监控平台

文章图片

测试一下,确认是否成功
/usr/local/spine/bin/spine
 
九、浏览器进行访问
http://IP/cacti
默认登录方式为admin
CentOS7搭建Cacti监控平台

文章图片

 
注意:1、服务需要设置开机自启动
systemctl enable nginx
  systemctl enable mysql
  systemctl enable snmpd
systemctl enable php-fpm71
2、需要在vi /etc/my.cnf配置文件中,加入如下内容
CentOS7搭建Cacti监控平台

文章图片

 

    推荐阅读