打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Centos5.2下Cacti安装配置

系统环境:centos5.2



参考:
www.linuxtone.org流量监控板块
linuxtone基于CentOS构建高性能的LAMP平台
JoeCen's 小猫窝http://www.joecen.com/article/cacti/

注:
前面的基本的lamp环境安装参照linuxtone的站长netseek的精华文章
基于构建高性能的lamp平台其中php编译有些改动



、编译安装基本环境
使用 yum 程序安装所需开发包(以下为标准的 RPM 包名称)
#rpm --import http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
#yum -y install ntp vim-enhanced gcc gcc-c++ gcc-g77 flex bison utoconf automake bzip2-devel ncurses-devel zlib-devel ibjpeg-devel libpng-devel libtiff-devel freetype-devel libXpm-devel  gettext-devel  pam-devel kernel

二、 编译安装软件包
源码编译安装所需包(Source)
1) GD2
# cd /usr/local/src
# tar xvf gd-2.0.35.tar.gz
# cd gd-2.0.35
# ./configure --prefix=/usr/local/gd2
# make
# make install
2) LibXML2
# cd /usr/local/src
# tar xvf libxml2-2.6.29.tar.bz2
# cd libxml2-2.6.29
# ./configure --prefix=/usr/local/libxml2
# make
# make install
3) LibMcrypt
# cd /usr/local/src
# tar xvf libmcrypt-2.5.8.tar.bz2
# cd libmcrypt-2.5.8
# ./configure --prefix=/usr/local/libmcrypt
# make
# make install


4). OpenSSL和OpenSSH
# cd /usr/local/src
# tar xvf openssl-0.9.8g.tar.gz
# cd openssl-0.9.8g
# ./config --prefix=/usr/local/openssl
# make
# make test
# make install
# cd ..
# tar xvf openssh-5.0p1.tar.gz  
# cd  openssh-5.0p1

CODE:

# ./configure  \
"--prefix=/usr" \
"--with-pam" \
"--with-zlib" \
"--sysconfdir=/etc/ssh" \
"--with-ssl-dir=/usr/local/openssl" \
"--with-md5-passwords"
# make
# make install
配置:

1) 禁用 SSH V1 协议

# vi /etc/ssh/sshd_config
  找到#Protocol 2,1改为:Protocol 2
2) 禁用服务器端GSSAPI
  找到以下两行,并将它们注释:
  GSSAPIAuthentication yes
  GSSAPICleanupCredentials yes
3) 禁用 DNS 名称解析
找到:#UseDNS yeas改为:UseDNS no
4)禁用客户端 GSSAPI
  # vi /etc/ssh/ssh_config 找到:

GSSAPIAuthentication yes

将这行注释掉。
  最后,确认修改正确后重新启动 SSH 服务
  # service sshd restart
  # ssh -v
  确认 OpenSSH 以及 OpenSSL 版本正确。
三、编译安装A.M.P环境
1.下载软件编译安装
1)下载软件
# cd /usr/local/src
httpd-2.2.8.tar.gz  
mysql-5.0.51b.tar.gz   
php-5.2.6.tar.bz2
2) 安装MySQL
查看分析你的CPU型号:
http://gentoo-wiki.com/Safe_Cflags 查找您的GCC编译参数.
确定系统CPU类型:
# cat /proc/cpuinfo | grep "model name"
执行后会看到系统中CPU的具体型号,记下CPU型号。
# tar xvf mysql-5.0.51b.tar.gz   
# cd mysql-5.0.51b
# vi mysql.sh

CODE:

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=prescott -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"
./configure \
        "--prefix=/usr/local/mysql" \
        "--localstatedir=/data/mysql/data" \
        "--with-comment=Source" \
        "--with-server-suffix=-LinuxTone" \
        "--with-mysqld-user=mysql" \
        "--without-debug" \
        "--with-big-tables" \
        "--with-charset=gbk" \
        "--with-collation=gbk_chinese_ci" \
        "--with-extra-charsets=all" \
        "--with-pthread" \
        "--enable-static" \
        "--enable-thread-safe-client" \
        "--with-client-ldflags=-all-static" \
        "--with-mysqld-ldflags=-all-static" \
        "--enable-assembler" \
        "--without-isam" \
        "--without-innodb" \
        "--without-ndb-debug"
make && make install
mkdir -p /data/mysql/data
useradd mysql -d /data/mysql -s /sbin/nologin
/usr/local/mysql/bin/mysql_install_db --user=mysql
cd /usr/local/mysql
chown -R root:mysql .
chown -R mysql /data/mysql/data
cp share/mysql/my-huge.cnf /etc/my.cnf
cp share/mysql/mysql.server /etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
/etc/rc.d/init.d/mysqld start

cd /usr/local/mysql/bin
for i in *; do ln -s /usr/local/mysql/bin/$i /usr/bin/$i; done
#sh mysql.sh 即可开始编译.
3) 编译安装Apache
# cd /usr/local/src
# tar xvf httpd-2.2.8.tar.gz  
# cd httpd-2.2.8

CODE:

./configure \
        "--prefix=/usr/local/apache2" \
        "--with-included-apr" \
        "--enable-so" \
        "--enable-deflate=shared" \
        "--enable-expires=shared" \
        "--enable-rewrite=shared" \
        "--enable-static-support" \
        "--disable-userdir"
make
make install
echo '/usr/local/apache2/bin/apachectl start ' >> /etc/rc.local
4).编译安装PHP
# cd /usr/local/src
# tar xjvf php-5.2.6.tar.bz2
# cd php-5.2.6

CODE:

./configure \
        "--prefix=/usr/local/php" \
        "--with-apxs2=/usr/local/apache2/bin/apxs" \
        "--with-config-file-path=/usr/local/php/etc" \
        "--with-mysql=/usr/local/mysql" \
        "--with-libxml-dir=/usr/local/libxml2/bin" \
        "--with-gd=/usr/local/gd2" \
        "--with-jpeg-dir" \
        "--with-png-dir" \
        "--with-bz2" \
        "--with-xmlrpc" \
        "--with-freetype-dir" \
        "--with-zlib-dir " \
        "--with-openssl=/usr/local/openssl" \
        "--with-mcrypt=/usr/local/libmcrypt" \
        "--enable-sysvsem" \
        "--enable-inline-optimization" \
        "--enable-soap" \
        "--enable-gd-native-ttf" \
        "--enable-ftp" \
        "--enable-mbstring" \
        "--enable-exif" \
        "--disable-debug" \
        "--disable-ipv6" \
        "--enable-sockets" \
        "--disable-cgi" \
        "--with-snmp"
make
make install
cp php.ini-dist /usr/local/php/etc/php.ini
2整合Apache与PHP及系统初化配置.
1)整合Apache与PHP
# vi /usr/local/apache2/conf/httpd.conf
找到:
AddType application/x-gzip .gz .tgz
在该行下面添加
AddType application/x-httpd-php .php

找到:
<IfModule dir_module>

DirectoryIndex index.html
</IfModule>
将该行改为
<IfModule dir_module>

DirectoryIndex index.html index.htm index.php
</IfModule>

找到:
#Include conf/extra/httpd-mpm.conf
#Include conf/extra/httpd-info.conf
#Include conf/extra/httpd-vhosts.conf  (虚拟主机配置文件存放目录.)
#Include conf/extra/httpd-default.conf
去掉前面的“#”号,取消注释。
注意:以上 4 个扩展配置文件中的设置请按照相关原则进行合理配置!

修改完成后保存退出。
# /usr/local/apache2/bin/apachectl restart
2)查看确认L.A.M.P环境信息
在网站根目录放置 info.php 脚本,检查phpinfo中的各项信息是否正确。
<?php
phpinfo();
?>


3)配置虚拟主机:
#vi /usr/local/apache2/conf/extra/httpd-vhosts.conf

CODE:

NameVirtualHost *:80
<VirtualHost *:80>
    ServerAdmin hamgua@gmail.com
    DocumentRoot "/data/www/wwwroot"
    ServerName cacti.test.comServer
    Alias cacti.test.cn
#    ErrorLog "logs/dummy-host.example.com-error_log"
#   CustomLog "|/usr/sbin/cronolog /data/logaccess_www.linuxtone.org.%Y%m%d" combined
</VirtualHost>

四、安装采集工具
SNMP全名是简单网络管理协议,几乎所有的网络设备(交换机、路由器等)和操作系统默认安装了认都安装了snmp服务。
Cacti系统所在的服务器并不一定要安装SNMP服务,但是Cacti系统采集数据要用到Net-SNMP包里面的几个工具,所以最好也在Cacti服务器上安装SNMP服务。我们可以直接在系统中运行snmpwalk和snmpget看是否有该命令,如果有则无需安装了。
如果操作系统没有安装SNMP,可以到本文最后的资源里的Net-SNMP官方网站上下载源码或二进制包进行安装。
#yum -y install net-snmp*
#rpm -qa|grep snmp

CODE:

net-snmp-libs-5.3.1-24.el5_2.2
net-snmp-perl-5.3.1-24.el5_2.2
net-snmp-utils-5.3.1-24.el5_2.2
net-snmp-5.3.1-24.el5_2.2
net-snmp-devel-5.3.1-24.el5_2.2

五、安装rrdtool
我这里使用的是rpm包安装
#wget
ftp://rpmfind.net/linux/fedora/updates/9/i386.newkey/rrdtool-1.3.4-2.fc9.i386.rpm
#rpm -ivh rrdtool-1.3.4-2.fc9.i386.rpm

CODE:

warning: rrdtool-1.3.4-2.fc9.i386.rpm:
Header V3 DSA signature: NOKEY, key ID 6df2196f
error: Failed dependencies:
                dejavu-lgc-fonts is needed by rrdtool-.3.4-2.fc9.i386
#yum -y install dejavu-lgc-fonts
#rpm -ivh rrdtool-1.3.4-2.fc9.i386.rpm

CODE:

warning: rrdtool-1.3.4-2.fc9.i386.rpm: Header V3 DSA signature: NOKEY, key ID 6df2196f
Preparing...            ###########################################[100%]   
1:rrdtool               ########################################### [100%]
六、安装配置cacti
下载cacti的源码包
#wget http://www.cacti.net/downloads/cacti-0.8.7b.tar.gz
#tar zvxf cacti-0.8.7b.tar.gz
#mv cacti-0.8.7b /data/www/wwwroot/cacti
#cd /data/www/wwwroot/cacti

配置账号及mysql:

CODE:

groupadd cactiuser
useradd -g cacti cactiuser
mysql -uroot -p
mysql> create database cactidb;
mysql> grant all on cactidb.* to root;
mysql> grant all on cactidb.* to root@localhost;
mysql> grant all on cactidb.* to cactiuser;
mysql> grant all on cactidb.* to cactiuser@localhost identified by '123456';
mysql> flush privileges;
mysql> exit

Catci配置:
# mysql cactidb -uroot -p < cacti.sql
# chown -R cactiuser rra/ log/
# chmod -R 777 rra/ log/
# vi include/config.php

CODE:

$database_type = "mysql";
$database_default = "cactidb";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "123456";
$database_port = "3306";

配置让系统每五分钟去取一次snmp数据:
#crontab -u cactiuser -e  //注意要用cactiuser就是你刚刚建立的那个账号去运行crontab

CODE:

*/5 * * * *  /usr/local/php/bin/php /data/www/wwwroot/cacti/poller.php > /dev/null 2>&1
七、客户端snmp配置
#yum -y install net-snmp*
#vi /etc/snmp/snmpd.conf

CODE:

# SNMP configfile for  Linux servers
com2sec local     127.0.0.1      public
com2sec local     192.168.22.0/24  public
group MyROGroup v1         local
group MyROGroup v2c        local
group MyROGroup usm        local
view all    included  .1                               80
access MyROGroup ""      any       noauth    exact  all    none   nones
yslocation (/etc/snmpd/snmpd.conf)
syscontact Me <hamgua@gmail.com>
#service snmpd restart

八、配置完成
打开浏览器输入
http://ip/cacti

1.jpg


输入用户名密码,默认的是adminadmin
然后提示修改密码
好了配置结束
尽情的去享受cacti吧!

2.jpg


3.jpg


4.jpg





本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Cacti安装配置文档
安装cacti模板
使用?cacti?批量监控服务器以及其?PHP?运作环境配置
Centos下稳步实现Cacti监控的详细配置
Cacti网络流量检测图形分析工具
用cacti来制图
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服