Middleware/JBoss EAP2019. 7. 26. 20:36

Red Hat Linux 환경에서 JBoss WebServer와 JBoss Application Server의 설치, 구성, 연동 방법에 대해서 정리해 보았습니다.

 

1. 설치 환경 
----------------------------------------------------------------
● Red Hat Enterprise Linux7.5 (64bit)
    rhel-server-7.5-x86_64-dvd.iso
● Oracle JDK 1.8 (64bit)
   jdk-8u144-linux-x64.tar.gz
http://www.oracle.com/technetwork/java/javase/downloads/index.html
● Red Hat JBoss Web Server 3.0.3
   jws-application-servers-3.0.3-RHEL7-x86_64.zip
  jws-httpd-3.0.3-RHEL7-x86_64.zip
 https://access.redhat.com/downloads/


2. JDK 설치
----------------------------------------------------------------
tar -xvzf jdk-7u80-linux-x64.tar.gz
mv jdk1.7.0_80 /usr/java/jdk1.7.0_80

rm -f /usr/java/latest
ln -s /usr/java/jdk1.7.0_80 /usr/java/jdk1.7

alternatives --install /usr/bin/java java /usr/java/jdk1.7/bin/java 10000
alternatives --install /usr/bin/javac javac /usr/java/jdk1.7/bin/javac 10000
alternatives --install /usr/bin/javaws javaws /usr/java/jdk1.7/jre/bin/javaws 10000
alternatives --install /usr/bin/jar jar /usr/java/jdk1.7/bin/jar 10000
alternatives --install /usr/bin/keytool keytool /usr/java/jdk1.7/bin/keytool 10000

alternatives --config java
alternatives --config javac

which java
readlink -f /usr/bin/javac /usr/java/jdk1.7.0_80/bin/javac

3. package 설치
----------------------------------------------------------------
yum -y update
yum clean all; yum repolist

yum remove tomcatjss
yum install apr apr-devel apr-util apr-util-devel apr-util-ldap elinks krb5-workstation mailcap

4. JBoss Web Server install
----------------------------------------------------------------
jws-application-servers-3.0.3-RHEL7-x86_64.zip
jws-httpd-3.0.3-RHEL7-x86_64.zip

5. JAVA_HOME, Tomcat, Apache User
----------------------------------------------------------------
● Creating a Tomcat User
groupadd -g 91 -r tomcat
useradd -c "Tomcat" -u 91 -g tomcat -s /bin/bash -r -p tomcat1234 tomcat

chown -R tomcat:tomcat tomcat
chmod -R u+X tomcat

vi /home/${user}/.bash_profile
JAVA_HOME=/usr/java/jdk1.7

PATH=$PATH:$JAVA_HOME/bin:$HOME/bin
export PATH

umask 022

# Enviroment Variable
export LANG=ko_KR.utf8
export EDITOR=vi
export TERM=vt100
set -o vi
PS1="$(whoami)@$(hostname)]"

# Alias
alias cdtomcat=’cd /app/jws-3.0/tomcat7’
alias cdhttpd=’cd /app/jws-3.0/httpd’

setclasspath.sh, catalina.sh
export JAVA_HOME=/usr/java/jdk1.7

● Creating an Apache User
groupadd -g 48 -r apache
useradd -c "Apache" -u 48 -g apache -s /bin/bash -r -p apache1234 apache

chown -R apache:apache httpd


※ Removing /Re-Adding SSL Support
JWS_HOME/httpd/conf.d/ssl.conf.disabled

● Enabling log4j Logging for Tomcat
cd JWS_HOME/extras/
cp log4j.properties $tomcat/lib/
cp log4j-eap6.jar $tomcat/lib/
cp tomcat-juli-adapters.jar $tomcat/lib/
cp tomcat-juli.jar $tomcat/bin/

6. HTTPD Configuring mod_jk
----------------------------------------------------------------
● JWS_HOME/httpd/conf.d/mod_jk.conf


● JWS_HOME/httpd/conf.d/workers.properties

worker.list=loadbalancer,jkstatus

worker.template.type=ajp13
worker.template.lbfactor=1
worker.template.ping_mode=A
worker.template.ping_timeout=5000
worker.template.prepost_timeout=5000
worker.template.connect_timeout=5000
worker.template.socket_timeout=300
worker.template.socket_keepalive=true
worker.template.connection_pool_size=64
worker.template.connection_pool_minsize=32
worker.template.connection_pool_timeout=60

# Set properties for node01
worker.tomcat01.reference=worker.template
worker.tomcat01.host=serverip1
worker.tomcat01.port=8009

# Set properties for node02
worker.tomcat02.reference=worker.template
worker.tomcat02.host=serverip2
worker.tomcat02.port=8109

worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=tomcat01,tomcat02
worker.loadbalancer.method=Session
worker.loadbalancer.sticky_session=True

worker.jkstatus.type=status


● JWS_HOME/httpd/conf.d/uriworkermap.properties
!/*.html=loadbalancer
!/*.css=loadbalancer
!/*.js=loadbalancer
!/*.gif=loadbalancer
!/*.png=loadbalancer
!/*.jpg=loadbalancer
!/*.swf=loadbalancer 
/*=loadbalancer
!/server-status/*=loadbalancer

● JWS_HOME/httpd/conf/httpd.conf
Timeout 60
KeepAlive Off
MaxKeepAliveRequests 200
KeepAliveTimeout 3

<VirtualHost *:80>

    DocumentRoot /app/htdocs
    DirectoryIndex index.html index.jsp
    ErrorLog "|/JWS_HOME/httpd/sbin/rotatelogs /JWS_HOME/httpd/logs/error_log.%Y%m%d 86400 +540"
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" \"%{Cookie}i\"" combined
    CustomLog "|/JWS_HOME/httpd/sbin/rotatelogs /JWS_HOME/httpd/logs/access_log.%Y%m%d 86400 +540" combined env=!dont_log
    JkMountFile /JWS_HOME/httpd/conf.d/uriworkermap.properties
</VirtualHost>

● JWS_HOME/httpd/conf.modules.d/00-mpm.conf

#LoadModule mpm_prefork_module modules/mod_mpm_prefork.so => 주석 처리
LoadModule mpm_worker_module modules/mod_mpm_worker.so => 주석 해지

<IfModule worker.c>
StartServers         4
MaxRequestWorkers         1024
MinSpareThreads     128
MaxSpareThreads     256
ThreadsPerChild      64
MaxConnectionsPerChild  0
</IfModule>

7. Running the Apache HTTP Server Post-Installation Script
----------------------------------------------------------------
cd JWS_HOME/httpd
# ./.postinstall

chown root:root httpd
chmod u+s httpd

cp /JWS_HOME/httpd/sbin/apachectl /etc/init.d/httpd

vi /etc/init.d/httpd
#!/bin/sh
# chkconfig: 2345 90 90
# description: init file for Apache server daemon
# processname: /app/jws-3.0/httpd/sbin/apachectl
# config: /app/jws-3.0/httpd/conf/httpd.conf
# pidfile: /app/jws-3.0/httpd/logs/httpd.pid

chkconfig --add httpd
chkconfig --del httpd

chkconfig --list | grep httpd

systemctl enable httpd.service
systemctl start httpd.service

※ Compile SELinux Policies
# cd /etc/tomcat7/selinux/packages/tomcat7
# make -f /usr/share/selinux/devel/Makefile
# semodule -i tomcat7.pp

# cd /etc/tomcat8/selinux/packages/tomcat8
# make -f /usr/share/selinux/devel/Makefile
# semodule -i tomcat8.pp

● Add the firewall rules
firewall-cmd --permanent --add-service=http
firewall-cmd --reload
iptables -I INPUT -m state --state NEW -p tcp -m tcp --dport 80 -j ACCEPT
iptables-save > /etc/sysconfig/iptables

firewall-cmd --permanent --zone=public --add-port=80/tcp

# Mod Cluster firewall 설정
firewall-cmd --permanent --zone=public --add-port=23364/udp
firewall-cmd --permanent --zone=public --add-port=8888/tcp

/sbin/iptables -I INPUT 5 -p udp -d 224.0.1.0/24 -j ACCEPT -m comment --comment "mod_cluster traffic"
/sbin/iptables -I INPUT 6 -p udp -d 224.0.0.0/4 -j ACCEPT -m comment --comment "JBoss Cluster traffic"
/sbin/iptables -I INPUT 9 -p udp -s 192.168.1.0/24 -j ACCEPT -m comment --comment "cluster subnet for inter-node communication"
/sbin/iptables -I INPUT 10 -p tcp -s 192.168.1.0/24 -j ACCEPT -m comment --comment "cluster subnet for inter-node communication"
# /etc/init.d/iptables save
iptables-save > /etc/sysconfig/iptables

8. Tomcat 설정
----------------------------------------------------------------
● mod _cluster JBoss WebServer
server.xml
--------------------------------------------------------------------
<Listener className="org.jboss.modcluster.container.catalina.standalone.ModClusterListener" advertise="true" stickySession="true" stickySessionForce="false" stickySessionRemove="true" />
<Engine name="Catalina" defaultHost="localhost" jvmRoute="worker01">


-Dorg.jboss.modcluster.container.catalina.status-frequency=6

## JBoss WebServer Worker Node with a Static Proxy List
server.xml
--------------------------------------------------------------------
<Listener className="org.jboss.modcluster.container.catalina.standalone.ModClusterListener" advertise="false" stickySession="true" stickySessionForce="false" stickySessionRemove="true"/>

● Static ProxyList
--------------------------------------------------------------------
<Listener className="org.jboss.modcluster.container.catalina.standalone.ModClusterListener" advertise="false" stickySession="true" stickySessionForce="false" stickySessionRemove="true" proxyList="10.33.144.3:6666,10.33.144.1:6666"/>


● Heap Memory 설정
catalina.sh
JAVA_OPTS="$JAVA_OPTS -server -Xms1024m -Xmx1024m -XX:NewSize=512m -XX:MaxNewSize=512m -XX:PermSize=512m -XX:MaxPermSize=512m"
JAVA_OPTS="$JAVA_OPTS -XX:+DisableExplicitGC -XX:-HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/logs/heapdump"
JAVA_OPTS="$JAVA_OPTS -XX:ParallelGCThreads=2 -XX:-UseConcMarkSweepGC"
JAVA_OPTS="$JAVA_OPTS -XX:-PrintGC -XX:-PrintGCDetails -XX:-PrintGCTimeStamps -XX:-TraceClassUnloading -XX:-TraceClassLoading"
JAVA_OPTS="$JAVA_OPTS -Djava.awt.headless=true -Dfile.encoding=UTF-8"

-Xmx3550m -Xms3550m -Xmn2g -Xss128k -XX:+UseParallelGC -XX:ParallelGCThreads=20 -XX:+UseParallelOldGC 


server.xml
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>

 connectionTimeout="10000" redirectPort="8443" URIEncoding="UTF-8" 
 maxConnection="8192" maxThreads="250" maxHttpHeaderSize="8192" emptySessionPath="true"
 enableLookups="false" acceptCount="100" disableUploadTimeout="true"/>

<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat01">

 

● datasource 설정

# /META-INF/context.xml

<Context>

  <Resource

    name="jdbc/DsWebAppDB"
    auth="Container"
    type="javax.sql.DataSource"
    username="sa"
    password=""
    driverClassName="org.h2.Driver"
    url="jdbc:h2:mem:target/test/db/h2/hibernate"
    maxActive="8"
    maxIdle="4"/>

</Context>

 

web.xml
<?xml version="1.0" encoding="UTF-8"?>

<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
  http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

<resource-env-ref>

  <resource-env-ref-name>jdbc/DsWebAppDB</resource-env-ref-name>

  <resource-env-ref-name>javax.sql.DataSource</resource-env-ref-name>

</resource-env-ref>

</web-app>

Posted by sonorous34