All Category

공개범위 설정
Table
   
기본채널
Table
   
카테고리
Table
   
공개범위
[전체]전체 공개
Table
   
위치정보
[전체]나만 보기
Table
   
다운로드
[전체]로그인 공개
Table
   
슬라이드
Table
   
시작고정
Table
   
사진정보
0
Date: 2021-04-02
2021
April
02

3. Jboss의 부하분산 및 세션공유 설정 상세(mod_jk + mod_cluster)






(3). Jboss의 부하분산 및 세션공유 설정 상세(mod_jk + mod_cluster)






1. Jboss 운영 방식 (domain, standalone)

- 1. standalone

- 2. domain

- 3. Node 분리 : standalone를 복사해사 만듬(파생) -> 가장 직관적인 설정 방식이다.





2. Jboss설정 전체 플로우



3. standalone디랙토리를 복사해서 SERVER11 노드 서버를 만든다

[root@localhost EAP-7.1.0]# cp -Rfp standalone SERVER11
[root@localhost EAP-7.1.0]# cd SERVER11 
[root@localhost SERVER11]#
[root@localhost SERVER11]# ls -al
합계 48
drwxrwxr-x.  9 jboss jboss  240 4  4 07:05 .
drwxr-xr-x. 16 jboss jboss 4096 5 27  2018 ..
drwxrwxr-x.  3 jboss jboss 4096 4  2 15:25 configuration
drwxrwxr-x.  8 jboss jboss  118 5 25  2018 data
drwxrwxr-x.  4 jboss jboss  128 4  2 15:56 deployments
drwxrwxr-x.  3 jboss jboss   17 5  4  2018 lib
drwxrwxr-x.  4 jboss jboss 4096 4  3 00:19 log
drwxrwxr-x.  2 jboss jboss 4096 4  2 15:56 nohup
drwxrwxr-x.  4 jboss jboss   29 4  3 02:17 tmp
[root@localhost SERVER11]






4. 쉘 스크립트 작성

- 노드 별로 수정이 필요한 파일 (노드ID, Offset 포트만 수정해서 사용)

env.sh


- 모든 노드를 동일하게 사용하는 파일 (한반만 작성해서 모든 노드에 복사해서 사용)

env.properties

Shutdown.sh

Start.sh

jboss-cli.sh

jboss-jconsole.sh


- instance-id 속성 (동적 변수로 변경) : standalone-full-ha.xml

변경 전 : <subsystem xmlns="urn:jboss:domain:undertow:4.0" instance-id="S01-Node01">

변경 후 : <subsystem xmlns="urn:jboss:domain:undertow:4.0" instance-id="${jboss.node.name}">





5. env 쉘 스크립트(env.sh)

[root@localhost SERVER11]# vi env.sh 




#!/bin/sh
DATE=`date +%Y%m%d%H%M%S`

######################################################################################################
##### JBOSS Directory Setup #####
######################################################################################################
export JBOSS_HOME=/home/jboss/EAP-7.1.0
export DOMAIN_BASE=/home/jboss/EAP-7.1.0


######################################################################################################
##### Configration File #####
######################################################################################################
export CONFIG_FILE=standalone-full-ha.xml
export HOST_NAME=myweb
export JBOSS_USER=jboss

export HOST_IP=192.168.20.1                     # Host IP
export SERVER_NAME=SERVER11                     # Node 디랙토리 이름
export NODE_NAME=S02-Node01                     # Node 이름
export PORT_OFFSET=0                            # Port Offset

 
######################################################################################################
##### Bind Address #####
######################################################################################################
export BIND_ADDR=$HOST_IP
export MULTICAST_ADDR=230.0.0.4                 # 230.1.0.1  #멀티케스트는 224.0.1.0 ~ 238.255.255.255 까지 범위를 가진다.(TCP Specification)
export JMS_MULTICAST_ADDR=231.7.7.7             # 231.7.0.1  #Apache mod_cluster 통신용 멀티케스트 주소
export MODCLUSTER_MULTICAST_ADDR=224.0.1.105    # Apache mod_cluster.conf 설정시 같은 서비스끼리 잘 맞추어야 한다. #잘못하면 이상한 WAS로 서비스를 전달하여 오류발생가능
export JGROUPS_BIND_ADDR=$HOST_IP
export MGMT_ADDR=$HOST_IP
export CONTROLLER_IP=$MGMT_ADDR
let JBOSS_CONTROLLER_PORT=9990+$PORT_OFFSET
export JBOSS_CONTROLLER_PORT
export LAUNCH_JBOSS_IN_BACKGROUND=true

######################################################################################################
##### jboss-cli #####
######################################################################################################
export JBOSS_MANAGEMENT_ADDR=$HOST_IP
export JBOSS_CONTROLLER_IP=$JBOSS_MANAGEMENT_ADDR


######################################################################################################
##### JBoss System module and User module directory #####
######################################################################################################
export JBOSS_MODULEPATH=$JBOSS_HOME/modules:$JBOSS_HOME/modules.ext




# ====================================================================================================
# JVM Options : Server : Memory(Java HotSpot ™ 64 비트 서버 VM 경고 : 옵션 MaxPermSize를 무시합니다. 8.0에서 지원이 제거되었습니다.)
# ====================================================================================================
export JAVA_OPTS="-server $JAVA_OPTS"

# -- JVM Options : Memory-----------------------------------------------------------------------------
#export JAVA_OPTS=" $JAVA_OPTS -Xms1024m -Xmx2048m "     # 2G(2048M)
#export JAVA_OPTS=" $JAVA_OPTS -Xms1024m -Xmx3072m "     # 3G(3072M)
export JAVA_OPTS=" $JAVA_OPTS -Xms1024m -Xmx4096m "      # 4G(4096M)
export JAVA_OPTS=" $JAVA_OPTS -XX:+UseParallelGC "
export JAVA_OPTS=" $JAVA_OPTS -XX:+ExplicitGCInvokesConcurrent "
export JAVA_OPTS=" $JAVA_OPTS -XX:-HeapDumpOnOutOfMemoryError "


######################################################################################################
# Linux Large Page Setting
######################################################################################################
export JAVA_OPTS=" $JAVA_OPTS -Djava.net.preferIPv4Stack=true"
export JAVA_OPTS=" $JAVA_OPTS -Dorg.jboss.resolver.warning=true"
export JAVA_OPTS=" $JAVA_OPTS -Dsun.rmi.dgc.client.gcInterval=3600000 "
export JAVA_OPTS=" $JAVA_OPTS -Dsun.rmi.dgc.server.gcInterval=3600000"
export JAVA_OPTS=" $JAVA_OPTS -Djboss.modules.system.pkgs=org.jboss.byteman"
export JAVA_OPTS=" $JAVA_OPTS -Djava.awt.headless=true"
export JAVA_OPTS=" $JAVA_OPTS -Djboss.server.base.dir=$DOMAIN_BASE/$SERVER_NAME"
export JAVA_OPTS=" $JAVA_OPTS -Djboss.socket.binding.port-offset=$PORT_OFFSET"
export JAVA_OPTS=" $JAVA_OPTS -Djboss.node.name=$NODE_NAME"

export JAVA_OPTS=" $JAVA_OPTS -Djgroups.bind_addr=$JGROUPS_BIND_ADDR"
export JAVA_OPTS=" $JAVA_OPTS -Djboss.bind.address.management=$MGMT_ADDR"
export JAVA_OPTS=" $JAVA_OPTS -Djboss.bind.address=$BIND_ADDR"
export JAVA_OPTS=" $JAVA_OPTS -Djboss.bind_addr=$MULTICAST_ADDR"
export JAVA_OPTS=" $JAVA_OPTS -Djboss.default.multicast.address=$MULTICAST_ADDR"
export JAVA_OPTS=" $JAVA_OPTS -Djboss.messaging.group.address=$JMS_MULTICAST_ADDR"
export JAVA_OPTS=" $JAVA_OPTS -Djboss.modcluster.multicast.address=$MODCLUSTER_MULTICAST_ADDR"
export JAVA_OPTS=" $JAVA_OPTS -Dorg.jboss.as.logging.per-deployment=false" ## Jboss 로그 끄기
export JAVA_OPTS=" $JAVA_OPTS -Dserver.mode=local"




echo "================================================"
echo "JBOSS_HOME=$JBOSS_HOME"
echo "DOMAIN_BASE=$DOMAIN_BASE"
echo "SERVER_NAME=$SERVER_NAME"
echo "CONFIG_FILE=$CONFIG_FILE"
echo "BIND_ADDR=$BIND_ADDR"
echo "PORT_OFFSET=$PORT_OFFSET"
echo "MULTICAST_ADDR=$MULTICAST_ADDR"
echo "CONTROLLER=$JBOSS_CONTROLLER_IP:$JBOSS_CONTROLLER_PORT"
echo "================================================"


노드별 설정에서 변경 해야하는 속성

- node1 : env.sh

export HOST_IP=192.168.20.1

export SERVER_NAME=SERVER11

export NODE_NAME=S01-Node01  

export PORT_OFFSET=0


- node2 : env.sh

export HOST_IP=192.168.20.1

export SERVER_NAME=SERVER12

export NODE_NAME=S01-Node02  

export PORT_OFFSET=100







6. env속성 파일 (env.properties)

[root@localhost SERVER11]# vi env.properties



#################################################
# 필요에 따라 사용 (선택)
#################################################
UseJK=true                                                                 # sticky session 설정
org.apache.coyote.http11.Http11Protocol.SERVER="MyTest-WS"                 # Header X-Powered-By 숨김
# org.apache.catalina.connector.URI_ENCODING=UTF-8                         # 언어 설정
# org.apache.catalina.connector.USE_BODY_ENCODING_FOR_QUERY_STRING=true
# org.apache.coyote.http11.Http11Protocol.MAX_HEADER_SIZE=8192
# org.apache.coyote.ajp.DEFAULT_CONNECTION_TIMEOUT=60000                   # 연결 시간 설정
# org.apache.coyote.http11.DEFAULT_CONNECTION_TIMEOUT=60000
# org.apache.tomcat.util.http.Parameters.MAX_COUNT=10000                   # 파라미터 최대 연결 개수 설정







7. 시작 쉘 스크립트(Start.sh)

[root@localhost SERVER11]# vi Start.sh 


#!/bin/sh
DATE=`date +%Y%m%d%H%M%S`
. ./env.sh

PID=`ps -ef | grep java | grep "=$SERVER_NAME " | awk '{print $2}'`
echo $PID

if [ e$PID != "e" ]
then
 echo "JBoss SERVER - $SERVER_NAME is already RUNNING..."
 exit;
fi


UNAME=`id -u -n`
if [ e$UNAME != "e$JBOSS_USER" ]
then
 echo "Use $JBOSS_USER account to start JBoss SERVER - $SERVER_NAME..."
 exit;
fi

echo $JAVA_OPTS
if [ ! -d "./nohup" ];
then
 mkdir nohup
fi
 mv $SERVER_NAME.out ./nohup/$SERVER_NAME.out.$DATE
 nohup $JBOSS_HOME/bin/standalone.sh -DSERVER=$SERVER_NAME -b $BIND_ADDR -bmanagement $MGMT_ADDR -u $MULTICAST_ADDR -P=$DOMAIN_BASE/$SERVER_NAME/env.properties -c $CONFIG_FILE >> $SERVER_NAME.out &
 #nohup $JBOSS_HOME/bin/standalone.sh -DSERVER=$SERVER_NAME -b $BIND_ADDR -u $MULTICAST_ADDR -c $CONFIG_FILE >> $SERVER_NAME.out &
 #nohup $JBOSS_HOME/bin/standalone.sh -DSERVER=$SERVER_NAME -b $BIND_ADDR -bmanagement $BIND_ADDR -c $CONFIG_FILE >> $SERVER_NAME.out &
if [ e$1 = "enotail" ]
then
 echo "Starting..... $SERVER_NAME"
 exit;
fi

if [ "$1" = "NoTail" ]; then
 echo ""
else
 tail -f $SERVER_NAME.out
fi






8. 종료 쉘 스크립트(Shutdown.sh)

[root@localhost SERVER11]# vi Shutdown.sh 


#!/bin/sh
. ./env.sh

PID=`ps -ef | grep java | grep "=$SERVER_NAME " | awk '{print $2}'`
echo $PID

if [ e$PID == "e" ]; then
 echo "JBoss SERVER $SERVER_NAME is Not RUNNING..."
 exit;
fi

$JBOSS_HOME/bin/jboss-cli.sh --connect --controller=$CONTROLLER_IP:$JBOSS_CONTROLLER_PORT --command=:shutdown








9. CLI관리콘솔 쉘 스크립트(jboss-cli.sh)

[root@localhost SERVER11]# vi jboss-cli.sh 


#!/bin/sh
BASE_DIR=$(dirname $0)
. $BASE_DIR/env.sh

#echo $JBOSS_HOME
export JAVA_OPTS=" -Djava.awt.headless=false $JAVA_OPTS"

$JBOSS_HOME/bin/jboss-cli.sh --controller=$JBOSS_CONTROLLER_IP:$JBOSS_CONTROLLER_PORT --connect $@





10. Jconsole 쉘 스크립트(jboss-jconsole.sh)

 [root@localhost SERVER11]# vi jboss-jconsole.sh 


#!/bin/sh
BASE_DIR=$(dirname $0)
. $BASE_DIR/env.sh
echo "======================================================="
echo " JMX URL : service:jmx:remoting-jmx://$JBOSS_MANAGEMENT_ADDR:$JBOSS_CONTROLLER_PORT"
echo "======================================================="
$JBOSS_HOME/bin/jconsole.sh






11. 배포 설정 (Jboss Deploy Host)

<subsystem xmlns="urn:jboss:domain:undertow:4.0" instance-id="${jboss.node.name}">
  <buffer-cache name="default"/>
  <server name="default-server">
    <ajp-listener   name="ajp"     socket-binding="ajp"   max-post-size="2147483648"/>
    <http-listener  name="default" socket-binding="http"  max-post-size="2147483648" redirect-socket="https"           enable-http2="true"/>
    <https-listener name="https"   socket-binding="https" max-post-size="2147483648" security-realm="ApplicationRealm" enable-http2="true"/>
    
    <host name="default-host" alias="localhost">
      <location   name="/" handler="welcome-content"/>
      <filter-ref name="server-header"/>
      <filter-ref name="x-powered-by-header"/>
    </host>

    <host name="MyWeb2-Host" alias="myweb2.co.kr" default-web-module="myweb2.war" disable-console-redirect="false"/>
    <host name="MyWeb-Host"  alias="myweb.co.kr"  default-web-module="myweb.war"  disable-console-redirect="false"/>

  </server>
  <servlet-container name="default">
    <jsp-config development="true" check-interval="1" modification-test-interval="1" recompile-on-fail="true"/>
    <websockets/>
  </servlet-container>
  <handlers>
    <file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
  </handlers>
  <filters>
    <response-header name="server-header"       header-name="Server"       header-value="JBoss-EAP/7"/>
    <response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow/1"/>
  </filters>
</subsystem>

  • 배포를 위한 설정1 (standalone-full-ha.xm)

- node1 : /home/jboss/EAP-7.1.0/SERVER11/configuration/standalone-full-ha.xml

- node2 : /home/jboss/EAP-7.1.0/SERVER12/configuration/standalone-full-ha.xml

- host 연결 이름 : <host name="MyWeb-Host" alias="myweb.co.kr" default-web-module="myweb.war" disable-console-redirect="false"/>


  • 배포를 위한 설정2 (myweb.war/WEB-INF/jboss.xml)

- Virtual Host : <virtual-host>MyWeb-Host</virtual-host>





12. 방화벽 설정


- 방화벽 구성(열기)

[root@localhost sysconfig]# cd /etc/sysconfig/
[root@localhost sysconfig]# vi iptables


- 방화벽 구성(편집)

# sample configuration for iptables service
# you can edit this manually or use system-config-firewall
# please do not ask us to add additional ports/services to this default configuration
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT

 
#------------------------------------------------------ -------------------------------           ---------
-A INPUT -d 224.0.1.0/24    -p udp -m comment --comment "mod_cluster traffic"                            -j ACCEPT
-A INPUT -d 224.0.0.0/4     -p udp -m comment --comment "JBoss Cluster traffic"                          -j ACCEPT
-A INPUT -s 192.168.10.0/24 -p udp -m comment --comment "cluster subnet for inter-node communication"    -j ACCEPT
-A INPUT -s 192.168.10.0/24 -p tcp -m comment --comment "cluster subnet for inter-node communication"    -j ACCEPT
#------------------------------------------------------ -------------------------------           ---------
  
#--------------------------------------------------------------------------- -------------------------------         ---------
-A INPUT -s 230.0.0.4/32   -p udp -m udp --dport 45688 -m comment --comment "jgroups-udp (multicast-port:4-j ACCEPT 5688)"  -j ACCEPT
-A INPUT -s 230.0.0.4/32   -p udp -m udp --dport 45700 -m comment --comment "jgroups-mping(multicast-port:4-j ACCEPT 5700)" -j ACCEPT
-A INPUT -s 231.7.7.7/32   -p udp -m udp --dport 9876  -m comment --comment "hornetq   (multicast-port:9-j ACCEPT 876)"     -j ACCEPT
-A INPUT -s 224.0.1.105/32 -p udp -m udp --dport 23364 -m comment --comment "224.0.1.105 (multicast-port(2-j ACCEPT 3364)"  -j ACCEPT
#--------------------------------------------------------------------------- -------------------------------         ---------

-A INPUT -m iprange --src-range 192.168.20.1-192.168.20.4 -p tcp -m tcp --dport 3528  -j ACCEPT
-A INPUT -m iprange --src-range 192.168.20.1-192.168.20.4 -p tcp -m tcp --dport 3529  -j ACCEPT
-A INPUT -m iprange --src-range 192.168.20.1-192.168.20.4 -p tcp -m tcp --dport 7600  -j ACCEPT
-A INPUT -m iprange --src-range 192.168.20.1-192.168.20.4 -p tcp -m tcp --dport 54200 -j ACCEPT
-A INPUT -m iprange --src-range 192.168.20.1-192.168.20.4 -p tcp -m tcp --dport 57600 -j ACCEPT
                             
 
 
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT



- 방화벽 구성(네트웍크 재시작)

[root@localhost sysconfig]# /etc/rc.d/init.d/network restart





13. 실행 권한 부여

[root@localhost SERVER11]# cd /home/jboss/EAP-7.1.0/SERVER11
[root@localhost SERVER11]# chmod +x *.sh


[root@localhost SERVER12]# cd /home/jboss/EAP-7.1.0/SERVER12
[root@localhost SERVER12]# chmod +x *.sh







14. Jboss 시작/종료

- Node1 시작

[root@localhost SERVER11]# su - jboss
[root@localhost SERVER11]# cd /home/jboss/EAP-7.1.0/SERVER11
[root@localhost SERVER11]# ./Start.sh


- Node2 시작

[root@localhost SERVER12]# su - jboss
[root@localhost SERVER12]# cd /home/jboss/EAP-7.1.0/SERVER12
[root@localhost SERVER12]# ./Start.sh



- Node1 종료

[root@localhost SERVER11]# su - jboss
[root@localhost SERVER11]# cd /home/jboss/EAP-7.1.0/SERVER11
[root@localhost SERVER11]# ./Shutdown.sh


- Node2 종료

[root@localhost SERVER12]# su - jboss
[root@localhost SERVER12]# cd /home/jboss/EAP-7.1.0/SERVER12
[root@localhost SERVER12]# ./Shutdown.sh













URL : http://www.epari.net/@architecture/vlink/b/ce
목록
도움이 되는 유익한 내용이었다면 힘이 될 수 있는 댓 글을 남겨주세요.
4
0
  • 뎃글달기
Upload
v
Name Type Size