tomcat 配置及启动

catalina.sh

JAVA_OPTS="-server -Xmx4000M -Xms4000M -Xmn2000M -XX:PermSize=256m -XX:MaxPermSize=256m -Xss512K -XX:+ExplicitGCInvokesConcurrent -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -
XX:CMSFullGCsBeforeCompaction=0 -XX:+CMSClassUnloadingEnabled -XX:LargePageSizeInBytes=128M -XX:+UseFastAccessorMethods -XX:CMSInitiatingOccupancyFraction=80 -XX:SoftRefLRUPolicyMSPerMB=0 -Djava.rmi.server.hostname=10.100.54.150 -verbose
:gc -XX:+PrintGCTimeStamps -XX:+PrintGCDetails -Xloggc:/letv/logs/boss-gc.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/letv/logs/dump/boss.dump"

#JAVA_OPTS="$JAVA_OPTS -Djava.nio.channels.spi.SelectorProvider=sun.nio.ch.EPollSelectorProvider"

 

server.xml

<?xml version='1.0' encoding='utf-8'?>

<Server port="8074" shutdown="SHUTDOWN">
 
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />

  <Listener className="org.apache.catalina.core.JasperListener" />
 
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

  
  <GlobalNamingResources>
   
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>


<Service name="Catalina">

  <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" 
        maxThreads="150" minSpareThreads="4"/>
 
<Connector port="8084" executor="tomcatThreadPool"  
                protocol="org.apache.coyote.http11.Http11NioProtocol"
                maxHttpHeaderSize="8192"
                maxThreads="1000"
                                maxConnections="20000" 
                minSpareThreads="100"
                maxSpareThreads="1000"
                minProcessors="100"
                maxProcessors="1000"
                enableLookups="false"
                compression="on"
                compressionMinSize="2048"
                compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain"
                connectionTimeout="20000"
                                asyncTimeout="600000"
                URIEncoding="UTF-8"
                acceptCount="1000"
                redirectPort="8443"
                disableUploadTimeout="true"/>

    <Engine name="Catalina" defaultHost="localhost">

   
      <Realm className="org.apache.catalina.realm.LockOutRealm">
       
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>

      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">

       




      </Host>
    </Engine>
  </Service>
</Server>

 

conf/Catalina/localhost/ROOT.xml

 

<?xml version='1.0' encoding='utf-8'?> 
<Context path="/" docBase="/web/myapp.com" reloadable="true"/> 

 

restart-tomcat.sh

#!/bin/sh 
TOMCATNAME="tomcat-apiboss"
pid=`ps aux|grep "${TOMCATNAME}" |grep start| awk 'NR==1 { print $2 }'` 
if [ $pid > 0 ]; then 
kill -9 $pid
fi

rm -fr /letv/tomcat/${TOMCATNAME}/logs/*
#rm -f /letv/logs/api*
BUILD_ID=boss /letv/tomcat/${TOMCATNAME}/bin/startup.sh
sleep 5;
tail -50 /letv/tomcat/${TOMCATNAME}/logs/catalina.out
exit 

 

tomcat.sh  start|stop|restart

 

#!/bin/sh
################################################################################
#       Title:  Tomcat tolls
#       Author: frank
#       Date:   2012-04-24
###############################################################################

BASEDIR=/letv/tomcat
TOMCATNAME="tomcat-apiboss"

function_printlog()
{
    tail -f -n 500 ${BASEDIR}/${TOMCATNAME}/logs/catalina.out
}

function_start()
{
    printf "Starting Tomcat ...\n"
    source /etc/profile
    ${BASEDIR}/${TOMCATNAME}/bin/startup.sh
    function_printlog
}

function_stop()
{
    printf "Stoping Tomcat ...\n"
    APP_ID=`ps aux |grep "${TOMCATNAME}"|grep -v "grep"|awk '{print $2}'`
    kill -9 $APP_ID
}

function_restart()
{
    printf "Restarting Tomcat ...\n"
    function_stop
    sleep 5
    rm -fr ${BASEDIR}/${TOMCATNAME}/logs/*
    sleep 1
    function_start
}

function_kill()
{
    printf "killing Tomcat ...\n"
    APP_ID=`ps aux |grep "${TOMCATNAME}"|grep -v "grep"|awk '{print $2}'`
    kill -9 $APP_ID
}

if [ "$1" = "start" ]; then
    function_start
elif [ "$1" = "stop" ]; then
    function_stop
elif [ "$1" = "restart" ]; then
    function_restart
elif [ "$1" = "kill" ]; then
    function_kill
else
    printf "please input 'start' 'stop' 'restart' 'kill' parameter!\n"
fi

 

un-web.sh

 

 sh /tomcat/tomcat.sh stop

sleep 3

rm -fr /web/api.boss.com

unzip /web/api.boss.com.war -d /web/api.boss.com

sh /letv/tomcat/restart_tomcat.sh

 

check-tomcat.sh

export LANG=en_US.UTF-8

URL="127.0.0.1:8084/pinfo/get/price?pid=75984"
LOG="/l/alarm/stat.log"

code=`curl -o /dev/null -s --connect-timeout 3  -w %{http_code} $URL`

if [ $code -eq 200 ]
then
    echo 0 > $LOG
else
    if [ ! -f "$LOG" ]; then
        echo 0 > $LOG
    fi
    n=`cat $LOG`
    n=`expr $n + 1`
    echo $n > $LOG
    if [[ $n -ge 3 ]]; then
        curl -o /dev/null -s --connect-timeout 3 "http://10.154.250.38:7070/alarm/notify?biz=boss"
    fi
fi

 

 check

#!/bin/sh
source /etc/profile 
strvalue="dfafadsfadsfasdf";
domainvalue="pay.58.com";
checkDir="/opt/backup/checktomcat/";
checkLog=$checkDir"check_pay.log";
echo "" > $checkLog;
array=(10.5.10.11 10.5.10.12);
#array=(10.5.10.11);
for iplist in `echo ${array[@]:0}`
do
        curl http://$iplist:8085 --connect-timeout 5 > $checkLog
        status=`sed -n '1p' $checkLog | awk '{print $0}'`
        if [[ "$status" != "$strvalue"  ]]
        then  status="timeout"
              echo $status
        fi
        echo "`date` $status" > $checkDir$iplist.log
done

 

你可能感兴趣的:(tomcat)