#!/bin/bash #need sudo -s first VER="1.4.2" ############## linux setting ################### mkdir /data0/soft /usr/sbin/adduser nginx mkdir -m755 /data0/nginx mkdir -m755 /data0/testlog chown nginx /data0/testlog echo ‘append /etc/sysctl.conf‘ echo ‘fs.file-max = 1048576‘>>/etc/sysctl.conf echo ‘ ‘ /sbin/sysctl -p echo ‘ ‘ echo ‘nginx soft nofile 20480‘>>/etc/security/limits.conf echo ‘nginx hard nofile 20480‘>>/etc/security/limits.conf echo ‘session required pam_limits.so‘>>/etc/pam.d/login su nginx -c ‘ulimit -n‘ /sbin/ifconfig|head -n2 ############ install and config the nginx ############## \cd /data0/soft rsync 10.210.208.48::temp/suda_web/nginx-$VER/*.tar.gz . rsync 10.210.208.48::temp/suda_web/nginx-$VER/*.zip . #wait tar -xvf nginx-$VER.tar.gz && unzip -u nginx-suda-patch-$VER.zip && unzip -u headers-more-nginx-module-0.19rc1.zip && tar -xvf pcre-8.32.tar.gz && tar -xvf zlib-1.2.7.tar.gz && cd /data0/soft/nginx-$VER ./configure --prefix=/data0/nginx --user=nginx--with-pcre=/data0/soft/pcre-8.32 --with-zlib=/data0/soft/zlib-1.2.7 --with-http_stub_status_module --with-http_realip_module --add-module=/data0/soft/headers --add-module=/data0/soft/missub --add-module=/data0/soft/misetag --add-module=/data0/soft/mistime --add-module=/data0/soft/miscookie && make && make install ################ conf ################################ cd /data0/soft && unzip -o nginx-conf-pack-$VER.zip && cd /data0/soft/nginx-conf-pack && chmod 755 nginx-auto-conf.py && cat nginx.conf.prd | /usr/bin/python nginx-auto-conf.py 1 >nginx.conf&& cat nginx.conf.test | /usr/bin/python nginx-auto-conf.py 1 >nginx.conf.test&& rm -rf /data0/nginx/html/* && \cp -ru /data0/soft/nginx-conf-pack/htdocs/* /data0/nginx/html ################ start nginx ####################### #!/bin/bash cd /data0/nginx \cp /data0/soft/nginx-conf-pack/nginx.conf /data0/nginx/conf/nginx.conf mkdir -p /data0/logs/clickstream/ chgrp -R nginx /data0/logs/clickstream/ chmod -R 775 /data0/logs/clickstream/ /data0/nginx/sbin/nginx ############### other setting ######################## curl -I http://127.0.0.1/a.gif tail /data0/logs/clickstream/clickstream* ############### other setting ######################## cd /data0/soft \cp /etc/rc.local /data0/nginx/conf/rc.local.bak echo ‘‘>> /etc/rc.local echo ‘#nginx‘>> /etc/rc.local echo ‘/data0/nginx/sbin/nginx‘>> /etc/rc.local crontab -l>tmpcron.txt echo ‘‘>>tmpcron.txt echo ‘#nginx clean log‘>>tmpcron.txt echo ‘1 10 * * * echo>/data0/nginx/logs/access.log‘>>tmpcron.txt crontab tmpcron.txt crontab -l cat /etc/rc.local ## temp ckctl update rsync 10.210.208.48::temp/suda_web/nginx-$VER/ckctl.html /data0/nginx/html/ckctl.html # rm -rf /data0/soft/headers # rm -rf /data0/soft/headers-more-nginx-module-0.19rc1.zip # rm -rf /data0/soft/nginx-1.2.5 # rm -rf /data0/soft/nginx-1.2.5.tar.gz # rm -rf /data0/soft/nginx-conf-pack # rm -rf /data0/soft/nginx-conf-pack.zip # rm -rf /data0/soft/nginx-suda-patch # rm -rf /data0/soft/nginx-suda-patch.tar.gz # rm -rf /data0/soft/openssl-1.0.1c # rm -rf /data0/soft/openssl-1.0.1c.tar.gz # rm -rf /data0/soft/pcre-8.32 # rm -rf /data0/soft/pcre-8.32.tar.gz # rm -rf /data0/soft/zlib-1.2.7 # rm -rf /data0/soft/zlib-1.2.7.tar.gz
install_nginx.sh
#!/bin/sh #ftp cd /data0/soft rsync 10.210.208.48::temp/suda_web/proftpd-1.3.1rc3.tar.gz . tar -zxf proftpd-1.3.1rc3.tar.gz cd proftpd-1.3.1rc3 ./configure make make install #config cd /data0/soft rsync 10.210.208.48::temp/suda_web/proftpd.conf . \cp proftpd.conf /usr/local/etc #user mkdir -p /data0/suds_autoftp /usr/sbin/adduser -d /data0/suds_autoftp/ftp_out/ -s /sbin/nologin suds_autoftp_001 echo "sudsautoftppswd001" |passwd --stdin suds_autoftp_001 #start /usr/local/sbin/proftpd & echo "" >> /etc/rc.local echo "#ftp" >> /etc/rc.local echo "/usr/local/sbin/proftpd &" >> /etc/rc.local #clear rm -rf proftpd-1.3.1rc3.tar.gz proftpd-1.3.1rc3
install_ftp.sh
#!/bin/sh #clicklog cd /data0/soft rsync 10.210.208.48::temp/suda_web/suds_autoftp/autoftp_clicklog.sh . rsync 10.210.208.48::temp/suda_web/suds_autoftp/data_bak.conf . mkdir -p /data0/suds_autoftp/ftp_out mv autoftp_clicklog.sh /data0/suds_autoftp mv data_bak.conf /data0/suds_autoftp #heartbeat cd /data0/soft rsync 10.210.208.48::temp/suda_web/heartbeat.sh . mkdir -p /data0/heartbeat mv heartbeat.sh /data0/heartbeat chmod a+x /data0/heartbeat/heartbeat.sh #databak mkdir /data0/suds_autoftp/ftp_out/data_bak mkdir /data0/auto_databak cd /data0/auto_databak rsync -avz 10.210.208.48::temp/suda_web/auto_databak/ . data1=`df -h|grep data1` if [ "$data1" == "" ] then mkdir -p /data0/data_bak mount --bind /data0/data_bak /data0/suds_autoftp/ftp_out/data_bak echo "" >> /etc/rc.local echo "#mount" >> /etc/rc.local echo "mount --bind /data0/data_bak /data0/suds_autoftp/ftp_out/data_bak" >> /etc/rc.local else mkdir -p /data1/data_bak mount --bind /data1/data_bak /data0/suds_autoftp/ftp_out/data_bak echo "/data1/data_bak 10" > /data0/auto_databak/path.conf echo "/data1/data_bak" > /data0/suds_autoftp/data_bak.conf echo "" >> /etc/rc.local echo "#mount" >> /etc/rc.local echo "mount --bind /data1/data_bak /data0/suds_autoftp/ftp_out/data_bak" >> /etc/rc.local fi crontab -l>tmpcron.txt echo ‘#for standard time‘>>tmpcron.txt echo ‘0 */3 * * * /usr/sbin/ntpdate tiger.sina.com.cn 202.106.184.186 > /dev/null‘>>tmpcron.txt echo ‘‘>>tmpcron.txt echo ‘#for suda log‘>>tmpcron.txt echo ‘1,31 * * * * /data0/suds_autoftp/autoftp_clicklog.sh > /dev/null‘>>tmpcron.txt echo ‘‘>>tmpcron.txt echo ‘# for heartbeat check‘>>tmpcron.txt echo ‘*/10 * * * * /data0/heartbeat/heartbeat.sh > /dev/null‘>>tmpcron.txt echo ‘‘>>tmpcron.txt echo ‘#logclear‘>>tmpcron.txt echo ‘20 4 * * * /data0/auto_databak/auto_logclear.sh > /dev/null‘>>tmpcron.txt
install_beacon.sh
#!/bin/sh #clicklog cd /data0/soft rsync 10.210.208.48::temp/suda_web/suds_autoftp/autoftp_clicklog.sh . rsync 10.210.208.48::temp/suda_web/suds_autoftp/data_bak.conf . mkdir -p /data0/suds_autoftp/ftp_out mv autoftp_clicklog.sh /data0/suds_autoftp mv data_bak.conf /data0/suds_autoftp #heartbeat cd /data0/soft rsync 10.210.208.48::temp/suda_web/heartbeat.sh . mkdir -p /data0/heartbeat mv heartbeat.sh /data0/heartbeat chmod a+x /data0/heartbeat/heartbeat.sh #databak mkdir /data0/suds_autoftp/ftp_out/data_bak mkdir /data0/auto_databak cd /data0/auto_databak rsync -avz 10.210.208.48::temp/suda_web/auto_databak/ . data1=`df -h|grep data1` if [ "$data1" != "not use data1" ] then mkdir -p /data0/data_bak mount --bind /data0/data_bak /data0/suds_autoftp/ftp_out/data_bak echo "" >> /etc/rc.local echo "#mount" >> /etc/rc.local echo "mount --bind /data0/data_bak /data0/suds_autoftp/ftp_out/data_bak" >> /etc/rc.local else mkdir -p /data1/data_bak mount --bind /data1/data_bak /data0/suds_autoftp/ftp_out/data_bak echo "/data1/data_bak 10" > /data0/auto_databak/path.conf echo "/data1/data_bak" > /data0/suds_autoftp/data_bak.conf echo "" >> /etc/rc.local echo "#mount" >> /etc/rc.local echo "mount --bind /data1/data_bak /data0/suds_autoftp/ftp_out/data_bak" >> /etc/rc.local fi crontab -l>tmpcron.txt echo ‘#for standard time‘>>tmpcron.txt echo ‘0 */3 * * * /usr/sbin/ntpdate tiger.sina.com.cn 202.106.184.186 > /dev/null‘>>tmpcron.txt echo ‘‘>>tmpcron.txt echo ‘#for suda log‘>>tmpcron.txt echo ‘1,31 * * * * /data0/suds_autoftp/autoftp_clicklog.sh > /dev/null‘>>tmpcron.txt echo ‘‘>>tmpcron.txt echo ‘# for heartbeat check‘>>tmpcron.txt echo ‘*/10 * * * * /data0/heartbeat/heartbeat.sh > /dev/null‘>>tmpcron.txt echo ‘‘>>tmpcron.txt echo ‘#logclear‘>>tmpcron.txt echo ‘20 4 * * * /data0/auto_databak/auto_logclear.sh > /dev/null‘>>tmpcron.txt
install_beacon_data0.sh
#!/bin/bash RSYNC=‘10.39.2.120::wenhui/database/install‘ CMAKE=‘cmake-2.8.6.tar.gz‘ MYSQL=‘mysql-5.5.24.tar.gz‘ MYSQL_DIR=‘/usr/local/mysql55‘ MYSQL_DATADIR=‘/data1/mysqldata/mysql3306‘ function main(){ user=`whoami` if [ "$user" != "root" ]; then echo "please use root to execute this script" exit 1 fi module=$1 module_type=$2 case "$1" in cmake) install_cmake ;; mysql) install_mysql $module_type ;; *) echo "USAGE: $0 MODULE[cmake|mysql] MODULE_TYPE[full|libmysql|mysqlclient]" esac } #install cmake function install_cmake(){ echo "begin install cmake"; sleep 1 echo "get tar from $RSYNC" eval "rsync -avzP $RSYNC/$CMAKE ./" dir=`echo $CMAKE | perl -pe ‘s/\Q.tar.gz\E$//g‘` eval "test -e $dir && rm -rf $dir" eval "tar -zxvf $CMAKE" echo "cd to $dir" eval "cd $dir" ./configure make && make install cd .. } #install mysql function install_mysql(){ LD_PATH=‘/etc/ld.so.conf.d/mysql.conf‘ INSTALL_TYPE=‘full‘ if [ "$1" != "" ]; then INSTALL_TYPE=$1 fi echo "begin install mysql $INSTALL_TYPE"; sleep 1 echo "get tar from $RSYNC" eval "rsync -avzP $RSYNC/$MYSQL ./" dir=`echo $MYSQL | perl -pe ‘s/\Q.tar.gz\E$//g‘` eval "test -d $dir && rm -rf $dir" eval "tar -zxvf $MYSQL" echo "cd to $dir" eval "cd $dir" if [ "$INSTALL_TYPE" == "full" ]; then eval "useradd mysql -s /sbin/nologin" eval "cmake -DCMAKE_INSTALL_PREFIX=$MYSQL_DIR \ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR==$MYSQL_DATADIR -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DWITH_EXTRA_CHARSETS=all " make && make install #copy configure file SCRIPT_DIR="$MYSQL_DIR/start" test -d $SCRIPT_DIR || mkdir -p $SCRIPT_DIR eval "rsync -avzp $RSYNC/my.cnf $SCRIPT_DIR" eval "rsync -avzp $RSYNC/init.sh $SCRIPT_DIR" elif [ "$INSTALL_TYPE" == "libmysql" ]; then eval "cmake -DCMAKE_INSTALL_PREFIX=$MYSQL_DIR \ -DWITHOUT_SERVER=ON " make && make install elif [ "$INSTALL_TYPE" == "mysqlclient" ]; then eval "cmake -DCMAKE_INSTALL_PREFIX=$MYSQL_DIR \ " make mysqlclient libmysql && make install fi echo "add bin path to /etc/bashrc" echo "" >> /etc/bashrc echo "#mysql envirment" >> /etc/bashrc echo "export PATH=\$PATH:$MYSQL_DIR/bin" >> /etc/bashrc echo "add ld path to $LD_PATH" echo "$MYSQL_DIR/lib" > $LD_PATH ldconfig } main $1 $2
install_mysql.sh
[[email protected] ~]# mysqladmin -S /tmp/mysql3306.sock shutdown #停止 [[email protected] ~]# sh /usr/local/mysql55/start/my3306.sh #启动
时间: 2024-11-10 00:53:35