Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1146593
  • 博文数量: 119
  • 博客积分: 1991
  • 博客等级: 上尉
  • 技术积分: 4452
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-23 21:28
文章分类

全部博文(119)

文章存档

2012年(111)

2011年(8)

分类: LINUX

2012-04-20 02:05:33

原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://blog.chinaunix.net/space.php?uid=9419692&do=blog&id=3182665
近段时间一直在整服务器监控方面的东西,以下就是cacti中英文版安装的全过程,各安装包基本都是最新的,基于Centos 5.2平台下安装的!!
#!/bin/bash
# BY kerryhu
# QQ:263205768
# MAIL:king_819@163.com
# BLOG:[url]http://kerry.blog.51cto.com[/url]
# Please manual operation yum of before Operation.....
#Centos 5.2
# yum install ntp vim-enhanced gcc gcc-c++ flex bison autoconf \
# automake bzip2-devel ncurses-devel libjpeg-devel libpng-devel \
# libtiff-devel freetype-devel pam-devel kernel netconfig
#########################################
ntpdate time.nist.gov
groupadd mysql
useradd mysql -d /dev/null -g mysql -s /sbin/nologin
cd /opt
#####################################
#2、安装ncurses-5.6
tar -zxvf ncurses-5.6.tar.gz
cd ncurses-5.6
./configure --prefix=/usr --with-shared --without-debug
make
make install
make install clean
####################################
#3、安装mysql-5.0.51a
cd /opt
tar -zxvf mysql-5.0.51a.tar.gz
cd mysql-5.0.51a
./configure --with-mysqld-user=mysql --prefix=/usr/local/mysql5 --with-charset=gbk --with-extra-charset=all --without-isam --exec-prefix=/usr/local/mysql5
make
make install
/usr/local/mysql5/bin/mysql_install_db
chown -R mysql.mysql /usr/local/mysql5/
cp /usr/local/mysql5/share/mysql/my-medium.cnf /etc/my.cnf
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 700 /etc/rc.d/init.d/mysqld
/usr/local/mysql5/bin/mysqld_safe --user=mysql &
/etc/rc.d/init.d/mysqld start
chkconfig --add mysqld
chkconfig --level 2345 mysqld on
ln -s /usr/local/mysql5/bin/mysql /sbin/mysql
ln -s /usr/local/mysql5/bin/mysqladmin /sbin/mysqladmin
#配置库文件搜索路径
echo "/usr/local/mysql5/lib/mysql" >> /etc/ld.so.conf
#添加/usr/local/mysql5/bin到环境变量PATH中
export PATH=$PATH:/usr/local/mysql5/bin
########################################################
#4、安装ZLIB2
# 如果不安装,等下编译安装openssl 就会报错,所以提前编译安装
cd /opt
tar zxvf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure
make
make install
######################################################
#5、安装openssl-0.9.8g
cd /opt
tar zxvf openssl-0.9.8g.tar.tar
cd openssl-0.9.8g
./config shared zlib
make
make test
make install
mv /usr/bin/openssl /usr/bin/openssl.OFF
mv /usr/include/openssl /usr/include/openssl.OFF
rm /usr/lib/libssl.so
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/ssl/include/openssl /usr/include/openssl
ln -sv /usr/local/ssl/lib/libssl.so.0.9.8 /usr/lib/libssl.so
#配置库文件搜索路径
echo "/usr/local/ssl/lib" >> /etc/ld.so.conf
#################################################
#6、安装BerkeleyDB
cd /opt
tar zxvf db-4.5.20.tar.gz
cd db-4.5.20/build_unix
../dist/configure --prefix=/usr/local/BerkeleyDB
make;make install
ln -sv /usr/local/BerkeleyDB/include /usr/include/db4
ln -sv /usr/local/BerkeleyDB/include/db.h /usr/include/db.h
ln -sv /usr/local/BerkeleyDB/include/db_cxx.h /usr/include/db_cxx.h
echo "/usr/local/BerkeleyDB/lib" >> /etc/ld.so.conf
ldconfig
####################################################
#7、安装httpd-2.2.8
cd /opt
tar jxvf httpd-2.2.8.tar.bz2
cd httpd-2.2.8
./configure --prefix=/usr/local/apache2 --enable-so --enable-ssl --with-ssl=/usr/local/ssl --enable-track-vars --enable-rewrite --with-zlib --enable-mods-shared=most --enable-suexec --with-suexec-caller=daemon
make;make install

echo "/usr/local/apache/bin/apachectl start" >> /etc/rc.d/rc.local
/usr/local/apache/bin/apachectl start
#################(8)安装libPNG######################################
cd /opt
tar zxvf libpng-1.2.26.tar.gz
cd libpng-1.2.26
cp scripts/makefile.linux ./makefile
./configure --prefix=/usr/local/libpng
make;make install
##################(9)安装freetype##################################
cd /opt
tar zxvf freetype-2.3.5.tar.gz
cd freetype-2.3.5
./configure
make;make install
##################(10)安装JPEG6##################################
cd /opt
tar zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b
mkdir -pv /usr/local/jpeg/{,bin,lib,include,man/man1,man1}
./configure --prefix=/usr/local/jpeg --enable-shared --enable- static
make;make install
##################(11)安装GD####################################
cd /opt
tar zxvf gd-2.0.35.tar.gz
cd gd-2.0.35
./configure --with-png --with-freetype --with-jpeg=/usr/local/jpeg/
make;make install
##################(12)安装LIBXML2################################
cd /opt
tar zxvf libxml2-2.6.31.tar.gz
cd libxml2-2.6.31
./configure --prefix=/usr/local/libxml2
make;make install
cp xml2-config /usr/bin
##################(13)安装libmcrypt###############################
cd /opt
tar zxvf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7
./configure
make;make install
##################(14)安装PHP5.2.5###################################
cd /opt
tar zxvf php-5.2.5.tar.gz
cd php-5.2.5
./configure --prefix=/usr/local/php5 --with-mysql=/usr/local/mysql5 --with-apxs2=/usr/local/apache2/bin/apxs --with-jpeg-dir=/usr/local/jpeg --with-freetype-dir=/usr/local/include/freetype2 --with-zlib --with-png-dir=usr/local/libpng12 --with-libxml-dir=/usr/local/libxml2 --with-gd --enable-ftp --enable-sockets -enable-mbstring=all- --with-mcrypt --with-mysqli=/usr/local/mysql5/bin/mysql_config
make;make install
cp php.ini-dist /usr/local/php5/lib/php.ini
mv /usr/local/apache/conf/http.conf /usr/local/apache/conf/http.conf.bak
cp /opt/httpd.conf /usr/local/apache2/conf/httpd.conf
cp /opt/index.php /usr/local/apache2/htdocs/
##############################################
# INSTALL ZendOptimizer
cd /opt
tar -zxvf ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz
cd ZendOptimizer-3.3.3-linux-glibc23-i386
./install
echo "LINUX+MYSQL+APACHE2+PHP5+ZEND INSTALL OK"
#安装Time::HiRes
cd /opt
tar zxvf Time-HiRes-1.9715.tar.gz
cd Time-HiRes-1.9715
perl Makefile.PL
make
make test
make install
#安装File::Tail
cd /opt
tar zxvf File-Tail-0.99.3.tar.gz
cd File-Tail-0.99.3
perl Makefile
make
make test
make install
cd /opt
rpm -ivh libart_lgpl-devel-2.3.17-4.i386.rpm
tar zxvf cgilib-0.5.tar.gz
cd cgilib-0.5
make
cp libcgi.a /usr/local/lib
cp cgi.h /usr/include
ln -s /usr/local/include/freetype2/ /usr/include/freetype2
#安装rrdtool-1.2.23
cd /opt
tar zxvf rrdtool-1.2.23.tar.gz
cd rrdtool-1.2.23
./configure --prefix=/usr/local/rrdtool
make
make install
#========================安装net-snmp========================
cd /opt
tar -zxvf net-snmp-5.3.2.tar.gz
cd net-snmp-5.3.2
./configure –prefix=/usr/snmp –enable-mfd-rewrites --enable-developer
make;make install
cp EXAMPLE.conf /usr/local/net-snmp/share/snmp/snmpd.conf
#vi /usr/local/net-snmp/share/snmp/snmpd.conf
#com2sec local localhost public
#com2sec mynetwork 192.168.8.0/24 public

/usr/local/net-snmp/sbin/snmpd -c /usr/local/net-snmp/share/snmp/snmpd.conf
echo "/usr/local/net-snmp/sbin/snmpd -c /usr/local/net-snmp/share/snmp/snmpd.conf" >> /etc/rc.local
PATH=/usr/local/net-snmp/bin/:/usr/local/net-snmp/sbin/:$PATH
cd ../
#=======================安装 英文版cacti============================
#下载
cd /opt
useradd cactiuser -g users
passwd cactiuser (pwd:cactipw)
tar -zxvf cacti-0.8.7b.tar.gz
mkdir -p /var/www/
mv cacti-0.8.7b /var/www/cacti
#创建cactidb数据库
/usr/local/mysql5/bin/mysqladmin -u root password nginx
/usr/local/mysql5/bin/mysql -u root -pnginx
create database cactidb;
grant all on cactidb.* to identified by 'cactipw';
exit;
cd /var/www/cacti
/usr/local/mysql5/bin/mysql -u root -pnginx cactidb chown -R cactiuser rra/ log/
cd scripts
chown cactiuser:users *
#vi /var/htdoc/cacti/include
#$database_type = “mysql”;
#$database_default = “cactidb”;
#$database_hostname = “localhost”;
#$database_username = “cactiuser”;
#$database_password = “cactipw”;
crontab -u cactiuser -e
加入
*/5 * * * * /usr/local/php5/bin/php /var/www/cacti/poller.php > /dev/null 2>&1
#[url] [/url] admin admin cactipw
su cactiuser
/usr/local/php5/bin/php /var/www/cacti/poller.php
# 把cacti目录里的cmd.php和poller.php文件加下运行的权限
#测试SNMP是不是工作正常 snmpwalk -c community -v 2c hostIP if正常的话会出现一些数据。不正常会出现一些错误,也会有对应的错误提示。
#7、我原来使用的是rrdtool-1.0.x 升级到 1.2.x 后部分图像无法显示(Zoom)
#修改Configuration -> Settings -> RRDTool Utility Version -> 1.2.x

#==========================安装 中文版cacti===================================
cd /opt
tar -zxvf cacti-0.8.7b-cn-utf8.tar.gz
useradd cactiuser -g users
passwd cactiuser (pwd:cactipw)
mkdir -p /var/www/
mv cacti-0.8.7b /var/www/cacti
#创建cactidb数据库
/usr/local/mysql5/bin/mysqladmin -u root password nginx
/usr/local/mysql5/bin/mysql -u root -pnginx
create database cactidb;
grant all on cactidb.* to identified by 'cactipw';
exit;
cd /var/www/cacti
/usr/local/mysql5/bin/mysql -u root -pnginx cactidb chown -R cactiuser rra/ log/
cd scripts
chown cactiuser:users *
#vi /var/htdoc/cacti/include/config.php global.php
#$database_type = “mysql”;
#$database_default = “cactidb”;
#$database_hostname = “localhost”;
#$database_username = “cactiuser”;
#$database_password = “cactipw”;
crontab -u cactiuser -e
加入
*/5 * * * * /usr/local/php5/bin/php /var/www/cacti/poller.php > /dev/null 2>&1
#[url] [/url] admin admin cactipw
su cactiuser
/usr/local/php5/bin/php /var/www/cacti/poller.php
#字体在图形中显示不正常的解决方法,下载并安装cjkuni-fonts中文字体,字体名ukai.ttf
cd /opt
wget
tar zxvf ttf-arphic-ukai_0.1.20060928.orig.tar.gz
cd ttf-arphic-ukai-0.1.20060928/
cp ukai.ttf /usr/share/fonts/ukai.ttf
#安装完成后注意在"设置"中更改下面两个必改项.
#常规->RRDTool应用程序版本 改为1.2.x,默认为1.0.x.不改可能图像不能正常显示出来.
#路径->RRDTool默认字体路径 改为上面安装的ukai.ttf的文件路径,如/usr/share/fonts/ukai.ttf

本文出自 “聆听未来” 博客,请务必保留此出处http://blog.chinaunix.net/space.php?uid=9419692&do=blog&id=3182665

阅读(1650) | 评论(0) | 转发(2) |
给主人留下些什么吧!~~