日期:2014-05-16  浏览次数:20975 次

apache+mod_jk+tomcat安装配置指南(二)

第一步:

编辑/opt/app/apache-boss/conf/workers.properties

?

worker.list=boss,mystatus


  worker.boss-a.port=8009
  worker.boss-a.host=192.168.0.161
  worker.boss-a.domain=boss-a
  worker.boss-a.type=ajp13
  worker.boss-a.lbfactor=20
  worker.boss-a.max_packet_size=65536
  worker.boss-a.connection_pool_timeout=600
  worker.boss-a.connection_pool_size=50
  worker.boss-a.connection_pool_minsize=40
  worker.boss-a.connect_timeout=5000
  worker.boss-a.prepost_timeout=5000
  worker.boss-a.socket_timeout=5
  worker.boss-a.retries=10

  worker.boss-a-1.reference=worker.boss-a
  worker.boss-a-1.port=9009
  worker.boss-a-1.host=192.168.0.161
  worker.boss-a-1.domain=boss-a

  worker.boss-b.reference=worker.boss-a
  worker.boss-b.port=10009
  worker.boss-b.host=192.168.0.161
  worker.boss-b.domain=boss-b

  worker.boss-b-1.reference=worker.boss-a
  worker.boss-b-1.port=11009
  worker.boss-b-1.host=192.168.0.161
  worker.boss-b-1.domain=boss-b

  worker.boss-c.reference=worker.boss-a
  worker.boss-c.port=8009
  worker.boss-c.host=192.168.0.163
  worker.boss-c.domain=boss-c

  worker.boss-c-1.reference=worker.boss-a
  worker.boss-c-1.port=9009
worker.boss-c-1.host=192.168.0.163
  worker.boss-c-1.domain=boss-c

  worker.boss-d.reference=worker.boss-a
  worker.boss-d.port=10009
  worker.boss-d.host=192.168.0.163
  worker.boss-d.domain=boss-d

  worker.boss-d-1.reference=worker.boss-a
  worker.boss-d-1.port=11009
  worker.boss-d-1.host=192.168.0.163
  worker.boss-d-1.domain=boss-d
  


  worker.boss.type=lb
  worker.boss.method=B
  worker.boss.balance_workers=boss-a,boss-b
  worker.boss.sticky_session=1
  worker.boss.sticky_session_force=0
  worker.mystatus.type=status
  worker.mystatus.read_only=True
  worker.mystatus.mount=/mystatus

?第二步:编辑boss-uriworkermap.properties

!/*.gif=boss
!/*.css=boss
!/scripts/*=boss
!/dwr/engine.js=boss
!/dwr/util.js=boss
!/*.jpg=boss
!/*.jpeg=boss
!/*.htm=boss
!/textEdit/*.js=boss
!/js/*=boss
!/*.ico=boss
!/*.dll=boss
!/*.bmp=boss
!/*.pgn=boss
!/*.tgz=boss
!/*.mp3=boss
/mystatus=mystatus
/*=boss

?第三步:

修改tomcat配置

/opt/app/tomcat-boss-a/bin/catalina.sh

加上以下:

JAVA_HOME=/opt/app/java
#-Xms1024m -Xmx1024m -Xmn500m -XX:+UseConcMarkSweepGC   -XX:MaxTenuringThreshold=5  -XX:+ExplicitGCInvokesConcurrent
JAVA_OPTS='-server -Xms2560m -Xmx2560m -Xmn768m -XX:PermSize=128m -XX:MaxPermSize=256m -Xss256k -XX:ParallelGCThreads=6 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:MaxTenuringThreshold=5 -XX:SurvivorRatio=6 -verbose:gc -XX:+HeapDumpOnOutOfMemoryError -Xloggc:/var/log/boss/gc-a.log -Djava.awt.headless=true -XX:+DisableExplicitGC -Dlog.home=/var/log/boss/boss-a -Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false'

?/opt/app/tomcat-boss-a/conf/server.xml

<?xml version='1.0' encoding='utf-8'?>
<!-- Note:  A "Server" is not itself a "Container", so you may not
     define subcomponents such as "Valves" at this level.
     Documentation at /docs/config/server.html
 -->
<Server port="8005" shutdown="SHUTDOWN">

  <!--APR library loader. Documentation at /docs/apr.html -->
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
  <Listener className="org.apache.catalina.core.JasperListener" />
  <!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />

  <!-- Global JNDI resources
       Documentation at /docs/jndi-resources-howto.html
  -->
  <GlobalNamingResources>
    <!-- Editable user datab