본문으로 건너뛰기

21.4 JBoss EWS 2 설치

JBoss EWS 2를 설치하고 mod_jkmod_cluster를 설정하는 방법에 대해서는 이미 ‘16장. JBoss EAP 6 클러스터링’에서 설명하였다. 여기에서는 간단한 절차만 설명하고, 자세한 내용은 16장을 참고하라.

필요 패키지 설치

웹 서버 설치에 필요한 패키지를 설치한다.

$ sudo yum install nss elinks apr-devel apr-util-devel krb5-workstation mod_auth_kerb

EWS 설치

다음과 같은 디렉터리에 설치한다.

구분디렉터리명설명
제품설치 디렉터리/svc/test/web/jboss-ews-2.0JBoss EAP 6를 설치할 디렉터리이다.
로그 디렉터리/logs/web/로그 파일들을 저장할 디렉터리이다.

다음과 같이 설치한다.

$ sudo mkdir -p /svc/test/web

$ cd /svc/test/web

$ cp ~jboss/jboss-ews-httpd-2.0.1-RHEL6-x86_64.zip .

$ unzip jboss-ews-httpd-2.0.1-RHEL6-x86_64.zip

$ cd /svc/test/web/jboss-ews-2.0/httpd

$ ./.postinstall

로그 디렉터리를 만든다.

$ mkdir -p /logs/web

JBoss EWS설정

Apache 웹 서버는 1.x 버전에서는 차일드 프로세스를 미리 만들어 놓는 prefork 방식을 사용하였고, 2.x 버전부터 스레드를 사용하는 worker 방식을 사용할 수 있다. 이것을 MPM(Multi-Processing Module)이라고 한다. 이 방식을 사용하면 더 적은 리소스를 사용하여 더 많은 처리를 할 수 있다. 두 방식의 차이점에 대해서는 ‘19장 JBoss EAP 6 튜닝’에서 자세히 설명하고 있다.

JBoss EWS 2에서는 미리 컴파일한 worker 모듈과 prefork 모듈, event 방식의 모듈을 제공한다. 기본값은 prefork 모듈이다. 성능과 안정성을 위해서 다음과 같이 worker 모듈로 변경한다.

$ cd /svc/test/web/jboss-ews-2.0/httpd/sbin

$ mv httpd httpd.prefork

$ cp httpd.worker httpd

worker 방식으로 변경되었는지 httpd -l 옵션으로 worker.c가 출력되는지 확인한다.

$ ./httpd -l
Compiled in modules:
core.c
worker.c
http_core.c
mod_so.c

웹 브라우저와 웹 서버 간의 소켓 연결도 매번 연결하고 끊는 것을 반복하면 성능이 떨어질 수밖에 없다. 하나의 웹 페이지를 구성하는 수 십여 개의 이미지, css, js와 같은 정적 콘텐츠들을 가져오기 위해 매 요청마다 연결을 맺고 끊지 않도록 KeepAliveOn으로 설정하면 성능이 향상된다.

worker 모듈에 대해서도 상세한 튜닝이 필요하겠지만, 다음과 같이 웹 서버가 제공하는 기본값보다 더 많은 요청을 동시에 처리할 수 있도록 httpd.conf 파일의 <IfModule worker.c> 부분을 설정한다. ServerLimit나 스레드 개수에 대한 계산 방법을 ‘20장. JBoss EAP 6 튜닝’에서 설명하고 있으니 참고하라.

$ vi /svc/test/web/jboss-ews-2.0/httpd/conf/httpd.conf
… 생략 …

#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive On
#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 1000
# worker MPM
# StartServers: initial number of server processes to start
# MaxClients: maximum number of simultaneous client connections
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadsPerChild: constant number of worker threads in each server process
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule worker.c>
StartServers 3
ServerLimit 64
MaxClients 4096
ThreadLimit 4096
MinSpareThreads 512
MaxSpareThreads 1024
ThreadsPerChild 64
MaxRequestsPerChild 10000
</IfModule>

ListenBackLog 1000
#
# ExtendedStatus controls whether Apache will generate "full" status
# information (ExtendedStatus On) or just basic information (ExtendedStatus
# Off) when the "server-status" handler is called. The default is Off.
#
ExtendedStatus On
… 생략 …

mod_jk 설정방법

mod_jk를 설정하려면 네이티브 커넥터를 다운로드 받아 설치하여야 한다. 다운로드 URL 및 자세한 설치 방법은 ’16장. JBoss EAP 6 클러스터링’의 ‘6. mod_jk 커넥터’을 참고하라.

JBoss가 설치된 머신 WAS01 머신에서 모듈을 설치하고 웹 서버로 복사한다. mod_jk.so 파일을 웹 서버의 modules 디렉터리로 복사한다. 여기서는 scp 명령을 이용하여 복사하였다.

$ cd /svc/test/was

$ cp ~jboss/jboss-eap-native-webserver-connectors-6.2.0-RHEL6-x86_64.zip .

$ unzip jboss-eap-native-webserver-connectors-6.2.0-RHEL6-x86_64.zip

$ cd jboss-eap-6.2/modules/system/layers/base/native/lib64/httpd/modules/

$ scp *.so root@192.168.0.201: /svc/test/web/jboss-ews-2.0/httpd/modules/

mod_cluster를 사용하려면 설정방법은 ‘16장. JBoss EAP 6 클러스터링’의 ‘7. mod_cluster 커넥터’를 참고하라.

다음과 같이 mod_jk.conf 파일을 작성한다. JkMountjsp, do, mvc로 끝나는 URL들을 로드 밸런서로 포워딩하도록 설정되어 있다.

$ sudo vi /svc/test/web/jboss-ews-2.0/httpd/conf.d/mod_jk.conf

파일의 내용은 다음과 같다.

# Load mod_jk module
# Update this path to match your modules location
LoadModule jk_module modules/mod_jk.so
# Where to find workers.properties
# Update this path to match your conf directory location (put workers.properties next to httpd.conf)
JkWorkersFile conf.d/workers.properties
# Where to put jk logs
# Update this path to match your logs directory location (put mod_jk.log next to access_log)
JkLogFile /logs/web/mod_jk.log
JkShmFile /logs/web/mod_jk.shm
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories +ForwardURICompatUnparsed
# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"
# Send everything for context /examples to worker named worker1 (ajp13)
JkMount /*.jsp lb
JkMount /*.do lb
JkMount /*.mvc lb
JkMount /jkstatus* jkstatus
# Add jkstatus for managing runtime data
<Location /jkstatus>
JkMount jkstatus
Order Deny,Allow
Allow from 127.0.0.1
Allow from 192
Allow from 10
Deny from all
</Location>

다음과 같이 workers.properties 파일을 작성한다. worker.template로 시작하는 설정은 모든 워커에 공통으로 적용되는 속성이다. woker.server11에서 server11worker의 이름이며 이 이름은 JBoss EAP 6의 instance-id로 설정한 이름과 같아야 한다.

$ sudo vi /svc/test/web/jboss-ews-2.0/httpd/conf.d/workers.properties

파일의 내용은 다음과 같다.

#
# This Configuration file is generated by KHAN [provisioning]
#
worker.list=lb,jkstatus

# Templates
worker.template.type=ajp13
worker.template.maintain=60
worker.template.lbfactor=1
worker.template.ping_mode=A
worker.template.ping_timeout=2000
worker.template.prepost_timeout=2000
worker.template.socket_timeout=60
worker.template.socket_connect_timeout=2000
worker.template.socket_keepalive=true
worker.template.connection_pool_timeout=60
worker.template.connect_timeout=10000
worker.template.recovery_options=7

worker.server11.reference=worker.template
worker.server11.host=192.168.0.101
worker.server11.port=8109
worker.server12.reference=worker.template
worker.server12.host=192.168.0.101
worker.server12.port=8209
worker.server21.reference=worker.template
worker.server21.host=192.168.0.102
worker.server21.port=8109
worker.server22.reference=worker.template
worker.server22.host=192.168.0.102
worker.server22.port=8209

worker.lb.type=lb
worker.lb.balance_workers=server11,server21,server12,server22
worker.lb.method=Session
worker.lb.sticky_session=True
worker.jkstatus.type=status

가상호스트를 사용하는 경우에는 다음과 같이 설정한다. 가상호스트 내에서도 JkMount를 사용하여 포워딩 URL를 지정한다.

$ sudo vi /svc/test/web/jboss-ews-2.0/httpd/conf.d/vhosts.conf

파일의 내용은 다음과 같다.

NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot "/svc/test/web/jboss-ews-2.0/httpd/www/html"
ServerName test.opennaru.com
ErrorLog "/logs/web/test.opennaru.com-error_log"
CustomLog "/logs/web/test.opennaru.com-access_log" common
DirectoryIndex index.html index.jsp
JkMount /*.jsp lb
JkMount /*.do lb
JkMount /*.mvc lb
JkMount /jkstatus* jkstatus
</VirtualHost>

JBoss EWS 2 시작 확인

웹 서버 sbin 디렉터리로 이동한다.

$ cd /svc/test/web/jboss-ews-2.0/httpd/sbin

웹 서버를 시작한다.

$ ./apachectl start

웹 브라우저로 다음 URL에 접속하여 mod_jk 상태를 확인한다.

http://192.168.0.201/jkstatus/

JBoss 인스턴스에 배포된 애플리케이션을 호출한다.

http://192.168.0.201/session/index.jsp

JBoss EWS 2 운영방법

먼저 JBoss EWS 2가 설치된 디렉터리로 이동한다.

$ cd /svc/test/web/jboss-ews-2.0/httpd/sbin

JBoss EWS 2는 80포트를 사용하기 때문에 root 계정으로 관리하여야 한다.

다음과 같이 JBoss EWS 2를 운영할 수 있다.

운영방법설명
$ ./apachectl start인스턴스 시작
$ ./apachectl stop인스턴스 종료
$ ./apachectl restart인스턴스 재시작
$ ./apachectl status인스턴스 수행 중인지 체크
$ ps –ef | grep httpdps 명령으로 인스턴스 프로세스가 있는지 체크
http://192.168.0.201/jkstatus/JkMount 상태 정보로 WAS와 연결상태 확인

표 7. JBoss EWS 2 운영 방법