Microsoft PowerPoint - ApacheHTTPIntegration-운영트랙-김병곤.ppt

Similar documents
Microsoft PowerPoint - 3_김병곤.ppt [호환 모드]

No Slide Title

Apache2 + Tomcat 5 + JK2 를 사용한 로드밸런싱과 세션 복제 클러스터링 사이트 구축

Intro to Servlet, EJB, JSP, WS

Introduction to SOA

교육2 ? 그림

rmi_박준용_final.PDF

Microsoft PowerPoint - L4-7Switch기본교육자료.ppt

Microsoft PowerPoint - 1_이우진.pptx

thesis

02 C h a p t e r Java

Web Application Hosting in the AWS Cloud Contents 개요 가용성과 확장성이 높은 웹 호스팅은 복잡하고 비용이 많이 드는 사업이 될 수 있습니다. 전통적인 웹 확장 아키텍처는 높은 수준의 안정성을 보장하기 위해 복잡한 솔루션으로 구현

Interstage5 SOAP서비스 설정 가이드

FileMaker 15 ODBC 및 JDBC 설명서

PowerPoint 프레젠테이션

Connection 8 22 UniSQLConnection / / 9 3 UniSQL OID SET

(Microsoft PowerPoint - Chapter17 RMI.ppt [\310\243\310\257 \270\360\265\345])

Samsung SDS Enterprise Cloud Networking CDN Load Balancer WAN

Analytics > Log & Crash Search > Unity ios SDK [Deprecated] Log & Crash Unity ios SDK. TOAST SDK. Log & Crash Unity SDK Log & Crash Search. Log & Cras

- JPA를사용하는경우의스프링설정파일에다음을기술한다. <bean id="entitymanagerfactory" class="org.springframework.orm.jpa.localentitymanagerfactorybean" p:persistenceunitname=

Chap7.PDF

목차 BUG offline replicator 에서유효하지않은로그를읽을경우비정상종료할수있다... 3 BUG 각 partition 이서로다른 tablespace 를가지고, column type 이 CLOB 이며, 해당 table 을 truncate

Microsoft PowerPoint - Supplement-03-TCP Programming.ppt [호환 모드]

Cache_cny.ppt [읽기 전용]

Portal_9iAS.ppt [읽기 전용]

Chap12

1

API STORE 키발급및 API 사용가이드 Document Information 문서명 : API STORE 언어별 Client 사용가이드작성자 : 작성일 : 업무영역 : 버전 : 1 st Draft. 서브시스템 : 문서번호 : 단계 : Docum

FileMaker ODBC 및 JDBC 가이드

untitled

J2EE Concepts

Corporate PPT Template

Microsoft PowerPoint - RMI.ppt

목차 JEUS EJB Session Bean가이드 stateful session bean stateful sample 가이드 sample source 결과확인 http session에

<C0CCBCBCBFB52DC1A4B4EBBFF82DBCAEBBE7B3EDB9AE2D D382E687770>

Spring Data JPA Many To Many 양방향 관계 예제

(Microsoft PowerPoint - Spring 3.1\277\241\274\255 Ehcache \310\260\277\353 \300\374\267\253.pptx)

Microsoft PowerPoint - 03-TCP Programming.ppt

Microsoft PowerPoint - Smart CRM v4.0_TM 소개_ pptx

자바-11장N'1-502

TTA Journal No.157_서체변경.indd

ALTIBASE 사용자가이드 Templete

Voice Portal using Oracle 9i AS Wireless

Microsoft PowerPoint - 04-UDP Programming.ppt

신림프로그래머_클린코드.key

歯Writing_Enterprise_Applications_2_JunoYoon.PDF

J2EE & Web Services iSeminar

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션

개요오라클과티베로에서 JDBC 를통해접속한세션을구분할수있도록 JDBC 접속시 ConnectionProperties 를통해구분자를넣어줄수있다. 하나의 Node 에다수의 WAS 가있을경우 DB 에서 Session Kill 등의동작수행시원하는 Session 을선택할수있다.

제11장 프로세스와 쓰레드

I T C o t e n s P r o v i d e r h t t p : / / w w w. h a n b i t b o o k. c o. k r

[Brochure] KOR_LENA WAS_

FileMaker ODBC and JDBC Guide

The Self-Managing Database : Automatic Health Monitoring and Alerting

ORANGE FOR ORACLE V4.0 INSTALLATION GUIDE (Online Upgrade) ORANGE CONFIGURATION ADMIN O

Network Programming

PowerPoint Presentation

PCServerMgmt7

Oracle9i Real Application Clusters

비긴쿡-자바 00앞부속

@OneToOne(cascade = = "addr_id") private Addr addr; public Emp(String ename, Addr addr) { this.ename = ename; this.a

Slide 1

Interstage4 설치가이드

Spring Boot/JDBC JdbcTemplate/CRUD 예제

MasoJava4_Dongbin.PDF

Mobile Service > IAP > Android SDK [ ] IAP SDK TOAST SDK. IAP SDK. Android Studio IDE Android SDK Version (API Level 10). Name Reference V

KYO_SCCD.PDF

thesis

목 차

Microsoft Word - Jeus_System_Architecture.doc

Microsoft Word - ntasFrameBuilderInstallGuide2.5.doc

Cloud Friendly System Architecture

Secure Programming Lecture1 : Introduction

이도경, 최덕재 Dokyeong Lee, Deokjai Choi 1. 서론

슬라이드 1

vm-웨어-앞부속

2

ISS 웹서버연동부록 C. 쓰리래빗츠와웹서버를연동하려면아파치톰캣커넥터를사용합니다. 쓰리래빗츠가아파치톰캣을이용 하기때문입니다. 윈도우 8 을기준으로설명합니다. 윈도우버전에따라 IIS 관리자화면이다릅니다. C.1 isapi_redirect.dll 설치 1 설치에필요한파일을

final_thesis

NoSQL

목차 BUG DEQUEUE 의 WAIT TIME 이 1 초미만인경우, 설정한시간만큼대기하지않는문제가있습니다... 3 BUG [qp-select-pvo] group by 표현식에있는컬럼을참조하는집합연산이존재하지않으면결괏값오류가발생할수있습니다... 4

Spring Boot

chapter1,2.doc

RED HAT JBoss Data Grid (JDG)? KANGWUK HEO Middleware Solu6on Architect Service Team, Red Hat Korea 1

The Pocket Guide to TCP/IP Sockets: C Version

Microsoft PowerPoint - JBossASTunning4BP.ppt

단계

PWR PWR HDD HDD USB USB Quick Network Setup Guide xdsl/cable Modem PC DVR 1~3 1.. DVR DVR IP xdsl Cable xdsl Cable PC PC DDNS (

6주차.key

쉽게 풀어쓴 C 프로그래밊

SMB_ICMP_UDP(huichang).PDF

다른 JSP 페이지호출 forward() 메서드 - 하나의 JSP 페이지실행이끝나고다른 JSP 페이지를호출할때사용한다. 예 ) <% RequestDispatcher dispatcher = request.getrequestdispatcher(" 실행할페이지.jsp");

초보자를 위한 분산 캐시 활용 전략

FileMaker ODBC and JDBC Guide

.

04장

Secure Programming Lecture1 : Introduction

untitled

PowerPoint Presentation

Transcription:

Apache HTTP Server Integration & JBoss AS Clustering 김병곤 JBoss User Group

Agenda Apache HTTP Integration JBoss AS Clustering Q/A

웹서버의로드밸런싱 app1 app2 Apache1 192.168.10.2 app3 app1 JBoss1 192.168.10.4 Client L4 Switch 192.168.10.1 app2 app3 Apache2 192.168.10.3 JBoss2 192.168.10.5 app1 app2 Apache1 192.168.10.2 app3 app1 JBoss1 192.168.10.4 Client L4 Switch 192.168.10.1 app2 app3 Apache2 192.168.10.3 JBoss2 192.168.10.5

Apache HTTP Server 와 JBoss 통합시고려사항 어떤 URI 를 JBoss 가처리할것인가? 웹서버는몇개의 JBoss 와연결되는가? 웹서버는어떤포트로 JBoss 와통신하게되는가? 웹서버는어떤방식으로 JBoss 에게요청을전달하는가? 웹서버는 JBoss 에서장애가발생한경우어떻게대처하는가?

Apache HTTP Server Integration Apache HTTP Server Integration 절차 1. Apache HTTP Server 설치하기 2. mod_jk 모듈설치하기 3. mod_jk 모듈설정하기 4. JBoss Worker 설정하기 5. URI Worker Mapping 설정하기 6. 웹서버구동하기 7. JBoss 구동하기

Apache HTTP Server 설치 다운로드 http://ftp.kaist.ac.kr/pub/apache/httpd/binaries/win32/apa che_2.2.11-win32-x86-openssl-0.9.8i.msi

mod_jk 설치하기 다운로드 URL http://www.apache.org/dist/tomcat/tomcatconnectors/jk/binaries 설치 다운로드한 mod_jk-1.2.27-httpd-2.2.10.so 파일을 <APACHE_HOME>/modules 디렉토리로복사

Apache HTTP Server 설정하기 Apache HTTP Server 에서 mod_jk 를활성화하려면 <APACHE_HOME>/conf/httpd.conf 파일에다음을추가... 생략 # Include mod_jk configuration file ( 추가 ) Include conf/mod-jk.conf # Server-pool management (MPM specific) #Include conf/extra/httpd-mpm.conf # Multi-language error messages #Include conf/extra/httpd-multilang-errordoc.conf... 생략

mod_jk 설정하기 <APACHE_HOME>/conf/mod-jk.conf 파일을다음과같이작성 LoadModule jk_module modules/mod_jk-1.2.27-httpd-2.2.10.so JkWorkersFile conf/workers.properties JkLogFile logs/mod_jk.log JkLogLevel debug JkLogStampFormat "[%a %b %d %H:%M:%S %Y]" JkOptions +ForwardKeySize +ForwardURICompatUnparsed -ForwardDirectories JkRequestLogFormat "%w %V %T" JkMountFile conf/uriworkermap.properties JkShmFile run/jk.shm 파일명오타주의 로깅레벨은통합이완전히끝나기전까지 debug 유지 Worker 파일, Mount 파일의파일명주의

mod_jk 설정하기 - Worker <APACHE_HOME>/conf/workers.properties 파일 (JBoss Instance=Worker 정의 ) worker.list=loadbalancer 웹서버가처리할 worker 목록 # ------------------------ # Node1 JBoss Server # ------------------------ worker.node1.host=localhost 로드밸런싱할 node1의 host worker.node1.port=8009 로드밸런싱할 node1의 port worker.node1.type=ajp13 node1 worker와웹서버연결시사용하는프로토콜유형 worker.node1.lbfactor=1 다수의노드로부하를분산시키는경우부하분산비율 # ------------------------ # Load Balancer Worker # ------------------------ worker.loadbalancer.type=lb loadbalancer worker list 의유형은로드밸런싱 worker.loadbalancer.balance_workers=node1 로드밸런싱할 JBoss 노드목록

mod_jk 설정하기 - Worker <JBOSS_HOME>/server/<CONFIGURATION>/deploy/jbossweb.sar/server.xml 파일 <Server> <Listener classname="org.apache.catalina.core.jasperlistener" /> <Service name="jboss.web"> <!-- A HTTP/1.1 Connector on port 8080 --> <Connector protocol="http/1.1" port="8080" address="${jboss.bind.address}" connectiontimeout="20000" redirectport="8443" /> <!-- A AJP 1.3 Connector on port 8009 --> <Connector protocol="ajp/1.3" port="8009" address="${jboss.bind.address}" redirectport="8443" />... 생략 </Service>... 생략 </Server>

mod_jk 설정하기 URI Worker Mapping 웹서버로들어오는요청의 URI 에따라서 JBoss 가처리할것과웹서버가처리할것을구분 <APACHE_HOME>/conf/uriworkermap.properties 파일 /jmx-console/*=loadbalancer /jmx-console=loadbalancer /helloworld/*=loadbalancer /helloworld=loadbalancer /*.do=loadbalancer /*.jsp=loadbalancer /*.faces=loadbalancer /*.seam=loadbalancer

JBoss 의 jvmroute 설정하기 <JBOSS_HOME>/server/<CONFIGURATION>/deploy/jbossweb.sar/server.xml 파일 <Server>... 생략 <Service name="jboss.web"> <Connector protocol="http/1.1" port="8080" address="${jboss.bind.address}" connectiontimeout="20000" redirectport="8443" /> <Connector protocol="ajp/1.3" port="8009" address="${jboss.bind.address}" redirectport="8443" /> <Engine name="jboss.web" defaulthost="localhost" jvmroute="node1">... 생략 </Engine> </Service> </Server> jvmroute 는 mod_jk 가 HttpSession 을정상적으로처리할수있도록하는설정으로써설정하지않으면세션생성후다른 JBoss 로요청이전달되어세션유지에문제가발생함

JBoss 의 usejk 설정하기 <JBOSS_HOME>/server/<CONFIGURATION>/deployers/jboss web.deployer/meta-inf/war-deployers-jboss-beans.xml 파일 <deployment xmlns="urn:jboss:bean-deployer:2.0">... 생략 <bean name="webappclusteringdefaultsdeployer" class="org.jboss.web.tomcat.service.deployers.clusteringdefaultsdeployer">... 생략 <property name="usejk">true</property> <!-- <property name="usesessionpassivation">false</property> <property name="passivationmaxidletime">-1</property> <property name="passivationminidletime">-1</property> -->... 생략 <property name="maxunreplicatedinterval">60</property> </bean>... 생략 usejk를설정하지않으면 mod_jk가정상적으로 </deployment> 동작하지않으므로반드시설정해야함

연동테스트 URI Worker Mapping 에있는 URI 를요청한경우 /jmx-console/*=loadbalancer /jmx-console=loadbalancer

연동테스트 URI Worker Mapping 에없는 URI 를요청한경우 /helloworld/*=loadbalancer /helloworld=loadbalancer

연동테스트 URI Worker Mapping 에있는 URI 를요청했지만 JBoss 에서처리할수없는경우 /helloworld/*=loadbalancer /helloworld=loadbalancer

연동테스트 JBoss 에서장애가발생하여 shutdown 된경우 "500 Internal Server Error or "503 Service Unavailable"

Sticky Session 과세션추적 상태를유지하지않는 HTTP 요청의경우 Apache HTTP Server 는 Round Robin 으로로드밸런싱

Sticky Session 과세션추적 상태를유지하는요청의경우 Round Robin 으로처리하면세션이존재하지않으므로문제가발생

Sticky Session 과세션추적 상태를유지하는 HTTP 요청의경우특별한처리가필요하다. Sticky Session

Sticky Session 과세션추적 사용자가로그인을하여 HttpSession 이생성된경우웹브라우저는쿠키및 session id 로세션을유지 Apache HTTP Server 의 mod_jk 는세션이만들어진서버로요청을처리할수있도록 (sticky session) JBoss 로요청을전달 하나이상의 JBoss 가웹서버와연결되어있다면 round robin 으로전달하는경우세션이분실된다!! jvmroute, usejk 은 sticky session 이제대로동작하기위해서필요한필수옵션 첫번째사용자 - z0fov8evascvu6jpllclxq**.node1 두번째사용자 - Q1tDFMtcneh-cvf4GScuxw**.node2 세번째사용자 - M3RIwe4JOFCcPQnbYHBh7w**.node3

mod_jk 의 failover Apache HTTP Server 는 HTTP 요청을적절하게 Round Robin 으로로드밸런싱을수행

mod_jk 의 failover Round Robin 으로로드밸런싱중 JBoss1 노드에장애가발생하면 JBoss2 로 failover

mod_jk 의 failover Apache HTTP Server 가 HTTP 요청을처리하던도중 JBoss 가갑자기 shutdown 되고장애를미처감지하지못한경우해당요청은처리실패

mod_jk 의 failover 갑작스런 JBoss 의장애가발생하는경우 Apache HTTP Server 는클라이언트로다음의에러를전달

mod_jk 의 failover Sticky Session 으로동작하는경우세션이생성된 JBoss 가 shutdown 되어 failover 하더라도세션이존재하지않게됨 Clustering 필요!!

URI Worker Mapping 작성패턴 구분 작성형식 주석 공백 URI 패턴 URI 패턴 형식 /myapp=myworker # 주석예제입니다. /myapp=myworker /myapp=myworker /myapp=myworker /myapp = myworker # URI /myapp1 와 /myapp1/ 밑의모든내용을매핑합니다 : /myapp1=myworker-a /myapp1/*=myworker-a #.jsp, *.do 로끝나는모든 URI 를매핑합니다 : *.jsp=myworker *.do=myworker # URI /myapp1 와 /myapp1/ 밑의모든내용을매핑합니다 : /myapp1 /*=myworker-a 설명 이파일은기본으로라인단위형식으로작성해야합니다. 한라인에각각의규칙을기술합니다. 각각의규칙은 URI 패턴과 worker 의이름의쌍으로구성되며 '=' 으로결합합니다. URI 패턴은대소문자를구분합니다. '#' 을포함하면주석으로처리하고무시합니다. URI 패턴의앞, 뒤로오는공백문자는 trim 처리합니다. Worker 의이름앞, 뒤로오는공백문자는 trim 처리합니다. URI 패턴에는 '*', '?', ' ' 을사용할수있습니다. '*' 은길이에제한이없는어떤문자라도일치를시킬때사용하는패턴입니다. '?' 은정확하게한개의문자를일치시킬때사용하는패턴입니다. ' ' 은줄여서쓰기위한패턴으로 'X Y' 는 'X', 'XY' 와동일하게사용합니다. 각각의 URI 패턴은 '/', '*', '?' 으로시작하며 ' ' 와 '-' 을조합할수있습니다. ' ' 은줄여서쓰기위한패턴으로 'X Y' 는 'X', 'XY' 와동일하게사용합니다. 이예제의경우 /myapp1 와 /myapp1/* 패턴을줄여쓴것입니다.

URI Worker Mapping 작성패턴 # URI /myapp1 와 /myapp1/ 밑의모든내용을매핑합니다 : /myapp /*=myworker # static 디렉토리는적용하지않습니다 :!/myapp/static /*=myworker # 다음의확장자를가진 URI 패턴을모든 worker 에적용하지않습니다 :!*.html=myworker # /myapp1 와 /myapp2 을매핑합니다 : /myapp1 /*=myworker1 /myapp2 /*=myworker2 # 모든 worker 에 static 디렉토리를적용하지않습니다 :!/*/static /*=* # 다음의확장자를가진 URI 패턴을모든 worker 에적용하지않습니다 :!*.html=*

mod_jk 와 mod_cluster mod_jk의경우동적으로 load balancing factor를변경하기어렵고또한 AJP Connector를사용하는문제가있음 mod_cluster(http://www.jboss.org/mod_cluster) 는 JBoss에서진행하는프로젝트로써 mod_jk의단점을보완한 Apache HTTP Server Module 장점 동적인 HTTP Worker 설정 서버측에서부하분산팩터를계산 정밀한웹애플리케이션생명주기제어 AJP 는옵션 설명 mod_jk 의경우 Worker 의개수를직접지정해야하지만 mod_cluster 는서버측의상태에따라서동적으로설정됨. mod_cluster 의경우 advertise mechanism 에따라서 proxy 가자동으로설정함. 애플리케이션서버는서버의종료 / 시작등의이벤트를 proxy 로전달함으로써좀더효율적으로자동설정이가능해짐. mod_jk 의경우부하분산팩터는 mod_jk 가가지고있지만 mod_cluster 는서버측에서결정함. 그래서견고하고정밀한제어가가능해짐 서버측에서애플리케이션이 undeploy 되면기존의 mod_jk 는서버가죽은건지, 애플리케이션이 undeploy 된것인지알지못하므로 404 에러를표현하지만 mod_cluster 는애플리케이션의생명주기에대한정보를알고있으므로해당노드로요청을전달하지않음 mod_jk 는 AJP 를이용하지만 mod_cluster 는 HTTP, AJP, HTTPS 를모두사용

Clustering 엔터프라이즈애플리케이션은높은가용성과확장성을보장해야함 운영중인환경에서도동적으로 JBoss Instance를추가하여확장가능해야함 장애가발생하더라도서비스는지속적으로제공되어야함 Clustering은확장성 (Scalability), 고가용성 (High Availability) 를보장하는기술 Clustering의핵심기술 Failover 장애발생시다른노드로요청을처리 Load Balancing 특정노드로부하가집중되는것을방지하고부하를다수의노드로분산

클러스터링시스템구축구성도 Web Server Failover Application Server Failover Database Failover Load Balancing JBoss AS (1) Load Balancing Apache HTTP (1) JBoss AS (2) Oracle 10g RAC (1) Database Clustering Client L4 Switch (Load Balancing) Load Balancing JBoss AS (3) Apache HTTP (2) Oracle 10g RAC (2) JBoss AS (4) DMZ Inner Network

클러스터의정의 모든노드는동일한 Partition Name을가져야한다. 모든노드는멀티캐스트통신이가능해야한다. JBoss의 all configuration으로구동해야한다.

Server Architecture Client Side Interceptor Client-Side Interceptor JBoss의 Clustering 구현기술중에하나로클라이언트측에서노드의장애를감지하여 failover를제공 EJB, JMS, HA-JNDI 등등

Server Architecture Load Balancer Firewall Firewall

Server Architecture Load Balancer L4 Switch와 Apache HTTP Server 간 Load Balancing Apache HTTP Server와 JBoss간 Load Balancing mod_jk 는 HTTP 요청을적절하게 JBoss 로 load balancing 정책 Request Session Traffic Busyness 설명요청의수를기준으로부하를분배하는정책세션의수를기준으로부하를분배하는정책네트워크트래픽을기준으로부하를분배하는정책부하가적은 worker를기준으로부하를분배하는정책 JBoss 내부의 Load Balancing 정책 RoundRobin RandomRobin FirstAvailable FirstAvailableIde nticalallproxies 설명 이방식은 round robin 방식으로부하를분배합니다. 첫번째노드는임의적으로선택합니다. 임의적으로노드를선택하여부하를분배합니다. 이방식은 sticky session 처럼최초선택한노드로부하를분배하며장애가발생하여해당노드를사용할수없는경우다른노드를랜덤하게선택합니다. FirstAvailable 과동일하게동작하지만동일 JVM 의 proxy 또는 stub 을공유합니다. 예를들어동일 EJB 에대해서서로다른 stub 을얻더라도서로다른 EJB 를호출하는것이아니라같은 EJB 를호출합니다.

HA-JNDI JNDI Lookup 에대한 failover 지원 JNDI 서비스자체에대한 failover 를지원함으로써리모트클라이언트의안정적인 JNDI lookup 이가능하도록함 JNDI Lookup 에대한 load balancing 지원 멀티캐스트를이용한 HA-JNDI 서비스의자동탐색 멀티캐스트를이용하면 JNDI 서비스를클라이언트에서자동으로탐색하여사용 클러스터링되어있는 JBoss 의 JNDI 트리의통합뷰 HA-JNDI 와 Local JNDI 가통합되어하나의뷰로보임 HA-JNDI 로 lookup 하는경우 Local JNDI 도 lookup HA-JNDI 사용조건 : all configuration 으로구동

HA-JNDI

HA-JNDI 서비스설정파일 <JBOSS_HOME>/server/all/deploy/cluster/hajndijboss-beans.xml 파일 <deployment xmlns="urn:jboss:bean-deployer:2.0"> <bean name="hajndi" class="org.jboss.ha.jndi.hanamingservice"> <depends>jboss:service=naming</depends>... 생략 <!-- Handler for the replicated tree --> <property name="distributedtreemanager"> <bean class="org.jboss.ha.jndi.impl.jbc.jbosscachedistributedtreemanager"> <property name="clusteredcache"> <inject bean="hapartitioncachehandler" property="cache"/> </property> </bean> </property> <!-- The thread pool used to control the bootstrap and auto discovery lookups --> <property name="lookuppool"> <inject bean="jboss.system:service=threadpool"/> </property>... 생략 </bean> </deployment>

HA-JNDI 의 Failover

HA-JNDI 의 Load Balancing <JBOSS_HOME>/server/all/deploy/cluster/hajndijboss-beans.xml 파일 <deployment xmlns="urn:jboss:bean-deployer:2.0"> <bean name="hajndi" class="org.jboss.ha.jndi.hanamingservice">... 생략 <depends>jboss:service=naming</depends>... 생략 <property name="discoverydisabled">false</property> <property name="autodiscoverybindaddress">${jboss.bind.address}</property> <property name="autodiscoveryaddress"> ${jboss.partition.udpgroup:230.0.0.4} </property> <property name="autodiscoverygroup">1102</property> <property name="autodiscoveryttl">16</property> <property name="loadbalancepolicy"> org.jboss.ha.framework.interfaces.roundrobin </property> </bean> </deployment>

HA-JNDI 의 InitialContext JBoss 내부클라이언트가 HA-JNDI 를이용하는경우 Properties p = new Properties(); p.put(context.initial_context_factory, "org.jnp.interfaces.namingcontextfactory"); p.put(context.url_pkg_prefixes, "jboss.naming:org.jnp.interfaces"); p.put(context.provider_url, "localhost:1100"); // HA-JNDI port Context context = new InitialContext(p); HelloWorld helloworld = (HelloWorld) context.lookup( HelloWorldBean/remote ); JBoss 외부클라이언트가 HA-JNDI 를이용하는경우 Properties p = new Properties(); p.put(context.initial_context_factory, "org.jnp.interfaces.namingcontextfactory"); p.put(context.url_pkg_prefixes, "jboss.naming:org.jnp.interfaces"); p.put(context.provider_url, "server1:1100,server2:1100,server3:1100 ); // HA-JNDI port Context context = new InitialContext(p); HelloWorld helloworld = (HelloWorld) context.lookup( HelloWorldBean/remote );

Spring Framework 에서 HA-JNDI <beans> <bean id="helloworld" class="org.springframework.jndi.jndiobjectfactorybean"> <property name="jndiname" value="helloworldbean/remote"/> <property name="lookuponstartup" value="false"/> <property name="cache" value="true"/> <property name="proxyinterface" value="com.jbossug.jboss.example.clustering.hajndi.helloworld"/> <property name="jnditemplate" ref="jnditemplate"/> </bean> <bean id="jnditemplate" class="org.springframework.jndi.jnditemplate"> <property name="environment"> <bean class="org.springframework.beans.factory.config.propertiesfactorybean"> <property name="properties"> <value> java.naming.factory.initial=org.jnp.interfaces.namingcontextfactory java.naming.provider.url=jnp://localhost:1100 </value> </property> </bean> </property> </bean> </beans>

HA-JNDI 와 EJB Stub Caching 그리고 Failover EJB 의 Stub 을 1 회 lookup 하고계속호출하는경우 (Caching) public class HelloWorldBeanHAClient { public static void main(string[] args) throws NamingException { String[] urls = new String[]{"192.168.0.1:1100", "192.168.0.2:1100"}; Context context = JndiUtils.getRemoteHAJNDIContext(urls); HelloWorld helloworld = (HelloWorld) context.lookup("helloworldbean/remote"); for (int index = 0; index < 1000; index++) { try { Thread.sleep(200); } catch (InterruptedException e) { } } } } try { System.out.println(index + ": " + helloworld.sayhello("ha-jndi")); } catch (Exception ex) { // 아무일도안함. }

HA-JNDI 와 EJB Stub Caching 그리고 Failover Client 가 EJB Stub 을얻고난후캐슁해서사용하는경우 HelloWorldBean HelloWorldBean JBoss Node1 JBoss Node1 Client Client JBoss Node2 JBoss Node2

HA-JNDI 와 EJB Stub Caching 그리고 Failover JBoss Node1 에서장애가발생하더라도 EJB Client 는계속커넥션을연결되어있는상태로인지하고 hang 발생 "main" prio=6 tid=0x0003c2d8 nid=0x1f94 runnable [0x0007f000..0x0007fc3c] at java.net.plainsocketimpl.socketconnect(native Method) at java.net.plainsocketimpl.doconnect(plainsocketimpl.java:333) - locked <0x02bba410> (a java.net.sockssocketimpl) at java.net.plainsocketimpl.connecttoaddress(plainsocketimpl.java:195) at java.net.plainsocketimpl.connect(plainsocketimpl.java:182) at java.net.sockssocketimpl.connect(sockssocketimpl.java:366) at java.net.socket.connect(socket.java:520) at org.jboss.remoting.util.securityutility.connect(securityutility.java:1037)... 생략 at $Proxy4.invoke(Unknown Source)... 생략 }

HA-JNDI 와 EJB Stub Caching 그리고 Failover EJB Stub 을호출시마다 lookup 형태로변경 (Non- Caching) public class HelloWorldBeanHAClient { public static void main(string[] args) throws NamingException { String[] urls = new String[]{"192.168.0.1:1100", "192.168.0.2:1100"}; Context context = JndiUtils.getRemoteHAJNDIContext(urls); for (int index = 0; index < 1000; index++) { HelloWorld helloworld = (HelloWorld) context.lookup("helloworldbean/remote"); try { Thread.sleep(200); } catch (InterruptedException e) { } try { System.out.println(index + ": " + helloworld.sayhello("ha-jndi")); } catch (Exception ex) { // 아무일도안함. } } } }

HA-JNDI 와 EJB Stub Caching 그리고 Failover HelloWorldBean JBoss Node1 HA-JNDI를이용하여호출시마다 JNDI lookup을하게되면노드에장애가발생하더라도 HA-JNDI는다른노드에서 JNDI lookup을시도 Client JBoss Node2 HelloWorldBean JBoss Node1 Client JBoss Node2

HA-JMS JMS(JavaMessage Service) 는비동기메시징표준 API 엔터프라이즈애플리케이션구축시비동기메시징이필요하다면 JMS 는꼭필요한기술 따라서고가용성을위한 JMS 의클러스터링은반드시필요 Failover 특정노드에서메시지송수신중장애발생시다른노드로 failover Load Balancing 메시지를다수의노드로분산 메시지수신자가메시지수신이늦는경우좀더빨리메시지는수신하는수신자로메시지를처리

HA-JMS 메시지송신 jnp://192.168.0.3:1100 Message Producer JBoss Node1 메시지라우팅 Cluster Partition JBoss Node4 JBoss Node2 jnp://192.168.0.9:1100 jnp://192.168.0.5:1100 메시지수신 JBoss Node3 jnp://192.168.0.7:1100 Message Consumer

HA-JMS HA-JMS 를사용하려면? JBoss Messaging의 Server Peer ID를노드별로유일하게설정 JBoss의 all configuration으로구동 동일한 partition name으로설정 #cd <JBOSS_HOME>/bin #run.sh -c all -b 192.168.0.7 -Dnode0 -Djboss.messaging.ServerPeerID=0 -g HATestPartition #cd <JBOSS_HOME>/bin #run.sh -c all -b 192.168.0.7 -Dnode1 -Djboss.messaging.ServerPeerID=1 -g HATestPartition

HA-JMS JBoss 의기본 Connection Factory 클러스터링 로드밸런싱 JNDI Name 설명 Failover 및로드밸런싱을 X X /ConnectionFactory /XAConnectionFactory java:/connectionfactory java:/xaconnectionfactory 지원하지않습니다. EJB Message-Driven Bean은자체적으로로드밸런싱메커니즘을지원하므로이 ConnectionFactory를 사용합니다. O O /ClusteredConnectionFactory /ClusteredXAConnectionFactory java:/clusteredconnectionfactory java:/clusteredxaconnectionfactory Failover 및로드밸런싱을지원합니다. 하지만 EJB Message-Driven Bean에서는이 ConnectionFactory를사용하지않습니다.

HA-JMS Clustering 을지원하는 JMS 의 Destination <JBOSS_HOME>/server/all/deploy/messaging/destinationsservice.xml 파일 <server>... 생략 <mbean code="org.jboss.jms.server.destination.queueservice" name="jboss.messaging.destination:service=queue,name=testqueue" xmbean-dd="xmdesc/queue-xmbean.xml">... 생략 <depends optional-attribute-name="serverpeer"> jboss.messaging:service=serverpeer </depends> <depends>jboss.messaging:service=postoffice</depends> <attribute name="clustered">true</attribute> </mbean> </server>

HA-JMS HA-JMS 의 Failover

HA-JMS HA-JMS 의메시지분산과 Sucker Connection

클러스터링시스템구축 Server Configuration 구성하기 장비에하나의 JBoss Instance 를구동하는경우 all configuration 으로구동 장비에다수의 JBoss Instance 를구동하는경우 클러스터링을지원하는 all configuration 을복사하여다수의 configuration 을구성 변경전 <JBOSS_HOME>/server/all <JBOSS_HOME>/server/default <JBOSS_HOME>/server/minimal <JBOSS_HOME>/server/standard <JBOSS_HOME>/server/web 변경후 <JBOSS_HOME>/server/all <JBOSS_HOME>/server/cluster1 <JBOSS_HOME>/server/cluster2 <JBOSS_HOME>/server/default <JBOSS_HOME>/server/minimal <JBOSS_HOME>/server/standard <JBOSS_HOME>/server/web

클러스터링시스템구축 시작스크립트작성하기 노드명 192.168.0.1 Cluster1 시작스크립트 (<JBOSS_HOME>/bin/start_cluster1.sh) #!/bin/sh nohup run_cluster1.sh -c cluster1 -b 192.168.0.1 -g JBoss5Partition -Djboss.messaging.ServerPeerID=1 2>&1 & Binding IP Address를지정할것 ( 미지정시 127.0.0.1) Partition Name을지정할것 ( 미지정시 DefaultPartition) JBoss Messaging의 Server Peer ID를지정할것 ( 미지정시 0)

클러스터링시스템구축 4 대의장비에각각한개의노드를구성하는경우 IP 주소 스크립트파일 항목 값 192.168.0.1 <JBOSS_HOME>/bin/start_cluster1.sh -b jboss.messagging.serverpeerid 192.168.0.1 1 <JBOSS_HOME>/bin/stop_cluster1.sh -s 192.168.0.1:1100 192.168.0.3 <JBOSS_HOME>/bin/start_cluster1.sh -b jboss.messagging.serverpeerid 192.168.0.3 3 <JBOSS_HOME>/bin/stop_cluster1.sh -s 192.168.0.3:1100 192.168.0.5 <JBOSS_HOME>/bin/start_cluster1.sh -b jboss.messagging.serverpeerid 192.168.0.5 5 <JBOSS_HOME>/bin/stop_cluster1.sh -s 192.168.0.5:1100 192.168.0.7 <JBOSS_HOME>/bin/start_cluster1.sh -b jboss.messagging.serverpeerid 192.168.0.7 7 <JBOSS_HOME>/bin/stop_cluster1.sh -s 192.168.0.7:1100

클러스터링시스템구축 Service Binding Manager 하나의물리장비에다수의 JBoss Instance 를구동하는경우포트충돌발생 Service Binding Manager 는서비스의포트를구동시변경시켜주어충돌을방지 포트를일괄적으로변경하기위해서 increment value 가사전에정의 (binding set) ports-default, ports-01(100), ports-02(200), ports-03(300) 8080, 8180, 8280, 8380 Binding Set 은 <JBOSS_HOME>/server/all/conf/bindings.xml 파일에정의 시작스크립트를통해 binding set 을지정

클러스터링시스템구축 시작스크립트에 Binding Set 지정하기 노드명 #!/bin/sh 시작스크립트 (<JBOSS_HOME>/bin/start_clusterX.sh) 192.168.0.1 Cluster1 nohup run_cluster1.sh -c cluster1 -b 192.168.0.1 -g JBoss5Partition -Djboss.messaging.ServerPeerID=1 -Djboss.service.binding.set=ports-01 2>&1 & #!/bin/sh 192.168.0.1 Cluster2 nohup run_cluster2.sh -c cluster1 -b 192.168.0.1 -g JBoss5Partition -Djboss.messaging.ServerPeerID=2 -Djboss.service.binding.set=ports-02 2>&1 &

클러스터링시스템구축 시작스크립트에 Binding Set 지정하기 동일한장비에다수의 JBoss Instance 에 binding set 을적용하면포트는일괄적으로변경됨 IP 주소 노드명 서비스 사용예 변경전 포트 변경후 JNDI jnp://192.168.0.1:1199 1099 1199 cluster1 (ports-01) HA-JNDI HTTP jnp://192.168.0.1:1200 http://192.168.0.1:8180 1100 8080 1200 8180 192.168.0.1 AJP JNDI 웹서버통합시사용 jnp://192.168.0.1:1299 8009 1099 8109 1299 cluster2 (ports-02) HA-JNDI HTTP jnp://192.168.0.1:1300 http://192.168.0.1:8280 1100 8080 1300 8280 AJP 웹서버통합시사용 8009 8209

실습전준비사항 Apache HTTP Server 다운로드 Mod_JK 다운로드 JBossAS 5.0.0.GA 다운로드 JDK 1.5.0 다운로드

EJB Clustering Stateless Session Bean - 로드밸런싱 Stateful Session Bean - 세션복제및분산캐쉬 Session 에대한 Buddy Replication Message-Driven Bean - 로드밸런싱 Entity - 분산캐슁 JBoss Cache 를이용한분상캐슁

EJB Clustering Stateless Session Bean 의 Instance Pool

EJB Clustering Stateless Session Bean 의 Load Balancing

EJB Clustering Stateless Session Bean 의 Clustering 은 @Clustered annotation import org.jboss.ejb3.annotation.clustered; import javax.ejb.stateless; @Stateless @Clustered // Annotation for EJB Clustering public class ClusteredHelloWorldBean implements ClusteredHelloWorld { public String sayhello(string name) { String message = "Hello " + name + " ==> [" + tostring() + "]"; System.out.println(message); return message; } } public @interface Clustered { java.lang.string loadbalancepolicy() default "LoadBalancePolicy"; java.lang.string homeloadbalancepolicy() default "LoadBalancePolicy"; // for EJB2 java.lang.string partition() default "${jboss.partition.name:defaultpartition}"; }

EJB Clustering Stateless Session Bean 의 Load Balancing Policy 로드밸런싱정책 RoundRobin RandomRobin FirstAvailable 설명이방식은 EJB 호출시 smart proxy가 round robin 방식으로호출합니다. 이방식은 EJB 호출시 smart proxy가임의적으로노드를선택하여호출합니다. 이방식은 sticky session 처럼한번선택한노드로 EJB 호출을하는방식입니다. 장애가발생하여해당노드를사용할수없는경우다른노드를랜덤하게선택합니다. 이방식은 proxy를공유하지않습니다. @Stateless @Clustered(loadBalancePolicy = "FirstAvailable") // Load Balancing Policy public class ClusteredHelloWorldBean implements ClusteredHelloWorld { public String sayhello(string name) { String message = "Hello " + name + " ==> [" + tostring() + "]"; System.out.println(message); return message; } }

EJB Clustering Stateful Session Bean 의 Instance Cache

EJB Clustering Stateful Session Bean 의 Activation/Passivation

EJB Clustering Stateful Session Bean 의 Session Replication Buddy Replication Load Balancing EJB Client invocation Smart Proxy for EJB Remote Interface creation & invocation JBoss Node1 Cluster Partition JBoss Node4 JBoss Node2 JBoss Node3

EJB Clustering Stateful Session Bean 의 Clustering @Stateful @Clustered // Annotation for EJB Clustering @CacheConfig(maxSize = 5000, removaltimeoutseconds = 18000) public class StatefulBean implements StatefulBeanRemote { private int state = 0; // Stateful Session Bean 의상태 } public void increment() { System.out.println("counter: " + (state++)); } public @interface CacheConfig { String name() default "jboss.cache:service=ejb3sfsbclusteredcache"; int maxsize() default 10000; long idletimeoutseconds() default 300; long removaltimeoutseconds() default 0; boolean replicationispassivation() default true; }

EJB Clustering JPA(Java Persistence API) Entity 의 Clustering @Entity @Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL) public class Account implements Serializable { @Id private String username; private String password; }... 생략

EJB Clustering JPA(Java Persistence API) Entity 의 Clustering public @interface Cache { CacheConcurrencyStrategy usage(); // Caching Strategy String region() default ""; // Caching Region (optional) String include() default "all"; // Property to cache (optional) } public enum CacheConcurrencyStrategy { NONE, READ_ONLY, // never update NONSTRICT_READ_WRITE, // update without locking (asynchronous) READ_WRITE, // update with distributed hard locking (asynchronous) TRANSACTIONAL // fully transactional cache (synchronous) }

EJB Clustering JPA(Java Persistence API) Entity 의 Clustering EJBJAR#META-INF/persistence.xml 파일 <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0"> <persistence-unit name="testpu " transaction-type="jta"> <jta-data-source>java:/defaultds</jta-data-source> <properties> Entity 의 2 차캐쉬 <property name="hibernate.cache.use_second_level_cache" value="true"/> <property name="hibernate.cache.use_query_cache" value="true"/> <property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.jbc2.jndimultiplexedjbosscacheregionfactory"/> <property name="hibernate.cache.region.jbc2.cachefactory" value="java:cachemanager"/> <property name="hibernate.cache.region.jbc2.cfg.entity" value="mvcc-entity"/> <property name="hibernate.cache.region.jbc2.cfg.query" value="local-query"/> </properties> </persistence-unit> </persistence>