欢迎来到新闻!
我的订单 签到有礼 资讯中心
当前位置:首页 > 代码知识 >
代码知识

【编程】tomcat的jvm和session同步配置

发布日期:2019-12-13 17:21 浏览量:0

  今天修改tomcat的jvm和配置session同步时,重启tomcat发现了几个错误:

  一、部署tomcat 6.0.20,使用sh startup.sh启动tomcat 出现This file is needed to run this program

  原因.sh文件都不是可执行文件,于是找到命令:

<pre name="code" class="plain">chmod +x *.sh  
chmod +x *.sh再次执行 sh catalina.sh通过,然后用sh startup.sh成功启动
例如:chmod 777 /opt/tomcat6_8081/bin/catalina.sh

  二、查看当前tomcat是否被占用:

<pre name="code" class="plain"> ps -ef|grep tomcat

  JVM内存配置(/bin/catalina.sh 最顶部即可):

<pre name="code" class="plain">JAVA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8
-server -Xms1024m -Xmx2048m-XX:NewSize=256m 
-XX:MaxNewSize=256m -XX:PermSize=256m
-XX:MaxPermSize=256m -XX:+DisableExplicitGC"

  tomcat共享session配置(/conf/server.xml标签中):

<span style="font-size:14px;"><Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster" channelSendOptions="8">
  <Manager className="org.apache.catalina.ha.session.DeltaManager" expireSessionsOnShutdown="false" notifyListenersOnReplication="true" maxInactiveInterval="28800" />
  <Channel className="org.apache.catalina.tribes.group.GroupChannel">
    <Membership className="org.apache.catalina.tribes.membership.McastService" address="228.0.0.4" port="45564" frequency="500" dropTime="5000" />
    <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver" address="auto" port="4000" autoBind="100" selectorTimeout="10000" maxThreads="150" />
    <Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">
      <Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender" />
    </Sender>
    <Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector" />
    <Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor" />
  </Channel>
  <Valve className="org.apache.catalina.ha.tcp.ReplicationValve" filter="" />
  <Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve" />
  <Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer" tempDir="/tmp/war-temp/" deployDir="/tmp/war-deploy/" watchDir="/tmp/war-listen/" watchEnabled="false" />
  <ClusterListener className="org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener" />
  <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener" />
</Cluster></span>

  web.xml文件的修改很简单:只需要在节点中添加这个节点就可以了。 tomcat安全证书配置(/conf/server.xml标签中):

<span style="font-size:14px;"><Connector server="ligang" port="9443" minProcessors="5" maxProcessors="150" minSpareThreads="25" maxSpareThreads="75"
disableUploadTimeout="true" URIEncoding="utf-8" useBodyEncodingForURI="true" SSLEnabled="true"
clientAuth="false" keystoreFile="ligang.p12" keystorePass="ligang@)!@" keystoreType="PKCS12" sslProtocol="TLS"
enableLookups="true" connectionTimeout="20000" acceptCount="100" debug="0" scheme="https" secure="true" /></span>