JBoss WildFly

JBoss Wildfly Cluster Example

This is an article about JBoss Wildly Cluster. JBoss WildFly runtime manages the applications deployed on its server. It used to be called as JBoss application server. In this article, setup of WildFly Clustering is presented and discussed.

1.Introduction

A JBoss WildFly instance can be deployed on the standalone server. The stand alone server is an independent process. Launch scripts are used to start the standalone instances.

To start with, a cluster consists of a domain controller (master) and slaves. The controller will distribute the configuration. The configuration is related to settings and applications deployed on the slaves. It provides capabilities to start, stop and restart instances deployed on slaves. A Cluster is a group of instances of applications running simultaneously. Further, Cluster provides increased scalability and reliability.

2.JBoss Wildfly Cluster

2.1 Prerequisites

Java 7 or 8 is required on the linux or windows operating system. In addition, JBoss Wildfly need to be installed after the prerequisites are installed.

2.2 Download

You can download Java 7 from Oracle site. On the other hand, You can download Java 8 from this site and use it as the JDK. JBoss Wildfly can be downloaded from this site.

2.3 Setup

You can set the environment variables for Java 7 or 8 and JBoss Wildfly in the standalone.conf. This configuration file can be found in the bin folder. For example, The script below shows the environmental variables set for JBoss Wildfly.

JAVA_HOME=”/jboss/jdk1.8.0_73″
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
JBOSS_HOME=”/jboss/wildfly-10.1.0.Final”
JAVA_OPTS= -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true 
export JAVA_OPTS

2.4 Running the standalone server

Stand alone server can be started with this command from wildfly-16.0.0.Final/bin:

./standalone.sh

After the stand alone server starts and you can check in the browser using the url : http://localhost:8080/

JBoss Wildfly Cluster
Wildfly

A sample war provided below in the download section can be deployed on to the stand alone server. The admin console is launched using : http://localhost:9990/console/index.html

JBoss Wildfly Cluster - wildfly admin console
wildfly admin console

The deployment tab is selected for deploying the sample.war file

JBoss Wildfly Cluster - Wildfly Deployment Section
Wildfly Deployment Section

From the left menu, the sample war file can be uploaded using “Upload Deployment” menu selection.

JBoss Wildfly Cluster Example - Upload deployment
Upload deployment

You can choose a file using the screen below:

JBoss Wildfly Cluster - Choose a file
Choose a file

Pick the sample war file from the directory using the file wizard.

JBoss Wildfly Cluster - Selection of war file
Selection of war file

The name and runtime name of the war file can be provided in the screen below.

JBoss Wildfly Cluster - Deployment Description
Deployment Description

After the deployment, the screen below appears.

JBoss Wildfly Cluster - Sample War deployed
Sample War deployed successfully

You can check the war deployed by using the link http://localhost:8080/sample

JBoss Wildfly Cluster - Sample Application
Sample Application

2.5 Running the Cluster

You can run the instances using the scripts specific to a cluster node. If the apache web server is used, you can enable the mod_jk module. This is related to the load-balancing for the deployed instances on the wildfly server.

Firstly to set up a cluster, You can start the two nodes with commands as shown below:

wildfly-16.0.0.Final/bin/standalone.sh -c standalone-ha.xml -Djboss.node.name=node1
wildfly-16.0.0.Final/bin/standalone.sh -c standalone-ha.xml -Djboss.node.name=node2 -Djboss.socket.binding.port-offset=100

The configuration file standalone-ha.xml is shown as below:


standalone-ha.xml

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

After the first node server starts, you can check in the browser using the url :

http://localhost:9990/console/index.html

JBoss Wildfly Cluster - Wildfly cluster node1
Wildfly cluster node1

After the second node server starts, you can check in the browser using the url :

http://localhost:10090/console/index.html

JBoss Wildfly Cluster - Wildfly Cluster Node2
Wildfly Cluster Node2

2.6 Managing JBoss Wildfly Cluster

To start with, JBoss WildFly server has the management console to manage a cluster. In a cluster, multiple instances can have the same domain controller. Hence, single management interface can handle commands and deployment of applications to multiple servers.

Centralized management is possible on a managed domains interacting with different JBoss Wildfly instances. The JBoss Wildfly management interface manages the interrelated jboss services per cluster. The domain controller process is the central point for management. Multiple instances have a common management policy. Hence, each instance is configured on the server using the policy. Host Controller manages the JBoss Wildfly instances deployed on different physical machines and VMs. A single Host Controller instance is configured as a Domain Controller. The Host Controller interacts with the Domain Controller. It manages the deployed server instances lifecycle.

The Host Controller manages the instances deployed on the server management. The application server workloads are not managed by the host controller. In short, it provides capabilities for starting and stopping the instances on the application server. Domain controller manages the instances running on the host.

The Domain Controller maintains the domain’s central management policy. The policy is to ensure all Host Controllers are aware of its current instances. The controller assists the Host Controllers in configuring the instances. It ensures the instances have a configuration policy.
A server group can be managed and configured as single domain cluster. Each instance deployed on the server is a member of the server group. Domain controller and Host controller maintain the consistent configuration. The multiple instances in a server group need to be configured with the single profile. So, the instances will have the similar deployment content deployed.

3.Download the Source Code

Sample war file can be used for deployment on JBoss WildFly Server


Download

You can download the full source code of this example here: JBoss Wildfly Cluster Example

Bhagvan Kommadi

Bhagvan Kommadi is the Founder of Architect Corner & has around 20 years’ experience in the industry, ranging from large scale enterprise development to helping incubate software product start-ups. He has done Masters in Industrial Systems Engineering at Georgia Institute of Technology (1997) and Bachelors in Aerospace Engineering from Indian Institute of Technology, Madras (1993). He is member of IFX forum,Oracle JCP and participant in Java Community Process. He founded Quantica Computacao, the first quantum computing startup in India. Markets and Markets have positioned Quantica Computacao in ‘Emerging Companies’ section of Quantum Computing quadrants. Bhagvan has engineered and developed simulators and tools in the area of quantum technology using IBM Q, Microsoft Q# and Google QScript. He has reviewed the Manning book titled : "Machine Learning with TensorFlow”. He is also the author of Packt Publishing book - "Hands-On Data Structures and Algorithms with Go".He is member of IFX forum,Oracle JCP and participant in Java Community Process. He is member of the MIT Technology Review Global Panel.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
sailaxman
sailaxman
3 years ago

i have installed wildfly on centos 7 server,how to install cluster on this.please provide any document to do this

Brian Sam-Bodden
Brian Sam-Bodden
3 years ago

Seems you are missing the standalone-load-balancer for the cluster.

Back to top button