CentOS7 下安装 Cacti0.8.8h 笔记

1、安装httpd、mysql、PHP、PHP-SNMP、rrdtool

[root~]# yum install httpd httpd-devel #安装httpd

[root~]# yum install mariadb-server #安装mariadb数据库(Mysql开源)

[root~]# yum install php-mysql php-pear php-common php-gd php-devel php php-mbstring php-cli #安装PHP及相关支持插件

[root~]# yum install php-snmp #安装PHP-SNMP

[root~]# yum install net-snmp-utils net-snmp-libs #安装net-snmp

[root~]# yum install rrdtool 安装rrdtool


2、配置httpd、mysql、snmpd、开机启动

[root~]# systemctl start httpd.service #启动httpd

[root~]# systemctl start mariadb.service #启动mysql

[root~]# systemctl start snmpd.service #启动snmp

[root~]# systemctl enable httpd.service #设置httpd开机启动

[root~]# systemctl enable mariadb.service #设置mysql开机启动

[root~]# systemctl enable snmpd.service #设置snmp开机启动


3、安装Cacti

[root~]# wget http://www.cacti.net/downloads/cacti-0.8.8h.tar.gz #下载cacti

[root~]# tar -xvzf cacti-0.8.8h.tar.gz #解压cacti

[root~]# cp -r cacti-0.8.8c /usr/local/ #拷贝至 /usr/local目录

[root~]# cd /usr/local

[root~]# mv cacti-0.8.8c/ cacti #改目录名

[root~]# cd cacti/

[root~]# vi include/config.php #更改cacti配置文件

        $database_username = "cacti";       #配置数据库用户名

$database_password = "test";          #配置数据库密码
date_default_timezone_set('Asia/shanghai'); #添加cacti时间

[root~]# useradd cacti -d /usr/local/cacti/ #添加用户并对/cacti目录控制(会提示出错,忽略)

[root~]# chown -R cacti /usr/local/cacti/ #改变拥有者为cacti

[root~]# chgrp -R cacti /usr/local/cacti #改变目录属性为cacti

[root~]# chmod -R 755 /usr/local/cacti/ #设置cacti目录权限


4、配置Mysql

[root~]# mysqladmin -u root password 密码 #设置mysql密码

[root~]# mysql -u root –p #登录mysql

MariaDB >create database cacti; #建cacti库

MariaDB >GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY 'test';  #建cacti用户对cacti库的完全访问,test为密码

MariaDB >FLUSH privileges; #刷新mysql

MariaDB >quit;     #退出

[root~]# mysql -u cacti -p cacti < /usr/local/cacti/cacti.sql #导入库(输入test密码后,成功不会有任何提示直接返回命令行)


5、开启http端口

[root~]# firewall-cmd --permanent --zone=public --add-service=http #防火墙开启HTTP

[root~]# firewall-cmd --reload #刷新防火墙策略


6、配置cacti

[root~]# vi /etc/httpd/conf.d/cacti.conf #新建cacti的http配置文件

  Alias /cacti    /usr/local/cacti



             # httpd 2.4
Require all granted


            # httpd 2.2
            Order deny,allow
           Deny from all
           Allow from all


[root~]# systemctl restart httpd.service     #重启httpd

[root~]# vi /etc/cron.d/cacti #新建配置cron.d

        */5 * * * *    cacti   /usr/bin/php /usr/local/cacti/poller.php > /dev/null 2>&1

# */5 * * * *    cacti   /usr/bin/php /usr/local/cacti/poller.php > /dev/null 2>&1

[root~]# systemctl restart httpd.service  #重启httpd


DONE!

你可能感兴趣的:(Cacti,CentOS)