当时记录Cacti的安装记录。

安装环境

OS : CentOS 7 Server Everything – Minimal Version
Required Packages : LAMP, RRDTool

部署基础组件

  1. 安装Apache
    命令如下:
1
2
yum install -y httpd httpd-devel  
dnf install -y httpd httpd-devel
  1. 安装MySQL
    命令如下:
1
2
yum install -y mysql mysql-server   
dnf install -y mysql mysql-server

OR

1
2
yum install -y Mariadb-server  
dnf install -y Mariadb-server
  1. 安装PHP
    命令如下:
1
2
yum install -y php-mysql php-pear php-common php-gd php-devel php php-mbstring php-cli  
dnf install -y php-mysql php-pear php-common php-gd php-devel php php-mbstring php-cli
  1. 安装PHP-SNMP
    命令如下:
1
2
yum install -y php-snmp  
dnf install -y php-snmp
  1. 安装NET-SNMP
    命令如下:
1
2
yum install -y net-snmp-utils net-snmp-libs net-snmp   
dnf install -y net-snmp-utils net-snmp-libs net-snmp

如果需要安装Spine,需要安装net-snmp-devel

1
2
yum install -y net-snmp-devel
dnf install -y net-snmp-devel
  1. 安装RRDTool
    命令如下:
1
2
yum install -y rrdtool  
dnf install -y rrdtool
  1. 开始所有的服务:
    命令如下:
1
2
3
service httpd start  
service mysqld start OR service mariadb start
service snmpd start

OR

1
2
3
systemctl start httpd.service
systemctl start mariadb.service
systemctl start snmpd.service
  1. 调整服务开机启动:
1
2
3
chkconfig httpd on  
chkconfig mysqld on
chkconfig snmpd on

OR

1
2
3
systemctl enable httpd.service
systemctl enable mariadb.service
systemctl enable snmpd.service
  1. 开启EPEL REPO & 安装Cacti
1
2
3
wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm  
rpm -ivh epel-release-latest-7.noarch.rpm
yum makecache

所有的安装内容已经部署完毕。

进行配置

  1. 配置MySQL的root密码
1
mysqladmin -u root password YOURSELF_PASSWORD
  1. 创建Cacti的数据库
1
2
3
4
5
mysql -u root -p
mysql> create database cacti;
mysql> GRANT ALL ON cacti.* TO cacti@localhost IDENTITFIED BY 'YOURSELF_PASSWORD';
mysql> FLUSH PRIVILEGES;
mysql> quit;
  1. MySQL-数据库初始化
1
2
rpm -ql cacti | grep cacti.sql
mysql -u cacti -p cacti < /usr/share/doc/cacti/cacti.sql

命令发起后需要进行密码的输入

  1. Cacti-读取数据库配置
1
vim /etc/cacti/db.php

需要编辑的内容如下:

1
2
3
4
5
6
7
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "YOURSELF_PASSWORD";
$database_port = "3306";
$database_ssl = false;
  1. Firewall-配置放行防火墙
1
2
3
iptables -A INPUT -p udp -m state --state NEW --dport 80 -j ACCEPT
iptables -A INPUT -p tcp -m state --state NEW --dport 80 -j ACCEPT
iptables save

OR

1
2
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --reload
  1. Apache- 配置Cacti根目录
1
vim /etc/httpd/conf.d/cacti.conf

配置文件内的内容修改如下:

1
2
3
4
5
<Directory /usr/share/cacti/>
Order Deny,Allow
Deny from all
Allow from all
</Directory>

重启服务:

1
service httpd restart

OR

1
systemctl restart httpd.service
  1. Crond-配置Poller的计划任务
1
2
vim /etc/cron.d/cacti
*/5 * * * * cacti /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1 \\ 去掉注释
  1. 启动Broswer,进入Cacti安装界面,http://IPADDRESS/Cacti, 之后按照说明继续即可。

Default Username : admin
Default Password : admin

补充安装SPINE过程

  1. 下载源文件,安装程序。
  2. 安装CentOS,Development Tool,yum group install。
  3. 在Spine的目录下,执行./configure && make && make install。
    NOTE: 这里出现了的问题,提示找不到net-snmp header file—>没有安装net-snmp-devel
  4. 进入控制台进行Spine是否安装成功。