CentOS 6.0
架設流量監控及集中日志系統
第一章、cacti的安裝
1、 系統的基本設置
2、 設置主機名
3、 [root@localhost ~]# vi /etc/sysconfig/network
4、 [root@localhost ~]# exit
5、 重新登陸
6、 [root@GZ-Cacti ~]#
7、 安裝screen后臺運行程序
yum -y install screen
8、 安裝優秀的編輯器vim
yum -y install vim
9、 執行screen -S cacti進程進行安裝程序防止斷開遠程導致安裝中斷
10、 cacti所需組件
http
Mysql
mysql-server
Php
Php-mysql
Php-snmp
php-cli
php-common
Perl-DBD-MySQL
Php-pdo
rrdtool
Net-snmp
Net-snmp-libs
Net-snmp-utils
rrdtool
yum安裝這些組件
yum -y install httpd php php-mysql php-snmp php-cli php-common mysql mysql-server net-snmp net-snmp-libs net-snmp-utils php-pdo perl-DBD-MySQL rrdtool
#下載cacti
[root@GZ-cacti ~]# cd /home/
[root@GZ-cacti home]# wget?http://www.cacti.net/downloads/cacti-0.8.7g.tar.gz
#解壓cacti
[root@GZ-cacti home]# tar xvf cacti-0.8.7g.tar.gz
#進入cacti文件夾,將里面的文件移動到/var/www/html/
[root@GZ-cacti home]# cd cacti-0.8.7g
[root@GZ-cacti cacti-0.8.7g]#
[root@GZ-cacti cacti-0.8.7g]# mv * /var/www/html/
#啟動apache及mysql服務
[root@GZ-cacti cacti-0.8.7g]# /etc/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 61.140.3.66 for ServerName
[ OK ]
[root@GZ-cacti cacti-0.8.7g]# /etc/init.d/mysqld restart
Stopping mysqld: [ OK ]
Starting mysqld: [ OK ]
[root@GZ-cacti cacti-0.8.7g]#
#并將apache、mysql及network加入自啟動
# chkconfig --level 35 httpd on
# chkconfig --level 35 mysqld on
#chkconfig network on
建立數據庫
mysql> create database cacti;
mysql> grant all privileges on cacti.* to?cactiuser@localhost?identified by 'cacti' with grant option;
mysql>flush privileges;
導入cacti數據庫
[root@GZ-cacti cacti-0.8.7g]# mysql -h localhost -u cactiuser -p cacti </var/www/html/cacti.sql
Enter password:
[root@GZ-cacti cacti-0.8.7g]#
修改cacti配置文件
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "cacti";
$database_port = "3306";
#$cacti_session_name = "Cacti";
暫時關閉防火墻
/etc/init.d/iptables stop
檢查SELinux現時況態
要知到你現在是否使用 SELinux:
# getenforce
enforcing
關閉selinux
修改檔案/etc/sysconfig/selinux
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=enforcing
# SELINUXTYPE= type of policy in use. Possible values are:
# targeted - Only targeted.NETwork daemons are protected.
# strict - Full SELinux protection.
SELINUXTYPE=targeted
把 SELINUX設定為disable, 下次啟動系統后將會停止SElinux。
# getenforce
disable
進入安裝界面
http://(cacti-ip)/install/index.php
確保每個路徑都正確點擊下一步完成安裝
安裝較高版本的cacti,在打開這里的時候可能會提示
ERROR: Your Cacti database login account does not have access to the MySQL TimeZone database. Please provide the Cacti database account "select" access to the "time_zone_name" table in the "mysql" database, and populate MySQL's TimeZone information before proceeding.
解決方法:
首先在bash環境下執行
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p 密碼 mysql
然后登陸mysql環境下
mysql> use mysql;
mysql> GRANT SELECT ON mysql.time_zone_name TO cactiuser@localhost;
mysql> flush privileges;**
配置snmp
vi /etc/snmp/snmp.conf
(7)配置snmp
vi /etc/snmp/snmp.conf
#將下邊這行中的default
com2secnotConfigUser default public
#改為127.0.0.1
com2secnotConfigUser 127.0.0.1 Cacti
#將下邊這行中的systemview
access notConfigGroup "" any noauth exact systemview none none
#改為all
access notConfigGroup "" any noauth exact all none none
#將下邊這行的注釋“#”號去掉
#view all included .1 80
#重啟snmpd服務
service snmpd restart
用這個命令進行測試能抓取信息為配置正確
snmpwalk -v 1 localhost -c Cacti
安裝ntpdate并且停用自動更新
yum -y install ntpdate
/etc/init.d/ntpdate stop
chkconfig ntpdate off
以cacituser用戶增加入一個計劃任務,使得 cacti 每五分鐘生成一個監控圖表。
crontab -e
#加入如下內容。注意poller.php的路徑
*/5 * * * * php /var/www/html/poller.php > /dev/null 2>&1
時間同步命令,每十分鐘跟因特網同步時鐘
*/10 * * * * ntpdate 210.72.145.44 > /dev/null 2>&1
并將rra和log文件夾賦予cactiuser以讀寫權限,poller.php文件賦予cactiuser用戶運行權限
[cactiuser@localhost html]$ chmod 777 rra
[cactiuser@localhost html]$ chmod 777 log
[cactiuser@localhost html]$ chmod 755 poller.php
至此cacti安裝完成,稍等五分鐘刷新一下就可以出圖
?
本文出自 “明日靈感” 博客,請務必保留此出處http://coolner.blog.51cto.com/957576/688164