Sha*_*zad 5 tomcat session-replication load-balancing nginx cluster-computing
在我的nginx中,我设置了上游和设置粘性会话:
upstream tomcat {
ip_hash;
server localhost:XXXX;
server localhost:XXXY;
server localhost:XXYY;
}
Run Code Online (Sandbox Code Playgroud)
我<distributable/>
在我的web.xml中添加了标签(在所有的tomcats中)
在我的tomcat/conf/server.xml文件中添加了这个:
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"
channelSendOptions="6">
<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="3000"/>
<Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
address="auto"
port="5000"
selectorTimeout="100"
maxThreads="6"/>
<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"/>
<Interceptor className="org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor"/>
</Channel>
<Valve className="org.apache.catalina.ha.tcp.ReplicationValve"
filter=".*\.gif|.*\.js|.*\.jpeg|.*\.jpg|.*\.png|.*\.htm|.*\.html|.*\.css|.*\.txt"/>
<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.ClusterSessionListener"/>
</Cluster>
Run Code Online (Sandbox Code Playgroud)
在我的tomcat/conf/context.xml中添加了这个:
<Manager className="org.apache.catalina.ha.session.BackupManager"
expireSessionsOnShutdown="false"
notifyListenersOnReplication="true"
mapSendOptions="6"/>
Run Code Online (Sandbox Code Playgroud)
但现在我可以登录我的应用程序了.如果所有3个或任何2个实例都启动并且我登录,我会看到JSESSIONID e..g xyz234.tomcat1
现在,如果我关闭tomcat1,它将带我回到登录页面,因为tomcat1已关闭.我再次登录,它创建了与tomcat2相关的会话,同时,我再次启动tomcat1,我的应用程序将带我回到登录页面.所以,我面临两个问题:
注意:我使用的是JSF2应用程序,因此不确定它是否与它有任何关系.
归档时间: |
|
查看次数: |
837 次 |
最近记录: |