Setting Up a Basic JBoss EAP 6 Cluster with mod_jk for Load Balancing and Failover

Kita akan membuat 2 node Jboss dan 1 node EWS sebagai load balancer cluster dengan session replication enabled, berikut alamat tiap node:

Node 1:  10.7.60.51

Node 2 :  10.7.60.52

EWS:  10.7.60.53

Contoh pada Node 1:

– Set hostname jboss ews

– edit /etc/hosts/

– install jdk for linux:

rpm -ivh namafiles.rpm

  1. install jboss-eap-6.4.0.zip to a directory, contoh /opt/

cd /opt/

unzip jboss-eap-6.4.0.zip

  1. Menambahkan user yang akan menggunakan jboss EAP

Agar dapat menambahkan user pada Jboss EAP, kita harus melakukan edit file jmx-console-users.properties, tapi pada Jboss 6, terdapat shell script di $JBOSS_HOME/bin directory yang bernama add-user.sh

Accept the default user type – Management User.
Accept the default realm – ManagementRealm

  1. Masukan username dan password dari useryang akan dibuat, contoh admin/admin123. Kemudia kita akan ditanya mengenai beberapa pertanyaan, yang pertama pilh yes dan yang kedua pilih no
  2. Cluster Setup (coba standalone configuration)

pada /opt/jboss-eap-6.4.0/standalone/configuration/standalone.xml, tambahkan ip of the node 1 yang akan di cluster.

<interfaces>

        <interface name=”management”>

            <inet-address value=”${jboss.bind.address.management:10.7.60.51}”/>

        </interface>

       <interface name=”public”>

            <inet-address value=”${jboss.bind.address:10.7.60.51}”/>

        </interface>

        <interface name=”unsecure”>

            <inet-address value=”${jboss.bind.address.unsecure:10.7.60.51}”/>

        </interface>

    </interfaces>

  1. Starting the servers

/opt/jboss-eap-6.4.0/bin/

./standalone.sh (ctrl+c)

  1. Edit standalone-ha.xml configuration

dan tambahkan ip of the node 1 in interface:

<interfaces>

<interface name=”management”>

<inet-address value=”${jboss.bind.address.management:10.7.60.51}”/>

</interface>

<interface name=”public”>

<inet-address value=”${jboss.bind.address:10.7.60.51}”/>

</interface>

<interface name=”unsecure”>

<inet-address value=”${jboss.bind.address.unsecure:10.7.60.51}”/>

</interface>

</interfaces>

  1. Start standalone-ha configuration

./standalone.sh –Djboss.node.name=jboss-node1 -server-config=standalone-ha.xml -b 10.7.60.51

 

Langkah selanjutnya adalah konfigurasi pada mesin Load balancer (jboss ews)

IP EWS:  10.7.60.53

  1. Set hostname
  2. set /etc/hosts
  3. install elinks, krb5-workstation, mailcap, mod_auth_kerb, and httpd
  4. cd /opt/ jboss-eap-6.4.0/httpd

Jalankan postinstall yang ada pada httpd

  1. ./.postinstall
  2. cd /sbin/

Start apache webserver

  1. ./apachectl start
  2. ada beberapa error ketika menjalankan apachectl, jadi kita harus analyze httpd log file nya
  3. tail /opt/jboss-eap-6.4.0/httpd/logs/httpd.log

karena file auth_kerb.conf itu ngelink ke file lain, maka kita harus unlink terlebih dahulu

  1. ls -l /opt/jboss-eap-6.4.0/httpd/conf.d/auth_kerb.conf
  2. unlink /opt/jboss-eap-6.4.0/httpd/conf.d/auth_kerb.conf
  3. ./apachectl restart
  4. ./apachectl stop
  5. ./apachectl start

Copy modules tambahan agar dapat memberikan fitur load balancing, dan clustering.

 

modules yang diperlukan adalah

 

mod_advertise.so,

mod_jk.so,

mod_manager.so,

mod_proxy_cluster.so,

mod_slotmem.so

 

Copy semua modul tersebut ke dalam opt/jboss-eap-6.4.0/httpd/modules/

kemudian, tambahkan konfigurasi berikut kedalam httpd.conf:

## Using mod_jk, mod_cluster in EWS 1.0.2

# mod_jk

#LoadModule jk_module /opt/jboss-ews-2.1/httpd/modules/mod_jk.so

#

# mod_cluster

# mod_proxy_balancer should be disabled when mod_cluster is used

#LoadModule proxy_cluster_module /opt/jboss-ews-2.1/httpd/modules/mod_proxy_cluster.so

#LoadModule slotmem_module /opt/jboss-ews-2.1/httpd/modules/mod_slotmem.so

#LoadModule manager_module /opt/jboss-ews-2.1/httpd/modules/mod_manager.so

#LoadModule advertise_module /opt/jboss-ews-2.1/httpd/modules/mod_advertise.so

# mod_proxy_balancer should be disabled when mod_cluster is used

LoadModule proxy_cluster_module modules/mod_proxy_cluster.so

LoadModule slotmem_module modules/mod_slotmem.so

LoadModule manager_module modules/mod_manager.so

LoadModule advertise_module modules/mod_advertise.so

# Load mod_jk module

# Specify the filename of the mod_jk lib

LoadModule jk_module modules/mod_jk.so

JkWorkersFile /opt/jboss-ews-2.1/httpd/conf/workers.properties

JkLogFile logs/mod_jk.log

JkLogLevel info

JkLogStampFormat “[%a %b %d %H:%M:%S %Y]”

JkOptions +ForwardKeySize +ForwardURICompatUnparsed -ForwardDirectories

JkRequestLogFormat “%w %V %T”

JkMount /clusterdemo/* loadbalancer

JkMountFile /opt/jboss-ews-2.1/httpd/conf/uriworkermap.properties

#JkShmFile /var/cache/mod_jk/jk.shm

JkShmFile logs/jk.shm

<Location /jkstatus/>

JkMount status

#Order deny,allow

#Deny from all

#Allow from 127.0.0.1

#Allow from 192.168.1.0/24

</Location>

<IfModule manager_module>

Listen 10.7.60.55:8080

ManagerBalancerName mycluster

<VirtualHost 10.7.60.55:8080>

<Location />

#      Order deny,allow

#      Deny from all

#      Allow from 127.0.0

</Location>

KeepAliveTimeout 300

MaxKeepAliveRequests 0

#ServerAdvertise on http://@IP@:6666

AdvertiseFrequency 5

#AdvertiseSecurityKey secret

#AdvertiseGroup @ADVIP@:23364

EnableMCPMReceive

<Location /mod_cluster_manager>

SetHandler mod_cluster-manager

#Order deny,allow

#Deny from all

#Allow from 127.0.0cat workers.properties

# Define list of workers that will be used

# for mapping requests

worker.list=loadbalancer,status

# Define Node1

# modify the host as your host IP or DNS name.

worker.node1.port=8009

worker.node1.host=10.7.60.55

worker.node1.type=ajp13

worker.node1.ping_mode=A

worker.node1.lbfactor=1

# Define Node2

# modify the host as your host IP or DNS name.

worker.node2.port=8009

worker.node2.host=10.7.60.55

worker.node2.type=ajp13

worker.node2.ping_mode=A

worker.node2.lbfactor=1

# Load-balancing behavior

worker.loadbalancer.type=lb

worker.loadbalancer.balance_workers=node1,node2

worker.loadbalancer.sticky_session=True

#worker.loadbalancer.sticky_session_force=True

# Status worker for managing load balancer

worker.status.type=status

</Location>

Setelah konfigurasi httpd sudah ditambahkan atau di copy dari file httpd.conf yang telah diedit, maka langkah selanjutnya adalah

edit file /opt/jboss-ews-2.1/httpd/conf/uriworkermap.properties  dan workers.properties menjadi sebagai berikut:

cat uriworkermap.properties

#/*=loadbalancer

/cluster-demo/*=loadbalancer

#/*=demo

 

cat workers.properties

 

# Define list of workers that will be used

# for mapping requests

worker.list=loadbalancer,status

 

# Define Node1

# modify the host as your host IP or DNS name.

worker.node1.port=8009

worker.node1.host=10.7.60.55

worker.node1.type=ajp13

worker.node1.ping_mode=A

worker.node1.lbfactor=1

 

# Define Node2

# modify the host as your host IP or DNS name.

worker.node2.port=8009

worker.node2.host=10.7.60.55

worker.node2.type=ajp13

worker.node2.ping_mode=A

worker.node2.lbfactor=1

 

# Load-balancing behavior

worker.loadbalancer.type=lb

worker.loadbalancer.balance_workers=node1,node2

worker.loadbalancer.sticky_session=True

#worker.loadbalancer.sticky_session_force=True

 

# Status worker for managing load balancer

worker.status.type=status

 

Pada file diatas, kita harus define ip node 1 dan node 2 yang akan di cluster.

Restart apechectl

./apachectl restart

Kemudian masuk kita hanya tinggal masukan alamat IP jboss ews di browser dan deploy satu applikasi “clusterdemo” untuk melihat kedua node telah tergabung dalam satu cluster.

 

Semoga bermanfaat.

 

Leave a Reply

Your email address will not be published. Required fields are marked *