JBoss Web Management 다우기술김성욱
목차 1. JBoss Web 소개 2. JBoss Web 구성요소 3. Valve 설정 4. 한글처리 5.
3 JBoss Web 소개 JBoss Web Medium & Large application을위한 Enterprise Web Server JBoss EAP 5.1.0 내장 Component 2.1.10.GA version ( based on Tomcat 6 ) 주요기능 JBoss EAP 내에서 Service 형태로작동 ( 서비스명 : jboss.web ) JSP / Servlet Container Java Server Pages 2.1 [JSP-245] 및 Java Servlet 2.5 [JSR-154] Specification 구현 Session 관리, Request Filtering, SSO 등유용한 Apache Tomcat의기능들
4 JBoss Web 구성요소 JBoss Web Architect Overview Server Service Engine Logger Logger Logger Logger Logger Valve Realm Connector Connector Connector Host Logger Logger Logger Logger Logger Valve Realm Context Logger Logger Valve Realm Logger Logger Wrapper
5 JBoss Web 구성요소 JBoss Web Components Component Description 설정변경용도 Server Top Level Element Servlet Container 젂체를의미하며, 하나만존재 거의없음 Service request-processing Engine 과 Connector 들의조합 거의없음 Connector 특정 IP address 와 port 로 binding 하여사용자요청을받는역할 HTTP protocol(8080), AJP protocol(8009) 지원 maxthreads, keepalivetimeout, acceptcount 등변경시 HTTP 와 AJP connector 에서제공하는공통속성과개별속성들을이용하여서비스성능향상도모 Engine Connector 들로부터사용자 request 들을받아서처리 JBoss Web node 들의 Load Balancing 설정시 (jvmroute) Realm 인증및권한설정 Memory, UserDatabase, JDBC, JNDI, JAAS 등지원 인증 Realm 변경시 Host Apache 의 Virtual Host 와비슷한용도 Virtual Host 설정시 Valve 사용자 request 를 intercept 하여 preprocessing 함 Servlet 의 filter mechanism 과비슷 access log 및 log pattern 설정시 현재 Host 의 web-app 들에게 single sign-on 설정시
6 JBoss Web 구성요소 Key Files and Directories File / Directory Description <Profile>/deploy/jbossweb.sar/ JBoss Web Service Archive directory 가장핵심이되는 server configuration file <Profile>/deploy/jbossweb.sar/server.xml HTTP / AJP Connector 설정 Valve 및인증관련설정 <Profile>/deploy/jbossweb.sar/context.xml 각 web application/meta-inf/context.xml 의 Global 설정을담고있는파일 Session, Cookie, Cache 등일반적인속성외에 Request Filter 같은다양한부가기능들을설정 <Profile>/deploy/jbossweb.sar/jsf-libs/ JSF 개발시필요로하는 library 저장 directory <Profile>/deployers/jbossweb.deployer/web.xml 각 web application/web-inf/web.xml 의 Global 설정을담고있는파일
7 Valve 설정 Valve 설정 설정파일 <Profile>/deploy/jbossweb.sar/server.xml Access Log Valve Access Log 생성및 Pattern 등의속성설정 Client Request Client Request Remote Address Valve Client IP address 를기반으로 access control Remote Host Valve Client hostname 을기반으로 access control Request Dumper Valve Request / Response Header 정보 Dump 설정 Single Sign On Valve Host 상의 web application 들에게 SSO 구현설정 Valve WebApp 1 WebApp 2 JBoss Web Log File
8 Valve 설정 Access Log Valve 설정 Access Log 를통하여 Request 내역및처리정보확인가능 <profile>/deploy/jbossweb.sar/server.xml <!-- Access logger --> <Valve classname="org.apache.catalina.valves.accesslogvalve prefix="localhost_access_log." suffix=".log pattern="common" directory="${ jboss.server.log.dir} resolvehosts="false" /> <profile>/log/localhost_access_log.2010-10-28.log 127.0.0.1 - - [28/Oct/2010:10:51:29 +0900] "GET / HTTP/1.1" 200 1421 127.0.0.1 - - [28/Oct/2010:10:51:29 +0900] "GET /css/jboss.css HTTP/1.1" 200 2221 127.0.0.1 - - [28/Oct/2010:10:51:29 +0900] "GET /images/logo.gif HTTP/1.1" 200 1815 127.0.0.1 - - [28/Oct/2010:10:51:29 +0900] "GET /favicon.ico HTTP/1.1" 200 1150
9 Valve 설정 Request Dumper Valve 설정 Request / Response Header Dump Header 와 Cookie 관련 Debugging 시사용가능 <profile>/deploy/jbossweb.sar/server.xml <Valve classname="org.apache.catalina.valves.requestdumpervalve" /> <profile>/log/server.log REQUEST URI =/ characterencoding=null contentlength=-1 contextpath= header=connection=keep-alive header=cache-control=no-cache header=accept=application/xml,application/xhtml+xml,text/html;q=0.9,text /plain;q=0.8,image/png,*/*;q=0.5 header=user-agent=mozilla/5.0 (Windows; U; Windows NT 5.1; en-us) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.41 Safari/534.7 header=accept-language=ko-kr,ko;q=0.8,en-us;q=0.6,en;q=0.4 method=get protocol=http/1.1
10 한글처리 HTTP GET 인코딩 Connector 설정변경 <profile>/deploy/jbossweb.sar/server.xml <!-- HTTP/1.1 Connector on port 8080 --> <Connector protocol="http/1.1" port="8080" address="${ jboss.bind.address} URIEncoding="utf-8" usebodyencodingforuri="true" connectiontimeout="20000" redirectport="8443" /> URIEncoding 해당 Connector 로젂송되는모든 URI 및 Query String 에대해설정된인코딩을적용 Static File 에도적용 기본값은 ISO-8859-1 usebodyencodingforuri URI query parameter 로 HTTP request header 의 Content-Type 에설정된 charset 값을사용할것인지여부를설정 URIEncoding 설정보다우선함 기본값은 false
11 한글처리 HTTP POST 인코딩 Request.setCharacterEncoding() POST 방식에서만유효 Filter 로설정하여매번 setcharacterencoding 을입력하지않도록함 SetCharacterEncodingFilter 의적용 < WEB-INF/web.xml > <filter> <filter-name>setcharacterencodingfilter</filter-name> <filter-class>filters.setcharacterencodingfilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>utf-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>setcharacterencodingfilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
12 Web System Architecture L4 Switch (L4 S/W 이중화 ) Web Server Connector Module ( mod_jk, mod_cluster ) Web Server Connector Module ( mod_jk, mod_cluster ) Apache HTTP Server AJP Connector Servlet Container AJP Connector Servlet Container JBoss Web DBMS (DBMS 이중화 )
13 Apache Tomcat Connector ( mod_jk ) Apache Tomcat 프로젝트의산물 Apache HTTP Server와 Tomcat의 Communication Channel 주요특징 Apache JServ Protocol v13 (AJP13) 프로토콜사용 Connection Pool을이용한 Client Request 관리 여러 Tomcat Server로부하분산기능제공 (lbfactor) Fail-over 및 Fail-back 기능제공 (recovery_options) Client Request의 URI Pattern에따른 Forwarding Rule 설정기능 상태 Monitoring 기능
14 mod_jk 설정 1. mod_jk 다운로드및 Compile Download URL : http://tomcat.apache.org/download-connectors.cgi Compile 압축해제후 native 디렉토리에서아래 command 실행 컴파일이완료되면 $Apache_Home/modules 디렉토리에 mod_jk.so 파일이생성됨 #./confiture --with-apxs=$apache_home/bin/apxs # make # make install 2. JBoss Web 파일설정 각 JBoss Web 의 <Profile>/deploy/jbossweb.sar/server.xml 파일에아래와같이설정 <Engine name="jboss.web" defaulthost="localhost jvmroute= node1 >
15 3. mod_jk 관련파일설정 < conf/httpd.conf > Include conf/mod-jk.conf <Location /jkstatus/> JkMount jkstatus Order deny,allow Deny from all Allow from 172.21.21.142 </Location> < conf/mod-jk.conf > LoadModule jk_module modules/mod_jk.so JkWorkersFile conf/workers.properties JkMountFile conf/uriworkermap.properties JkLogFile logs/mod_jk.log JkLogLevel info JkLogStampFormat "[%a %b %d %H:%M:%S %Y]" JkOptions +ForwardKeySize +ForwardURICompat - ForwardDirectories JkRequestLogFormat "%w %V %T < conf/workers.properties > worker.list=loadbalancer,jkstatus worker.node1.port=8009 worker.node1.host=175.115.93.226 worker.node1.type=ajp13 worker.node1.lbfactor=1 worker.node2.port=8009 worker.node2.host=175.115.93.227 worker.node2.type=ajp13 worker.node2.lbfactor=1 worker.loadbalancer.type=lb worker.loadbalancer.balance_workers=node1,node2 worker.loadbalancer.sticky_session=true worker.jkstatus.type=status < conf/uriworkermap.properties > /*.jsp=loadbalancer!/*.html=loadbalancer /portal/*=loadbalancer
16 JK Status Manager Load Balancing Worker 상태정보 Balancer Members 상태정보
17 mod_jk Tuning 다양한 Test 를통하여환경에맞는 Tuning Point 를확인 AJP Connector 주요 Tuning Point <profile>/deploy/jbossweb.sar/server.xml <!-- AJP 1.3 Connector on port 8009 --> <Connector protocol="ajp/1.3" port="8009" address="${ jboss.bind.address}" redirectport="8443" /> maxthreads : Connector 에서생성되는 request processing thread 의최대값및최대동시처리량을의미. ( default : 200 ) maxpostsize : HTTP POST request size ( default : 2MB ) backlog : 모든 request processing thread 가작동중일경우 connection request 를저장하는 queue lenghth ( defalut : 10 ) connectiontimeout : connection 을수락한후 Request URI 을받을때까지 Connector 가기다리는시갂 ( default : unlimited ) keepalivetimeout : connection 을종료하기젂에또다른 AJP request 를받을때까지 Connector 가기다리는시갂 ( default : connectiontimeout 값 )
18 mod_jk Tuning workers.properties 주요 Tuning Point Connection Directives socket_timeout : JK 에서 Remote Host 로부터의 response 를유지하는시갂 ( default : 0 ) ping_mode, prepost_timeout, connect_timeout : AJP13 의 CPing, CPong packet 을이용하여 back-end 서버가정상적으로 connection 이연결되어서비스하고있는지확인 lbfactor : load balancer 의 member worker 의 request 처리량할당 ( default : 1 ) connection_pool_size : 각웹서버 child process 당 pool 로유지하는 AJP back-end connection 수 Load Balancing Directives method : request 수, session 의개수, network traffic, busyness 등 Load Balancing 수행시최적의 worker 를찾는알고리즘을선택 ( default : Request ) sticky_session : SESSION ID 를포함한 request 를같은 worker 로젂달할건지결정 (default : true ) Advanced Worker Directives recovery_options : 장애발생시처리방식선택 ( 중복선택가능, default 0 )
19 mod_cluster Apache HTTP Server와 Tomcat의 Communication Channel 주요특징 젂통적인 http-based load balancer의단점을보완하기위해서시작한프로젝트 mod_proxy, mod_proxy_ajp 등과함께동작 동적인 HTTP worker 설정및 dynamic discovery에의한 proxy 탐색기능 동적으로 Application Server 를 balance member 로추가가능함 Application Server 에서 load balance fact 를계산하여 proxy 로제공 정교한부하분산기능구현가능 Web application 의 life cycle 을탐지하여부하를우회시키는기능제공 AJP, HTTP, HTTPS protocol 사용가능
20 mod_cluster Requirements httpd-2.2.8+ JBoss EAP 5.x+ or JBossWeb 2.1.1+ 참고 URL Download URL http://www.jboss.org/mod_cluster/downloads/1-1-0.html Documents URL http://docs.jboss.org/mod_cluster/1.1.0/html
21 mod_cluster 설정 ( JBoss EAP 5.1 기준 ) 1. mod_cluster 관련 module 배포 mod_cluster의 Dynamic library를 download 아래의모듈들을 Apache HTTPD의 modules 디렉토리에복사 mod_proxy.so, mod_proxy_ajp.so, mod_slotmem.so, mod_manager.so, mod_proxy_cluster.so mod_advertise.so 2. Apache 의 httpd.conf 파일설정 < conf/httpd.conf > LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_ajp_module modules/mod_proxy_ajp.so LoadModule slotmem_module modules/mod_slotmem.so LoadModule manager_module modules/mod_manager.so LoadModule proxy_cluster_module modules/mod_proxy_cluster.so LoadModule advertise_module modules/mod_advertise.so
22 < conf/httpd.conf > Listen 175.115.93.226:6666 <VirtualHost 175.115.93.226:6666> <Directory /> Order deny,allow Deny from all Allow from all </Directory> <Location /mod_cluster-manager> SetHandler mod_cluster-manager Order deny,allow Deny from all Allow from all </Location> KeepAliveTimeout 60 MaxKeepAliveRequests 0 ManagerBalancerName mycluster AdvertiseFrequency 5 </VirtualHost> ProxyPass / balancer://mycluster/
23 3. JBoss EAP 설정 JBoss Web 의 Listener 추가 <profile>/deploy/jbossweb.sar/server.xml // Non-Cluster Mode <Listener classname="org.jboss.web.tomcat.service.deployers.microcontainerintegrationlifecyclelistener" delegatebeanname="modclusterservice"/> // Cluster Mode <Listener classname="org.jboss.web.tomcat.service.deployers.microcontainerintegrationlifecyclelistener" delegatebeanname="hamodclusterservice"/> mod-cluster 서비스배포및설정 mod_cluster/mod-cluster.sar 를 <profile>/deploy 디렉토리에배포 <profile>/deploy/mod-cluster.sar/meta-inf/mod-cluster-jboss-beans.xml // 필요시 Proxy Server(Apache) List 정보입력 <property name="proxylist">175.115.93.226:6666</property> // Exclude 할 Context 설정 ( exclude 하지않으면해당 context 가서비스안됨 ) <property name="excludedcontexts">${ jboss.modcluster.excludedcontexts:root,admin-console,invoker,jbossws,jmxconsole,juddi,web-console}</property>
24 mod_cluster manager
Thank you.