Cnetos 7 搭建cacti
安装依赖包
[root@localhost cacti]# yum install -y wget gcc gcc-c++ net-snmp net-snmp-utils net-snmp-devel php php-mysql mariadb-server mariadb-devel rrdtool
关闭selinux
[root@localhost cacti]# vi /etc/selinux/config
修改前:SELINUX=enforcing
修改后:SELINUX=disabled
[root@localhost cacti]# setenforce 0
配置mariadb数据库
[root@localhost cacti]# service mariadb start
[root@localhost cacti]# mysql
MariaDB [(none)]> set password=password(‘123456’);
MariaDB [(none)]> create database cacti;
MariaDB [(none)]> GRANT ALL ON cacti.* TO zhangsan@localhost IDENTIFIED BY ‘123456’;
MariaDB [(none)]> flush privileges;
安装cacti
[root@localhost ~]# cd /var/www/html
[root@localhost html]# wget https://www.cacti.net/downloads/cacti-0.8.8f.tar.gz –no-check-certificate
[root@localhost html]# wget https://www.cacti.net/downloads/spine/cacti-spine-0.8.8f.tar.gz –no-check-certificate
[root@localhost html]# tar xvf cacti-0.8.8f.tar.gz && mv cacti-0.8.8f cacti
[root@localhost html]# cd cacti
[root@localhost cacti]# mysql -uzhangsan -p cacti < cacti.sql
[root@localhost cacti]# chown apache:apache /var/www/html/cacti -R
[root@localhost cacti]# chmod 744 /var/www/html/cacti -R
[root@localhost cacti]# chmod 777 rra log
[root@localhost cacti]# echo “*/5 * * * * apache php /var/www/html/cacti/poller.php > /dev/null 2>&1” >> /etc/crontab
[root@localhost cacti]# vi include/config.php
修改前
$database_type = “mysql”;
$database_default = “cacti”;
$database_hostname = “localhost”;
$database_username = “cactiuser”;
$database_password = “cactiuser”;
$database_port = “3306”;
$database_ssl = false;
修改后
$database_type = “mysql”;
$database_default = “cacti”;
$database_hostname = “localhost”;
$database_username = “zhangsan”;
$database_password = “123456”;
$database_port = “3306”;
$database_ssl = false;
[root@localhost cacti]# service httpd start
[root@localhost cacti]# service firewalld stop
[root@localhost cacti]# service iptables stop
安装spine
[root@localhost cacti]# cd /var/www/html
[root@localhost html]# tar xvf cacti-spine-0.8.8f.tar.gz
[root@localhost html]# cd cacti-spine-0.8.8f
[root@localhost cacti-spine-0.8.8f]# ./configure && make && make install
[root@localhost cacti-spine-0.8.8f]# cp /usr/local/spine/etc/spine.conf.dist /etc/spine.conf
[root@localhost cacti-spine-0.8.8f]# vi /etc/spine.conf
修改前
DB_Host localhost
DB_Database cacti
DB_User cactiuser
DB_Pass cactiuser
DB_Port 3306
修改后
DB_Host localhost
DB_Database cacti
DB_User zhangsan
DB_Pass 123456
DB_Port 3306
设置使用spine采集:
[console]->[Settings]->[Paths]->[Spine Poller File Path]填写[/usr/local/spine/bin/spine] 点击save
[console]->[Settings]->[Poller]->[Poller Type]选择[spine] 点击save
这样就设置好了