nginx+tomcat集群session复制问题

blackworm 发布于 2014/03/30 14:26
阅读 653
收藏 0
最近在使用nginx+tomcat集群碰到session复制问题,tomcat时不时报空指针异常,求高手解决,如图:
标签: <无>

代码片段(2)[全屏查看所有代码]

1. [图片] QQ图片20140330015930.jpg    

2. [代码][其他]代码     跳至 [2] [全屏预览]

001 Tomcat配置如下:
002 <?xml version='1.0' encoding='utf-8'?>
003 <!--
004   Licensed to the Apache Software Foundation (ASF) under one or more
005   contributor license agreements.  See the NOTICE file distributed with
006   this work for additional information regarding copyright ownership.
007   The ASF licenses this file to You under the Apache License, Version 2.0
008   (the "License"); you may not use this file except in compliance with
009   the License.  You may obtain a copy of the License at
010  
011       http://www.apache.org/licenses/LICENSE-2.0
012  
013   Unless required by applicable law or agreed to in writing, software
014   distributed under the License is distributed on an "AS IS" BASIS,
015   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016   See the License for the specific language governing permissions and
017   limitations under the License.
018 -->
019 <!-- Note:  A "Server" is not itself a "Container", so you may not
020      define subcomponents such as "Valves" at this level.
021      Documentation at /docs/config/server.html
022  -->
023 <Server port="8006" shutdown="SHUTDOWN">
024  
025   <!--APR library loader. Documentation at /docs/apr.html -->
026   <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
027   <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
028   <Listener className="org.apache.catalina.core.JasperListener" />
029   <!-- Prevent memory leaks due to use of particular java/javax APIs-->
030   <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
031   <!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->
032   <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
033   <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
034  
035   <!-- Global JNDI resources
036        Documentation at /docs/jndi-resources-howto.html
037   -->
038   <GlobalNamingResources>
039     <!-- Editable user database that can also be used by
040          UserDatabaseRealm to authenticate users
041     -->
042     <Resource name="UserDatabase" auth="Container"
043               type="org.apache.catalina.UserDatabase"
044               description="User database that can be updated and saved"
045               factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
046               pathname="conf/tomcat-users.xml" />
047   </GlobalNamingResources>
048  
049   <!-- A "Service" is a collection of one or more "Connectors" that share
050        a single "Container" Note:  A "Service" is not itself a "Container",
051        so you may not define subcomponents such as "Valves" at this level.
052        Documentation at /docs/config/service.html
053    -->
054   <Service name="Catalina">
055    
056     <!--The connectors can use a shared executor, you can define one or more named thread pools-->
057     <!--
058     <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
059         maxThreads="150" minSpareThreads="4"/>
060     -->
061      
062      
063     <!-- A "Connector" represents an endpoint by which requests are received
064          and responses are returned. Documentation at :
065          Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
066          Java AJP  Connector: /docs/config/ajp.html
067          APR (HTTP/AJP) Connector: /docs/apr.html
068          Define a non-SSL HTTP/1.1 Connector on port 8080
069     -->
070     <Connector port="81" protocol="HTTP/1.1"
071           minSpareThreads="25" maxSpareThreads="75"
072           enableLookups="false" disableUploadTimeout="true" connectionTimeout="20000"
073           acceptCount="300"  maxThreads="300" maxProcessors="1000" minProcessors="5"
074           useURIValidationHack="false"
075           compression="on" compressionMinSize="2048"
076           compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain"
077                redirectPort="8443"/><!--URIEncoding="UTF-8" -->
078     <!--<Connector port="81" protocol="HTTP/1.1"
079           URIEncoding="UTF-8"  minSpareThreads="25" maxSpareThreads="75"
080           enableLookups="false" disableUploadTimeout="true" connectionTimeout="20000"
081           acceptCount="300"  maxThreads="300" maxProcessors="1000" minProcessors="5"
082           useURIValidationHack="false"
083           compression="on" compressionMinSize="2048"
084           compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain"
085                redirectPort="8443"/>-->
086     <!-- A "Connector" using the shared thread pool-->
087     <!--
088     <Connector executor="tomcatThreadPool"
089                port="8080" protocol="HTTP/1.1"
090                connectionTimeout="20000"
091                redirectPort="8443" />
092     -->          
093     <!-- Define a SSL HTTP/1.1 Connector on port 8443
094          This connector uses the JSSE configuration, when using APR, the
095          connector should be using the OpenSSL style configuration
096          described in the APR documentation -->
097     <!--
098     <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
099                maxThreads="150" scheme="https" secure="true"
100                clientAuth="false" sslProtocol="TLS" />
101     -->
102  
103     <!-- Define an AJP 1.3 Connector on port 8009 -->
104     <Connector port="8019" protocol="AJP/1.3" redirectPort="8443" />
105  
106  
107     <!-- An Engine represents the entry point (within Catalina) that processes
108          every request.  The Engine implementation for Tomcat stand alone
109          analyzes the HTTP headers included with the request, and passes them
110          on to the appropriate Host (virtual host).
111          Documentation at /docs/config/engine.html -->
112  
113     <!-- You should set jvmRoute to support load-balancing via AJP ie :
114     <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">        
115     -->
116     <Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat3_zb">
117  
118       <!--For clustering, please take a look at documentation at:
119           /docs/cluster-howto.html  (simple how to)
120           /docs/config/cluster.html (reference documentation) -->
121        
122       <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"  channelSendOptions="6">
123         <Manager className="org.apache.catalina.ha.session.BackupManager"
124         expireSessionsOnShutdown="false"
125         notifyListenersOnReplication="true"
126         mapSendOptions="6"/>
127         <!--
128         <Manager className="org.apache.catalina.ha.session.DeltaManager"
129         expireSessionsOnShutdown="false"
130         notifyListenersOnReplication="true"/>
131         -->
132         <Channel className="org.apache.catalina.tribes.group.GroupChannel">
133         <Membership className="org.apache.catalina.tribes.membership.McastService"
134         address="228.0.0.4"
135         port="45564"
136         frequency="500"
137         dropTime="3000"/>
138         <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
139         address="auto"
140         port="4001"
141         selectorTimeout="100"
142         maxThreads="6"/>
143         <Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">
144         <Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/>
145         </Sender>
146         <Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>
147         <Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/>
148         <Interceptor className="org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor"/>
149         </Channel>
150         <Valve className="org.apache.catalina.ha.tcp.ReplicationValve"
151         filter=".*\.gif;.*\.js;.*\.jpg;.*\.png;.*\.htm;.*\.html;.*\.css;.*\.txt;"/>
152         <Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer"
153         tempDir="/tmp/war-temp/"
154         deployDir="/tmp/war-deploy/"
155         watchDir="/tmp/war-listen/"
156         watchEnabled="false"/>
157         <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>
158     </Cluster>
159               
160  
161       <!-- The request dumper valve dumps useful debugging information about
162            the request and response data received and sent by Tomcat.
163            Documentation at: /docs/config/valve.html -->
164       <!--
165       <Valve className="org.apache.catalina.valves.RequestDumperValve"/>
166       -->
167  
168       <!-- This Realm uses the UserDatabase configured in the global JNDI
169            resources under the key "UserDatabase".  Any edits
170            that are performed against this UserDatabase are immediately
171            available for use by the Realm.  -->
172       <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
173              resourceName="UserDatabase"/>
174  
175       <!-- Define the default virtual host
176            Note: XML Schema validation will not work with Xerces 2.2.
177        -->
178  
179         <Host name="localhost"  appBase="webapps"
180             unpackWARs="true" autoDeploy="true">
181             <Context path="" docBase="D:\Program Files\Apache Software Foundation\sites\zhongbao" reloadable="false" ></Context>
182         </Host>
183     </Engine>
184   </Service>
185 </Server>
加载中
0
南湖船老大
南湖船老大

没细看,可能你需要的是nginx sticky模块,让SSIONED值死死的粘滞在其中一台服务器上。

blackworm
blackworm
我都没有用nginx sticky模块呢
返回顶部
顶部