环境:windows7 VMware Esxi4+CentOS6.1
第一步:安装配置Cacti环境
#yum install mysql mysql-server httd php php-mysql -y
mysql-server //安装mysql服务
httd //安装apache
php //安装PHP
php-mysql //安装PHP与mysql的……
====================================================
Installed:
httpd.i686 0:2.2.15-15.el6.centos mysql.i686 0:5.1.52-1.el6_0.1
mysql-server.i686 0:5.1.52-1.el6_0.1 php.i686 0:5.3.3-3.el6_2.5
php-mysql.i686 0:5.3.3-3.el6_2.5
Dependency Installed:
apr.i686 0:1.3.9-3.el6_1.2 apr-util.i686
0:1.3.9-3.el6_0.1 apr-util-ldap.i686 0:1.3.9-3.el6_0.1
httpd-tools.i686 0:2.2.15-15.el6.centos libedit.i686
0:2.11-4.20080712cvs.1.el6 mailcap.noarch 0:2.1.31-2.el6
perl.i686 4:5.10.1-119.el6_1.1 perl-DBD-MySQL.i686
0:4.013-3.el6 perl-DBI.i686 0:1.609-4.el6
perl-Module-Pluggable.i686 1:3.90-119.el6_1.1 perl-Pod-Escapes.i686
1:1.04-119.el6_1.1 perl-Pod-Simple.i686 1:3.13-119.el6_1.1
perl-libs.i686 4:5.10.1-119.el6_1.1 perl-version.i686
3:0.77-119.el6_1.1 php-cli.i686 0:5.3.3-3.el6_2.5
php-common.i686 0:5.3.3-3.el6_2.5 php-pdo.i686
0:5.3.3-3.el6_2.5
Dependency Updated:
mysql-libs.i686 0:5.1.52-1.el6_0.1
====================================================
第二步:安装Cacti所需的各种库
#yum install zlib libpng freetype jpeg fontconfig gd libxml -y //zlib一般默认
己安装
====================================================I
nstalled:
freetype.i686 0:2.3.11-6.el6_1.8
gd.i686 0:2.0.35-10.el6 libpng-1.2.46-1.el6_1.i686
Dependency Installed:
fontconfig.i686 0:2.8.0-3.el6 libX11.i686 0:1.3-2.el6 libX11-common.noarch
0:1.3-2.el6 libXau.i686 0:1.0.5-1.el6 libXpm.i686 0:3.5.8-2.el6
libjpeg.i686 0:6b-46.el6 libxcb.i686 0:1.5-1.el6
====================================================
第三步:安装绘图所要用到的rrdtool
#yum install rrdtool -y
现在6.2版本源增加了不少,安装很多软件真是方便呀,以前在5.0的时候用yum无法安装rrdtool只
能用wget
====================================================
Installed:
rrdtool.i686 0:1.3.8-6.el6
Dependency Installed:
cairo.i686 0:1.8.8-3.1.el6 dejavu-fonts-common.noarch
0:2.30-2.el6 dejavu-lgc-sans-mono-fonts.noarch 0:2.30-2.el6
dejavu-sans-mono-fonts.noarch 0:2.30-2.el6
fontpackages-filesystem.noarch 0:1.41-1.1.el6 libXft.i686 0:2.1.13-4.1.el6
libXrender.i686 0:0.9.5-1.el6 libthai.i686 0:0.1.12-3.el6
pango.i686 0:1.28.1-3.el6_0.5.1.centos
pixman.i686 0:0.18.4-1.el6_0.1
====================================================
===========================================
第四步:安装snmp支持
#yum install net-snmp net-snmp-utils -y
====================================================
Installed:
net-snmp.i686 1:5.5-37.el6_2.1
net-snmp-utils.i686 1:5.5-37.el6_2.1
Dependency Installed:
lm_sensors-libs.i686 0:3.1.1-10.el6
net-snmp-libs.i686 1:5.5-37.el6_2.1
====================================================
第五步:安装Cacti
这一点不爽,为什么还不支持yum来安装cacti,debian和ubuntu都支持apt-get来直接安装
====================================================
#wget -c
--2012-01-31 19:59:36--
Resolving 209.242.232.5, 140.211.167.231, 173.225.179.10
Connecting to |209.242.232.5|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2236916 (2.1M) [application/x-gzip]
Saving to: “cacti-0.8.7g.tar.gz”
100%[==========================>] 2,236,916 111K/s in 22s
2012-01-31 20:00:03 (99.0 KB/s) - “cacti-0.8.7g.tar.gz” saved [2236916/2236916]
====================================================
tar -xvzf cacti-0.8.7g.tar.gz
mv cacti-0.8.7g cacti //这步可以不做,我只是为了给这个长
文件名改短一点,没有任何意思
cp -a cacti/. /var/www/html/ //同样这步做不做都行,我是为了省事把cacti
目录下的全部文件及子目录拷贝到httpd默认的目录下,懒的改httpd
第六步:为cacti建立用户和库
# service mysqld start
首先为mysql的root设置密码,在安装好mysql后一般默认是没有密码的,这样不安全
#/usr/bin/mysqladmin -u root password 123456
然后登录到mysql
#mysql -uroot -p 123456
mysql>show databases; //查看数据库
mysql>create database cacti; //建立cacti数据库
Query OK, 1 row affected (0.00 sec)
mysql>show databases; //再次查看
第七步:建立用户并授权用户Cacti数据库的全部权限及网络访问权限
GRANT ALL PRIVILEGES ON cacti.* TO cactiuser@localhost IDENTIFIED BY
"11223344";
Query OK, 0 rows affected (0.00 sec)
授权用户网络访问的权限:
GRANT ALL PRIVILEGES ON cacti.* TO cactiuser@"%" IDENTIFIED BY "123456";
Query OK, 0 rows affected (0.00 sec)
GRANT ALL PRIVILEGES ON cacti.* TO cactiuser@[ip address或者“%”] IDENTIFIED
BY "11223344";
ip address是指定ip,如果想在任何地点使用的话可以用通配符"%"注意输入时不要忘记
冒号
# /usr/bin/mysqladmin --user=root create cacti
# mysql -e "GRANT ALL ON cacti.* TO cactidate IDENTIFIED BY 'admin'"
第七步:导入cacti库
mysql -ucactiuser -p11223344 cacti < /var/www/html/cacti.sql
第八步:编辑config.php
vim /var/www/html/include/config.php
====================================================
原内容:
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "cactiuser";
$database_port = "3306";
改为:
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "11223344";
$database_port = "3306";
====================================================
第九步:启动httpd
#/etc/init.d/httpd start
第十步:验证php
建立一个php测试页
vim php.php
phpinfo();
?>
第十一步:配置iptables
如查在安装CentOS时没有特别定制的话,默认是只有TCP22端口是开放的,所以要配置一
下
vim /etc/sysconfig/iptables
====================================================
原有内容:
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
增加几条
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
//http所要用到的端口
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
//mysql所要用到的端口
-A INPUT -p udp -m udp --dport 161 -j ACCEPT
//snmp所要用到的端口
====================================================
配置完成后重启iptables让配置生效
/etc/init.d/iptables restart
第十二步:Cacti的web页面安装
打开浏览器输入: address/
阅读(2275) | 评论(0) | 转发(1) |