Tomcat multi-instance one-click Deployment Shell Script

Source: Internet
Author: User

#!bin/bash#tomcat deployment script, upload apache-tomcat-8.5.30.tar.gz, jdk-8u172-linux-x64.tar.gz to the server's/tmp/directory in advance. Install Jdktar  -zxf /tmp/jdk-8u172-linux-x64.tar.gz -c /usr/local/ln -s /usr/local/jdk1.8.0_ 172/ /usr/local/jdk# Configuring the Java Environment cat >> /etc/profile.d/java.sh <<eofexport  Java_home=/usr/local/jdk/export path=\ $JAVA _home/bin:\ $JAVA _home/jre/bin:\ $PATHEOF # Note the source /etc/here Profile, after the script has finished running, you need to exit and then log back on to the server to load/etc/profile. Otherwise, the Java environment fails source /etc/profile#2. Installing tomcattar -zxf /tmp/apache-tomcat-8.5.30.tar.gz -c  /usr/local/ln -s /usr/local/apache-tomcat-8.5.30/ /usr/local/tomcatcd /usr/local/tomcat/ mkdir -pv /usr/local/tomcat_dirmv conf/ logs/ temp/ webapps/ work/ / Usr/local/tomcat_dir#n to establish the number of Tomcat instances N=7for ((i=1;i<=n;i++)) do      /usr/bin/ mkdir -pv /usr/local/tomcat$i      /usr/bin/cp -a /usr/local/tomcat_dir/* /usr/local/tomcat$i      sed -i  ' s /server port= "8005"/server port= "708 ' $i '"/'  /usr/local/tomcat$i/conf/server.xml        sed -i  ' s/connector port= ' 8080 "/connector port=" 808 ' $i ' "/'  /usr/local/tomcat$i/conf/server.xml       sed -i  ' s/ Connector port= "8009"/connector port= "908 ' $i '"/'  /usr/local/tomcat$i/conf/server.xml  donerm -rf /usr/local/tomcat_dir/mkdir -pv /usr/local/tomcat_sh/#注意下面的 "\", representing non-translation. cat > /usr/local/tomcat_sh/start_tomcat.sh <<eof#!/bin/bashsource /etc/ profilepath=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/binexport catalina_home=/usr/local/ Tomcatexport catalina_base=\${1%/}export log=\ $CATALINA _base/startup.log# use %/ is  for next grep matchecho \$catalina_basetomcat_pid=\$ (ps aux | grep  "java"  | grep -v  "grep"    | grep  "Dcatalina.base=\${catalina_base}"   |awk  ' {print \$2} ') if [  -n  "\ $Tomcat _pid"  ];then    echo  "the tomcat instance  \ $CATALINA _base is running,please checkout the status ";     exit  1;fi/usr/bin/sh \ $CATALINA _home/bin/startup.sh > \ $log  2>&1if [  "\$?"  = 0 ];then    echo  "The tomcat instance \ $CATALINA _ Base start succeed!!! "; else    echo  "The tomcat instance \ $CATALINA _base start  Faild!!! "     tail -f \ $logfiEOFcat  > /usr/local/tomcat_sh/stop_tomcat.sh  <<eof#!/bin/bashsource /etc/profilepath=/usr/local/sbin:/usr/local/bin:/Usr/sbin:/usr/bin:/root/binexport catalina_home=/usr/local/tomcatexport catalina_base=\${1%/}export  log=\ $CATALINA _base/stop.log# use %/ is for next grep matchecho  \ $CATALINA _basetomcat_pid=\$ (ps aux | grep  "java"  | grep -v  "grep"   | grep  "Dcatalina.base=\${catalina_base}"   |awk  ' {print \$2} ') if  [ -n  "\ $Tomcat _pid"  ];then    /usr/bin/sh \ $CATALINA _home/bin/ Shutdown.sh > \ $log  2>&1else    echo  "the tomcat  Instance \ $CATALINA _base is not running,please checkout the status "     exit 1;fiif [  "\$?"  = 0 ];then    echo  "The tomcat instance \ $CATALINA _ Base stop succeed!!! "; else    echo  "THE&NBSP;TOMCAt instance \ $CATALINA _base stop faild!!! "     tail -f \ $logfiEOFchmod  +x -r /usr/local/tomcat_sh/


Tomcat multi-instance one-click Deployment Shell Script

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.