Friday, July 21, 2017

Jboss EAP 7 Standalone cluster - TCP

Tested environment
OS: Centos 7 / Rhel 7 (SELinux and firewall disabled )
Java: Oracle JDK 1.8
Jboss: Jboss EAP 7.0.0 (2016-05-10)

Started to try setup Jboss EAP 7 cluster using standalone mode. But fail to setup using their default config which using UDP multicast, so been googling and found working solution at RedHat portal which using TCP for it multicast.
below is the step i had taken to setup my Jboss EAP 7 Standalone cluster for 2 server

Please make sure you had setup 2 server before you start this as the cluster config needed to input both server IP

Oracle JDK 1.8

1. download your oracle jdk 1.8 from this URL

download the "jdk-8u141-linux-x64.rpm"

2. transfer to your server and install it
# yum localinstall jdk-8u141-linux-x64.rpm

3. confirm your java with this command
# java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

JBOSS EAP 7 setup

1. download your jboss from this URL
I use version 7.0.0 as currently that's the latest stable version.

2. transfer to your Centos 7 / RHEL 7 and unpack the package
# unzip

3. move the folder to /opt
# mv jboss-eap-7.0 /opt/

4. Add a management user, you can skip this if you does not need it. But for me, it useful for me to monitoring and give to developer to deploy code and get log.
# cd /opt/jboss-eap-7.0/bin
( NOTE: since i only using it for testing and development use, i edit the password config so I do not require me to setup complicated password )
# vim

# ./
What type of user do you wish to add?
 a) Management User (
 b) Application User (
(a): a
Enter the details of the new user to add.
Using realm 'ManagementRealm' as discovered from the existing property files.
Username : jboss-admin
Password :
Re-enter Password :
What groups do you want this user to belong to? (Please enter a comma separated list, or leave blank for none)[  ]:
About to add user 'jboss-admin' for realm 'ManagementRealm'
Is this correct yes/no? yes
Added user 'jboss-admin' to file '/opt/jboss-eap-7.0/standalone/configuration/'
Added user 'jboss-admin' to file '/opt/jboss-eap-7.0/domain/configuration/'
Added user 'jboss-admin' with groups  to file '/opt/jboss-eap-7.0/standalone/configuration/'
Added user 'jboss-admin' with groups  to file '/opt/jboss-eap-7.0/domain/configuration/'
Is this new user going to be used for one AS process to connect to another AS process?
e.g. for a slave host controller connecting to the master or for a Remoting connection for server to server EJB calls.
yes/no? yes
To represent the user add the following to the server-identities definition <secret value="amJvc3MtYWRtaW4=" />

5. go to init.d folder and update jboss config
# cd init.d/
# vim jboss-eap.conf

## Location of JDK
## Location of JBoss EAP
## The username who should own the process.
## The mode JBoss EAP should start, standalone or domain
## Configuration for standalone mode

6. Edit the startup script to point to this config file
# vim

# Load JBoss EAP init.d configuration.
if [ -z "$JBOSS_CONF" ]; then

7. add user jboss since inside the config, we had set to run this as jboss user
# useradd jboss

8. change jboss ownership to jboss
# chown -R /opt/jboss-eap-7.0

9. try startup the jboss
# ./ start

Cluster setup

1. once the jboss is started, left it running as the next step needed it to implement the setting.
go to bin directory and create new file call tcp-cluster
# cd /opt/jboss-eap-7.0/bin
# touch tcp-cluster

2. open tcp-cluster file and pass this below into it.

# Add the tcpping stack
# Set the properties for the TCPPING protocol
# Set tcpping as the stack for the ee channel

Edit your host to your IP for both of your server (which in Red color font)

3. execute the script by using this command
# ./ --connect --file=tcp-cluster

4. stop your jboss service
# ./init.d/ stop

5. go to edit standalone-ha config and update it to listen to your IP instead of localhost
# cd /opt/jboss-eap-7.0/standalone/configuration/
# vim standalone-ha.xml

        <interface name="management">
            <inet-address value="${}"/>
        <interface name="public">
            <inet-address value="${jboss.bind.address:}"/>
        <interface name="private">
            <inet-address value="${jboss.bind.address.private:}"/>

6. you need to edit java_opt to give your node a name
# cd /opt/jboss-eap-7.0/bin/
# vim standalone.conf

if [ "x$JAVA_OPTS" = "x" ]; then
   JAVA_OPTS="-Xms1350m -Xmx1350m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m"
   JAVA_OPTS="$JAVA_OPTS -Djboss.modules.system.pkgs=$JBOSS_MODULES_SYSTEM_PKGS -Djava.awt.headless=true"
   echo "JAVA_OPTS already set in environment; overriding default settings with values: $JAVA_OPTS"

please use different name for your 2nd server

7. you can start your jboss and try access it using <server_IP>:8080

8. your cluster is done and for your war file, you need to code it to support cluster. at the end of this node, I will write testing section on how to make sure it is cluster and jsession is transfer to each other when it down.


for the startup, we will use back jboss initd script provided.
It located at /opt/jboss-eap-7.0/bin/init.d/

1. go to systemd and create jboss.service
# cd /usr/lib/systemd/system
# vim jboss.service

2. paste this into it and save it

Description=Jboss EAP 7

ExecStart=/opt/jboss-eap-7.0/bin/init.d/ start
ExecStop=/opt/jboss-eap-7.0/bin/init.d/ stop


3. enable jboss to start during boot
# systemctl enable jboss.service

4. start jboss service to verify it is working
# systemctl start jboss

Apache Web Setup

I going to use apache with mod_jk for my web + balancer

1. install apache and needed package
# yum install httpd httpd-devel gcc

2. download mod_jk and build it. You can get it from this URL
get the JK 1.2.42 Source Release tar.gz (e.g. Unix, Linux, Mac OS)

3. unpack it, configure, make
# tar -zxvf tomcat-connectors-1.2.42-src.tar.gz
# tomcat-connectors-1.2.42-src/native/
# find / -iname apxs
# ./configure --with-apxs=/usr/bin/apxs
# make
# make install

4. setup web config file
# cd /etc/httpd/conf.d/
# vim

#node name you using here need to be same in standalone.conf
# Load-balancing behaviour

# vim mod_jk.conf

LoadModule jk_module modules/
<IfModule mod_jk.c>
JkWorkersFile /etc/httpd/conf.d/
JkShmFile /var/log/httpd/mod_jk.shm
JkLogFile /var/log/httpd/mod_jk.log
JkLogLevel info,debug
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

JkMount /* worker1
#mount this url, edit as neccessary

5. save it and start apache service


By right, if you are using Exsi to host your server. You should see cluster member view inside the log during the jboss startup.
for mine, i only using Vmware workstation on my laptop and host 2 server. So there is nothing to be see on the log if do not have any War file with cluster setting deploy.
So do not freak out if your log do not show the cluster member.

here is the step taken to test my cluster is working

1. download this war file, which i get it from RedHat solutions
Unzip the file.
Inside it, go to counter/dist, download the counter.war

2. deploy it to your both of your jboss. You can either use the management console to deploy it or put the war file to the deployment folder
(NOTE: once you deploy the war file to both server, you should be able to see the cluster member info show up in your log )

3. go to <server-1_IP>/counter in browser

4. refresh few times, and you should see the counter increasing

5. now stop server-1 jboss, when it done fully stop, even we are still using server-1 web but the backend should be redirected to server-2 jboss since we had stop server-1 jboss.

6. Try refresh the pages and you should see the counter is continue increase instead of get reset. this had prove the jsession has been pass to other member of the cluster when it get down.

No comments:

Post a Comment