WEB . WAS

[Tomcat] 세션클러스터링

고구마맨 2023. 5. 9. 14:35
반응형

■ 세션 클러스터링

 - WAS 구성이 2대 이상일 때 동일한 세션 정보를 공유하기 위한 방법

 - 톰캣 서버의 간단한 설정으로 세션 정보를 동기화 할 수 있다.

 

1) server.xml 추가

 - 나는 <Host appBase="webapps" autoDeploy="true" name="xxx" unpackWARs="true"> 밑으로 위치시켰다.


Tomcat 1

<Cluster channelSendOptions="8" className="org.apache.catalina.ha.tcp.SimpleTcpCluster">

<Manager className="org.apache.catalina.ha.session.DeltaManager" expireSessionsOnShutdown="false" notifyListenersOnReplication="true"/>

 

<Channel className="org.apache.catalina.tribes.group.GroupChannel">

<Membership address="228.0.0.4" className="org.apache.catalina.tribes.membership.McastService" dropTime="3000" frequency="500" port="45564"/>

<Receiver address="auto" autoBind="100" className="org.apache.catalina.tribes.transport.nio.NioReceiver" maxThreads="6" port="4000" selectorTimeout="5000"/>

 

<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.MessageDispatchInterceptor"/>

</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" deployDir="/tmp/war-deploy/" tempDir="/tmp/war-temp/" watchDir="/tmp/war-listen/" watchEnabled="false"/>

 

<ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>

</Cluster>

 

Tomcat 2

 

<Cluster channelSendOptions="8" className="org.apache.catalina.ha.tcp.SimpleTcpCluster">

<Manager className="org.apache.catalina.ha.session.DeltaManager" expireSessionsOnShutdown="false" notifyListenersOnReplication="true"/>

 

<Channel className="org.apache.catalina.tribes.group.GroupChannel">

<Membership address="228.0.0.4" className="org.apache.catalina.tribes.membership.McastService" dropTime="3000" frequency="500" port="45564"/>

<Receiver address="auto" autoBind="100" className="org.apache.catalina.tribes.transport.nio.NioReceiver" maxThreads="6" port="4000" selectorTimeout="5000"/>

 

<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.MessageDispatchInterceptor"/>

</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" deployDir="/tmp/war-deploy/" tempDir="/tmp/war-temp/" watchDir="/tmp/war-listen/" watchEnabled="false"/>

 

<ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>

</Cluster>

 

 


 

2) web.xml 추가 (<web-app 열린 코드 제일 하단에 추가)

 

 

<distributable/> 

 

 

3) 선택

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

 

 jvmRoute="ID" 

→ 로드밸런싱을 설정하는 경우 worker 이름과 동일하게 하는 편이 좋다.

추가해서 WAS 별로 이름을 다르게 설정하면 세션 정보를 통해 어떤 WAS에서 생성되었는지 알 수 있다.

반응형