■ 세션 클러스터링
- 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에서 생성되었는지 알 수 있다.
'WEB . WAS' 카테고리의 다른 글
[Apache] Apache + php 7.4.33 연동(TS버전) 3일차(완료) (0) | 2023.05.23 |
---|---|
[Apache] Apache + php 7.4.33 연동(TS버전) 2일차 (0) | 2023.05.19 |
[Apache] Apache + php 7.4.33 연동(TS버전) 1일차 (0) | 2023.05.18 |
[Apache] 설치하기_CentOS7_httpd-2.0.64.tar (0) | 2023.04.12 |
[NGINX] Nginx Start && Restart (0) | 2022.11.22 |