Nginx - Jboss 연동, fail-over

 

 

1. 준비

- Nginx 설치 : 1.8.0

- Jboss 설치 : 5.1.0

 

2. Nginx : 1년전에 설치만 해두었던 것 활용

             (다운로드 후 압축해제..)

 

3. Jboss 설치

- download : http://jbossas.jboss.org/downloads.html

 

 

- 5.1.x 를 테스트 할 필요 있어서 5.1.0 다운로드

 

 

 

4. jboss 설치(압축 해제) 후

- JBOSS_HOME\server\all 을 copy 하여

- node1, node2 만든다.

 

 

 

5. JBOSS_HOME\bin 의 run.bat 수정

- JBOSS_HOME 지정 : 압축 푼 위치

- JAVA_HOME : 로컬의 설치 위치

 

 

6. node1, node2 기동 스크립트 작성

 

 

[run_node1.bat]

cd D:\dev\jboss\jboss-5.1.0.GA\bin

run.bat  -c node1 -g testCluster -u 239.255.100.100 -b 127.0.0.1 -Djboss.messaging.ServerPeerID=1 -Djboss.service.binding.set=ports-default

 

[run_node2.bat]

cd D:\dev\jboss\jboss-5.1.0.GA\bin

run.bat  -c node2 -g testCluster -u 239.255.100.100 -b 127.0.0.1 -Djboss.messaging.ServerPeerID=2 -Djboss.service.binding.set=ports-01

 

옵션은 다음과 같음(인터넷 참조)

     -c : 생성한 node 명 (node1, node2)

     -g : 클러스터 명 (testCluster)
     -u : 내부 클러스터 통신을 위한 멀티캐스트 주소
     -b : 소켓에 바운딩될 아이피 주소

 

7. 소스 생성

- ROOT.war copy 해서 test.war 생성

 

 

- 내부에는 WEB-INF 폴더와 web.xml 만 남겨둠

- web.xml 도 필요 없는 내용 다 지움

 

 

[web.xml]

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"    "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app> 

    <display-name>Welcome to JBoss</display-name> 

    <description>     Welcome to JBoss  </description>

 

</web-app> 

     

- 테스트 페이지 작성

 

8. Nginx 설정

 

- location 부분 과 upstream 설정

- max_fails 를 설정하지 않으면

- fail-over 가 되긴 하나 지연시간이 길다(10~20여초)

 

 

 server {

        listen       80;

        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

 ... (생략)

               

        location /test {

            proxy_pass   http://backend;

        }

     }

 ... (생략)

 

 upstream backend {

        server 127.0.0.1:8080  max_fails=2;

        server 127.0.0.1:8180;

    }

 

 

9. Jboss 기동

 

- 1번 기동

 

- 2번 기동

 

- 2번에 Clustering 메시지 표지 (New Member... 등등)

 

10. Jboss 확인(기동)

- 1번 기동 (8080 port)

 

- 2번 기동 (8180 port)

 

11. Nginx 확인(80 포트로 접속)

 

 

12. Fail-over 테스트

- 1번 Shutdown

 

- 2번에 Clustering 메시지 표지 (Member Dead... 등등)

 

13. Nginx 재확인(80 포트로 접속)

 

 

 

+ Recent posts