天天看點

cacti安裝教程

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

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 ]

#并将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:

修改cacti配置檔案

/* make sure these values refect your actual database/host/user/password */

$database_type = "mysql";

$database_default = "cacti";

$database_hostname = "localhost";

$database_username = "cactiuser";

$database_password = "cacti";

$database_port = "3306";

/* Default session name - Session name must contain alpha characters */

#$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。

disable

進入安裝界面

http://(cacti-ip)/install/index.php

確定每個路徑都正确點選下一步完成安裝

配置snmp

vi /etc/snmp/snmp.conf

(7)配置snmp

#将下邊這行中的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安裝完成,稍等五分鐘重新整理一下就可以出圖

11、報錯處理

1)/usr/bin/ld: cannot find -lmysqlclient 解決方法

原因是GCC 的預設搜尋沒有包含 /usr/lib/mysql

 解決方法:

    執行   export LIBRARY_PATH=/usr/lib/mysql

2)# make

false // No help2man // --output=spine.1 --name='Data Collector for Cacti' --no-info --version-option='--version' ./spine

make: *** [spine.1] Error 1報錯

解決辦法

需安裝help2man解決

#yum -y install help2man

3)ERROR: Your

Cacti database login account does not haveaccess to the MySQL TimeZone

database. Please provide the Cacti databaseaccount "select" access to

the "time_zone_name" table inthe "mysql" database, and populate MySQL's

TimeZone informationbefore proceeding

錯誤解決辦法

# grant all privileges on *.* to cacti@localhost identified by 'cacti';

# flush privileges;

4)ERROR: Your MySQL TimeZone database is not populated.Please populate this database  before proceeding.

 解決辦法# mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql

12、參考資料

Cacti官網:http://www.cacti.net/index.php

Cacti官網論壇:http://forums.cacti.net/

Cacti文檔:http://docs.cacti.net/

Cacti插件:http://cactiusers.org/index.php

Network Weathermap:http://www.network-weathermap.com/

RRDTool官網:http://oss.oetiker.ch/rrdtool/

NET-SNMP官方網站:http://www.net-snmp.org/

Apache官網:http://httpd.apache.org/

MySQL官網:http://www.mysql.com/

PHP官網:http://www.php.net/