기술지원 문의

resin 2.1.6에서 tcp distributed session사용
비바람 / 2005-11-29 18:07

resin.conf에,

 

  <http id=a port=80 />
  <http id=b port=80 />
  <srun id=a host=xxx.xxx.xxx.xxa srun-index=1 port=6802/>
  <srun id=b host=xxx.xxx.xxx.xxb srun-index=2 port=6802/>

 

로 세팅을 했습니다.

session은,

 

    <session-config>
      <tcp-store />
      <always-save-session />
      <session-max>4096</session-max>
      <enable-cookies>true</enable-cookies>
      <session-timeout>1200</session-timeout>
    </session-config>

로 했구요.

resin버전은 2.1.6 입니다.

 

L4에서는 저 두서버를 round lobin으로 분기합니다.

스타트 하는 스크립트의 옵션에는 a서버에서는 -server a 옵션,

b서버에서는 -server b 를 주었고 맞게 먹는것도 확인했습니다.

 

이때, a서버에 웹으로 로그인하면,

~/WEB-INF/session폴더아래에

a29같은 폴더가 생기고,

b서버의 ~/WEB-INF/session 에도

b29가 생깁니다.

이걸로 봐서 설정은 맞는것 같은데,

이상하게 다른서버로 연결이 되게되면 로그인창으로 가버리네요.

 

모든 class는 serializable을 implement했구요.

잘못된 부분이 어딘지 알수가 있을런지요.

[답변]resin 2.1.6에서 tcp distributed session사용
권용찬 / 2005-12-01 23:03

질문하신부분에서 보면
http 데몬으로 운영 되는 process에 L4로 요청을 분기시키셔서 세션이 유지되도록 하려고 하신 것 같습니다.
저도 혼동이 되어 테스트 해본 결과

Session 유지는 srun Port로 구동된 Process간에서만 가능한 것으로 확인됩니다.

즉 resin.conf에

  <http id=a port=80 />
  <http id=b port=80 />
  <srun id=a host=xxx.xxx.xxx.xxa srun-index=1 port=6802/>
  <srun id=b host=xxx.xxx.xxx.xxb srun-index=2 port=6802/>

하셨다면

  <http id=a port=80 />
  <http id=b port=80 />
두개사이에 세션유지는 동작하지 못합니다. 이는 http 서버로 운영중인 레진 데몬의 기능제약인것 같습니다.
(이렇게 해보려고 한적인 없어서 -.-)

그리고 -server a start 하시면 srun 데몬은 구동조차 되지 않습니다.
레진사이트에서 셈플이 이렇게 되어 있는데.. 제가 테스트를 잘못한것인지...

여하간 동작하게 하는 방법은 다음과 같습니다.

1. 양쪽(편의를 위하 A Server,B Server)에 Apache를 설치하십시요

2. 각각의 서버에서 resin을 컴파일 하여 모듈을 생성하시고 설치하십시요
./configure --with-apxs=/export/home/yckwon/apache13/bin/apxs \\
--with-apache=/export/home/yckwon/apache13 \\
--prefix=/export/home/yckwon/resin      <== 원래깔려있는 resin위치를 동일하게 적어 주시면 됩니다.
#make     <== 모듈을 생성합니다.
#make install    <== 모듈을 복사하고 httpd.conf에 필요한 정보를 수정합니다.
(원래 Resin은 제공된 그대로 컴파일 없이 구동이 가능하나
연동 모듈 생성을 위해서는 컴파일 해주셔야 합니다.)

3. Apache httpd.conf 파일에 필요한 설정을 하시고
위에서 make install 까지 하시면 resin 설치스크립트가 내용을 추가 해 줍니다.

4. 양쪽 서버 resin.conf에 다음과 같이 설정합니다.
  <http id=httpa port=8080/>
  <http id=httpb port=8080/>
  <srun id=a host=192.168.1.1 srun-index=1 port=6802/>
  <srun id=b host=192.168.1.2 srun-index=2 port=6802/>
   ...
  <host id=>
   ...
    <web-app id=/>
     ....
      <session-config>
        <tcp-store/>
        <always-save-session/>
     ....

5. Server A의 start Script를 다음과 같이 작성하십시요
#!/bin/sh
JAVA_HOME=/usr/j2se
RESIN_HOME=/export/home/yckwon/resin/resin-2.1.16
SERVER_ROOT=/export/home/yckwon/resin/resin-2.1.16
CLASSPATH=.
export JAVA_HOME RESIN_HOME SERVER_ROOT CLASSPATH
$RESIN_HOME/bin/httpd.sh -verbose -server-root $SERVER_ROOT  -server a -pid $SERVER_ROOT/a.pid start
$RESIN_HOME/bin/httpd.sh -verbose -server-root $SERVER_ROOT  -server httpa -pid $SERVER_ROOT/httpa.pid start

6.  Server B의 start Script를 다음과 같이 작성하십시요
#!/bin/sh
JAVA_HOME=/usr/j2se
RESIN_HOME=/export/home/yckwon/resin/resin-2.1.16
SERVER_ROOT=/export/home/yckwon/resin/resin-2.1.16
CLASSPATH=.
export JAVA_HOME RESIN_HOME SERVER_ROOT CLASSPATH
$RESIN_HOME/bin/httpd.sh -verbose -server-root $SERVER_ROOT  -server b -pid $SERVER_ROOT/b.pid start
$RESIN_HOME/bin/httpd.sh -verbose -server-root $SERVER_ROOT  -server httpb -pid $SERVER_ROOT/httpb.pid start

위와 같이 작업후 세션 서블릿에서 setAttribute 한 정보가 양쪽 서버를 번갈아 다운해도 유지되는 것이 확인됩니다.

(첨부된 파일은 톰켓의 셈플을 레진에 맞도록 수정해서 통으로 압축해서 올려습니다. 서블릿 예제에 세션 서블릿을 사용해서 테스트 해보시기 바랍니다.)