//添加“IP”
-
vi /etc/sysconfig/network-scripts/ifcfg-eth0
------------------------------------------------------
DEVICE=eth0 #网卡对应的设备别名
BOOTPROTO=static #设置网卡获得ip地址的方式,可为static,dhcp或bootp
BROADCAST=192.168.1.255 #对应的子网广播地址
IPADDR=12.168.1.200 #网卡 ip地址的方式为静态指定
NETMASK=255.255.255.0 #网卡对应的网络掩码
NETWORK=192.168.1.0 #网卡对应的网络地址
HWADDR=00:07:E9:05:E8:B4 #对应的网卡物理地址
IPV6INIT=no
IPV6_AUTOCONF=no
ONBOOT=yes #系统启动时是否启动此接口
------------------------------------------------------
//添加“网关”
-
vi /etc/sysconfig/network
------------------------------------------------------
NETWORKING=yes #表示系统是否使用网络
HOSTNAME=centos #设置本机的主机名
GATEWAY=192.168.1.1 #设置本机网关地址
------------------------------------------------------
//添加“DNS”
-
vi /etc/resolv.conf
------------------------------------------------------
nameserver 8.8.8.8 #google域名服务器
nameserver 8.8.4.4 #google域名服务器
------------------------------------------------------
-
service network restart #重启网络服务
//安装telnet
-
yum -y install telnet-server
-
vi /etc/xinetd.d/telnet
------------------------------------------------------
#将disable项由yes改成no。
------------------------------------------------------
-
/etc/init.d/xinetd restart
//设置允许root以telnet进入Linux主机
-
vi /etc/pam.d/remote #将“auth required pam_securetty.so”注释掉即可
//设置防火墙
-
/sbin/iptables -I INPUT -p tcp –dport 23 -j ACCEPT #开放23端口
-
/sbin/iptables -I INPUT -p tcp –dport 80 -j ACCEPT #开放80端口
-
/sbin/iptables -I INPUT -p icmp -j ACCEPT #开放ICMP端口
-
/etc/rc.d/init.d/iptables save #保存防火墙配置
//关闭SELinux
-
vi /etc/selinux/config #SELINUX="" 为 disabled
安装Cacti
1、首先要安装Apache+PHP+MySQL+Net-SNMP+RRDTool(MySQL安装、Apache安装、PHP安装),本文采用YUM命令安装所有cacti依赖软件。过程如下:
-
yum install -y mysql mysql-server mysql-devel php-mysql httpd php php-pdo lm_sensors net-snmp net-snmp-devel openssl-devel php-snmp net-snmp-utils perl-Net-Daemon perl-PlRPC perl-DBI rrdtool perl-rrdtool perl-DBD-MySQL net-snmp-libs libtool ntpdate wget vixie-cron man lrzsz make
//配置SNMP
-
vi /etc/snmp/snmpd.conf
-----------------------------------------------------------------------
com2sec notConfigUser default public #将这行中的“default“改为127.0.0.1
com2sec notConfigUser 127.0.0.1 public
.....
access notConfigGroup "" any noauth exact systemview none none #将这行中的"systemview "改为all
access notConfigGroup "" any noauth exact all none none
.....
#view all included .1 80 将这行的注释"#"号去掉
view all included .1 80
-----------------------------------------------------------------------
//自动同步时间
-
ntpdate us.pool.ntp.org
//修改PHP时区
-
vi /etc/php.ini
-----------------------------------------------------------------------
#date.timezone = #去掉前面的注释并 改为 date.timezone = Asia/Shanghai
date.timezone = Asia/Shanghai
-----------------------------------------------------------------------
//启动snmpd/httpd/mysql服务
-
service snmpd start
-
chkconfig snmpd on
-
service httpd start
-
chkconfig httpd on
-
service mysqld start
-
chkconfig mysqld on
//安装cacti
-
wget http://www.cacti.net/downloads/cacti-0.8.8a.tar.gz
-
tar zvxf cacti-0.8.8a.tar.gz
-
mv cacti-0.8.8a /var/www/html/cacti
//安装Spine插件
-
wget http://www.cacti.net/downloads/spine/cacti-spine-0.8.8a.tar.gz
-
tar -zxvf cacti-spine-0.8.8a.tar.gz
-
cd cacti-spine-0.8.8a
-
./configure --prefix=/var/www/html/cacti/app/spined
-
make
-
make install
//配置Spinecd
-
/var/www/html/cacti/app/spine/etc/
-
mv spine.conf.dist spine.conf
-
vi spine.conf
-----------------------------------------------------------------------
DB_Host localhost
DB_Database cacti
DB_User cacti
DB_Pass cacti
DB_Port 3306
DB_PreG 0
-----------------------------------------------------------------------
//在数据库中建库、授权、导入数据库结构
-
mysql
-
create database cacti;
-
grant all privileges on cacti.* to cacti@localhost identified by 'cacti' with grant option;
- grant all privileges on cacti.* to cacti@127.0.0.1 identified by 'cacti' with grant option;
- use cacti;
-
source /var/www/html/cacti/cacti.sql;
-
exit
//配置cacti以连接数据库
-
vi /var/www/html/cacti/include/config.php
-----------------------------------------------------------------------
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cacti";
$database_port = "3306";
-----------------------------------------------------------------------
//添加cacti用户,否则cacti不能写入rrd和log目录,将会无法生成图片
#添加cacti用户
-
useradd cacti
-
passwd cacti
#修改cacti目录所属组
-
chgrp –R cacti /var/www/html/cacti
#将log目录的所有权给cacti用户
-
chown –R cacti /var/www/html/cacti/log
#将rra目录的所有权给cacti用户
-
chown –R cacti /var/www/html/cacti/rra
//增加入一个计划任务,使得 cacti 每两分钟生成一个监控图表。注意poller.php路径
//安装crontab
# su cacti
# crontab –e
*/5 * * * * php /var/www/html/cacti/poller.php > /dev/null 2>&1
//完成cacti最后的配置,在浏览器输入:http://localhost/cacti
-
wget http://mirror.cactiusers.org/downloads/plugins/settings-0.5.tar.gz
-
tar -xzvf settings-0.5.tar.gz
-
mv settings /var/www/html/cacti/plugins/
-
wget http://mirror.cactiusers.org/downloads/plugins/thold-0.4.3.tar.gz
-
tar -xzvf thold-0.4.3.tar.gz
-
mv thold /var/www/html/cacti/plugins/
-
vi web/c/cacti/include/global.php
#---
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cacti";
$database_port = "3306";
/* Default session name - Session name must contain alpha characters */
$cacti_session_name = "Cacti";
$plugins = array();
$plugins[] = 'settings';
$plugins[] = 'thold';
#---
-
mysql -ucacti -pcactipw cacti < /web/c/cacti/plugins/thold/thold.sql