CentOS7搭建Cacti监控平台

Posted 远方在呼唤

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS7搭建Cacti监控平台相关的知识,希望对你有一定的参考价值。

​搭建环境:一台CentOS7服务器,Cacti版本为1.2.2

一、首先关闭selinux,关闭防火墙,或者防火墙放行对应规则

vim /etc/selinux/config     #将SELINUX修改为disabled

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


三、安装nginxphpmysql以及相关依赖包

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等函数删除

重启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

修改为如图

导入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

修改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

重启一下nginx服务

nginx -t

/etc/init.d/nginx restart


八、设置一下轮询引擎,使用spine

cd /usr/local/spine/etc/

cp spine.conf.dist spine.conf

vim spine.conf

测试一下,确认是否成功

/usr/local/spine/bin/spine

 

九、浏览器进行访问

http://IP/cacti

默认登录方式为admin

 

注意:1、服务需要设置开机自启动

systemctl enable nginx

 systemctl enable mysql

 systemctl enable snmpd

systemctl enable php-fpm71

2、需要在vi /etc/my.cnf配置文件中,加入如下内容

 

以上是关于CentOS7搭建Cacti监控平台的主要内容,如果未能解决你的问题,请参考以下文章

Linux监控平台——搭建zabbix监控平台

Cacti 监控平台搭建(基于Centos6.7)

centos7.4安装监控软件系列3: Zabbix

inux监控平台搭建-监控项

监控平台搭建-监控项

监控平台搭建-监控项