[root@sh ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database cacti;
Query OK, 1 row affected (0.00 sec)
mysql> GRANT ALL ON cacti.* TO 'cacti'@'localhost' IDENTIFIED BY 'cactipass';
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.04 sec)
mysql> quit
Bye 4、导入Cacti数据库文件
[root@sh ~]# mysql -uroot -p cacti < /var/www/html/cacti/cacti.sql
5、修改Cacti相关的MySQL数据库配置文件
[root@sh ~]# vim /var/www/html/cacti/include/config.php/* make sure these values refect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cactipass";
$database_port = "3306";
$database_ssl = false;
6、添加防火墙规则允许外部访问80端口
[root@sh ~]# iptables -A INPUT -p udp --dport 80 -j ACCEPT
[root@sh ~]# iptables -A INPUT -p tcp --dport 80 -j ACCEPT
[root@sh ~]# service iptables save
7、配置Cacti虚拟主机文件,创建/etc/httpd/conf.d/cacti.conf,允许192.168.1.0的网段访问
[root@sh ~]# vim /etc/httpd/conf.d/cacti.conf
Alias /cacti /var/www/html/cacti
Order Deny,Allow
Deny from all
Allow from 192.168.1.0/24
8、调整系统时间,并且修改php.ini对应的时区为'Asia/Shanghai'
[root@sh ~]# ntpdate time.nist.gov
[root@sh ~]# hwclock ;写入BIOS
#添加时间自动同步计划任务
0 11 * * * /usr/sbin/ntpdate time.nist.gov;hwclock -w[root@sh ~]# vim /etc/php.ini
date.timezone = 'Asia/Shanghai' 9、配置cacti轮询php脚本,添加cron计划任务,让它每五分钟执行一次以生成图像显示
*/5 * * * * /usr/bin/php /var/www/html/cacti/poller.php[root@sh ~]# /usr/bin/php /var/www/html/cacti/poller.php
OK u:0.00 s:0.01 r:0.08
OK u:0.00 s:0.01 r:0.10
OK u:0.00 s:0.01 r:0.11
OK u:0.00 s:0.01 r:0.13
OK u:0.00 s:0.01 r:0.19
01/21/2016 03:15:01 PM - SYSTEM STATS: Time:0.3285 Method:cmd.php Processes:1 Threads:N/A Hosts:2 HostsPerProcess:2 DataSources:5 RRDsProcessed:5
10、重启服务
[root@sh ~]# service httpd restart
[root@sh ~]# service mysqld restart
[root@sh ~]# service snmpd restart
[root@sh ~]# service crond restart