Chinaunix首页 | 论坛 | 博客
  • 博客访问: 344787
  • 博文数量: 93
  • 博客积分: 2322
  • 博客等级: 大尉
  • 技术积分: 1600
  • 用 户 组: 普通用户
  • 注册时间: 2012-08-27 10:23
文章分类

全部博文(93)

文章存档

2018年(12)

2012年(81)

分类: LINUX

2012-08-28 16:28:49

#!/bin/bash
rpm -qa |grep httpd |xargs rpm -e --nodeps
rpm -qa |grep mysql |xargs rpm -e --nodeps
rpm -qa |grep php |xargs rpm -e --nodeps
rpm -qa |grep jdk |xargs rpm -e --nodeps
sleep 5
chkconfig --level 35 iptables off
service iptables stop
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
ntpdate pool.ntp.org
hwclock -w
mkdir /opt/tar
mkdir /opt/src
install
apache2
cd /opt/tar
wget
tar -zxf httpd-2.2.17.tar.gz  -C ../src/
cd ../src/httpd-2.2.17/
./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite --enable-info --enable-cgid --enable-mime-magic --enable-alias --enable-access --enable-deflate --enable-forward --enable-proxy --enable-http --enable-proxy-connect --enable-proxy-http --enable-file-cache --enable-cache --enable-disk-cache --enable-mem-cache --with-mpm=prefork
make ; make install
install logs
cd /opt/tar
wget
tar -zxf  cronolog-1.6.2.tar.gz -C ../src/
cd ../src/cronolog-1.6.2/
./configure && make && make install
install  nginx
cd /opt/tar
wget
wget
wget
wget
wget
tar -jxf zlib-1.2.3.tar.bz2 -C ../src
tar -zxf openssl-0.9.8l.tar.gz -C ../src
tar -zxf pcre-8.10.tar.gz -C ../src
tar -zxf ngx_cache_purge-1.0.tar.gz -C ../src
tar -zxf nginx-0.8.52.tar.gz -C ../src/
cd /opt/src/nginx-0.8.52/
useradd www
usermod -G www www;
./configure --user=www --group=www --add-module=/opt/src/ngx_cache_purge-1.0 --prefix=/usr/local/nginx --with-http_realip_module --with-http_sub_module --with-http_flv_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_ssl_module --with-pcre=/opt/src/pcre-8.10/ --with-openssl=/opt/src/openssl-0.9.8l/ --with-zlib=/opt/src/zlib-1.2.3
make ; make install
install jdk
cd /opt/tar
wget
cp jdk-6u29-linux-x64.bin  /usr/local/
cd /usr/local
chmod u+x jdk-6u29-linux-x64.bin
./jdk-6u29-linux-x64.bin
rm -f jdk-6u29-linux-x64.bin
echo "export JAVA_HOME=/usr/local/jdk1.6.0_29 "  >> /etc/profile
echo "export RESIN_HOME=/usr/local/resin"  >> /etc/profile
echo "export PATH=\$JAVA_HOME/bin:\$PATH:\$RESIN_HOME/bin" >> /etc/profile
echo "export CLASSPATH=.:\$JAVA_HOME/lib/dt.jar:\$JAVA_HOME/lib/tools.jar:\$JAVA_HOME/lib/htmlconverter.jar:\$RESIN_HOME/lib:/usr/java/jdbc/mysql-connector-java-3.1.10-bin.jar"  >> /etc/profile
echo "#export LANG=zh_CN.utf8" >> /etc/profile
echo "#export LANG=zh_CN.gb18030"  >> /etc/profile
echo "ulimit -SHn 51200" >> /etc/profile
source /etc/profile
java -version
install resin
cd /opt/tar
wget
tar -zxf resin-pro-3.1.10.tar.gz -C /opt/src
cd /opt/src/resin-pro-3.1.10/
./configure --prefix=/usr/local/resin  --with-java-home=/usr/local/jdk1.6.0_29
make
make install
cp  /opt/src/resin-pro-3.1.10/contrib/init.resin  /etc/rc.d/init.d/resin
chmod +x /etc/init.d/resin
chkconfig --add resin
chkconfig resin on
# vi /etc/init.d/resin
#修改以下代码
#JAVA_HOME=/usr/java/jdk1.6.0_27
#RESIN_HOME=/usr/local/resin
#在找到以下四条前面加入#号
#log_daemon_msg "Starting resin"
#log_end_msg $?
#log_daemon_msg "Stopping resin"
#log_end_msg $?
#直接用修改好的去进行测试前提是做了ssh认证双向
scp -P 6822 192.168.0.241:/etc/rc.d/init.d/resin   /etc/rc.d/init.d/resin
chmod +x /etc/rc.d/init.d/resin
chkconfig --add resin
chkconfig resin on
chkconfig --level 35 resin on

install jdbc
cd /opt/tar
wget
tar -zxf mysql-connector-java-3.1.10.tar.gz  -C /opt/src
mkdir  /usr/java/
cp -fr /opt/src/mysql-connector-java-3.1.10  /usr/java
cd /usr/java
ln -s mysql-connector-java-3.1.10/  jdbc
 
install mysql
cd /opt/tar
wget
tar -zxf mysql-cluster-gpl-7.1.19-linux-x86_64-glibc23.tar.gz  -C /opt/src
rm -fr /usr/local/mysql/*
cp -fr /opt/src/mysql-cluster-gpl-7.1.19-linux-x86_64-glibc23/* /usr/local/mysql/
cd /usr/local/mysql
useradd mysql
usermod -G mysql mysql
chown root:root /usr/local/mysql -R
/usr/local/mysql/scripts/mysql_install_db  --user mysql --basedir /usr/local/mysql/  --datadir /usr/local/mysql/data/
chown mysql:mysql /usr/local/mysql/data -R
/usr/local/mysql/bin/mysqld_safe --user mysql &
cp /usr/local/mysql/support-files/my-large.cnf  /etc/my.cnf
cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
/etc/init.d/mysql stop

install inotify
cd /opt/tar
wget
tar -zxf inotify-tools-3.13.tar.gz -C /opt/src
cd /opt/src/inotify-tools-3.13/
./configure --prefix=/usr/local/inotify  && make && make install
ln -s /usr/local/inotify/bin/* /usr/local/bin/
install rsync
cd /opt/tar
wget
tar -zxf rsync-3.0.6pre1.tar.gz -C /opt/src
cd /opt/src/rsync-3.0.6pre1/
./configure --prefix=/usr/local/rsync  && make && make install
ln -s   /usr/local/rsync/bin/*  /usr/local/bin/
install keepalived
cd /opt/tar
wget  
tar zxvf keepalived-1.1.15.tar.gz   -C /opt/src
cd /opt/src/keepalived-1.1.15 
./configure --prefix=/usr/local/keepalived 
make  
make install 
cp /usr/local/keepalived/sbin/keepalived /usr/sbin/ 
cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/ 
cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/ 
mkdir /etc/keepalived 
cd /etc/keepalived/ 
主keepalived配置
cat keepalived.conf 
! Configuration File for keepalived 
global_defs { 
   notification_email { 
    
        } 
   notification_email_from  
   smtp_server 127.0.0.1 
   smtp_connect_timeout 30 
   router_id LVS_DEVEL 

vrrp_instance VI_1 { 
    state MASTER 
    interface eth0 
    virtual_router_id 51 
    mcast_src_ip 192.168.0.154    <==主nginx的IP地址 
    priority 100 
    advert_int 1 
    authentication { 
        auth_type PASS 
        auth_pass chtopnet 
    } 
    virtual_ipaddress { 
        192.168.0.188                      <==vip地址 
    } 

#service keepalived start
cd /etc/keepalived/ 
辅keepalived配置
! Configuration File for keepalived 
global_defs { 
   notification_email { 
    
        } 
   notification_email_from  
   smtp_server 127.0.0.1 
   smtp_connect_timeout 30 
   router_id LVS_DEVEL 

vrrp_instance VI_1 { 
    state BACKUP 
    interface eth0 
    virtual_router_id 51 
    mcast_src_ip 192.168.0.155              <==辅nginx的IP的地址 
    priority 100 
    advert_int 1 
    authentication { 
        auth_type PASS 
        auth_pass chtopnet 
    } 
    virtual_ipaddress { 
        192.168.0.188 
    } 
}

rsync同步脚本
/root/rsync/rsync.sh
#! /bin/bash -
#####天子
####versionov01
####Department: 技术部
####author£oì×
####tiime:2012-3-26
####master
src=/usr/local/WEB
ip1=192.168.0.242             
ip2=192.168.0.245
des=/usr/local/WEB
/usr/local/bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format  '%T %w%f' \
 -e modify,delete,create,attrib \
        ${src} \
        | while read  file
                   do
                        rsync -avzr -e 'ssh -p 6822' --delete --progress ${src}/ &&
                        echo "${file} was rsynced"
                        rsync -avzr -e 'ssh -p 6822' --delete --progress ${src}/ &&
                        echo "${file} was rsynced"
                        echo "------------------------------------------------------"
done
keepalived检测脚本
cat /root/keepalived/nginx.pid.sh
#!/bin/bash 
while  : 
do 
 nginxpid=`ps -C nginx --no-header | wc -l` 
 if [ $nginxpid -eq 0 ];then 
  /usr/local/nginx/sbin/nginx 
  sleep 5 
  nginxpid=`ps -C nginx --no-header | wc -l`
   if [ $nginxpid -eq 0 ];then 
   /etc/init.d/keepalived stop 
   fi 
 fi 
 sleep 5  
done

添加脚本开机自动启动到后台
vi /etc/rc.d/rc.local
nohup /bin/sh /root/keepalived/nginx.pid.sh &
nohup /bin/sh /root/rsync/rsync.sh &
阅读(2087) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~