Tech-Today
How to configure Wildfly 8 clustering and deploying picketlink enabled war application to test the session.
In this tutorial we will try to configure wildfly cluster and test it by deploying a picketlink enabled war application where a user can login and the session shared between the virtual server.
Before we start, make sure that you read these links:
https://docs.jboss.org/author/display/AS71/AS7+Cluster+Howto
http://blog.arungupta.me/2014/03/wildfly-8-clustering-and-session-failover/
The concept of wildfly clustering is already discussed in the previous links so we will just enumerate the steps we've done and provide a sample war.
This is how I configured my servers (note that I'm using Wildfly 8.1 Final). Basically we have 2 physical machine, windows (master) and slave (ubuntu). Windows is the domain controller, while ubuntu has host controller and 2 virtual servers. Note that we need to manually deploy wildfly on both servers.
-Windows (IP=192.168.0.100)
--domain controller
-Ubuntu (IP=192.168.0.116)
--host controller
2 server groups
-main-server-group
-other-server-group
You may refer to the following images for reference.
Master
Slave
We need to create a slave user in the master's machine. This user will be use by the slave server later on. To create a user account (username / password) run wildfly/bin/add-user.bat. Take note of the password as we will need to convert it later to base64.
Here are the configuration changes that we need to do:
On master, wildfly/domain/configuration/host.xml, we need to update the correct ip address, don't use 127.0.0.1:
<interfaces>
<interface name="management">
<inet-address value="${jboss.bind.address.management:192.168.0.100}"/>
</interface>
<interface name="public">
<inet-address value="${jboss.bind.address:192.168.0.100}"/>
</interface>
<interface name="unsecure">
<inet-address value="${jboss.bind.address.unsecure:192.168.0.100}"/>
</interface>
</interfaces>
Then on slave machine, rename host.xml to host.bak.xml and rename host-slave.xml to host.xml. We need to update the following:
//set host name to slave
<host name="slave" xmlns="urn:jboss:domain:2.1">
//set domain controller, point to master's ip
<domain-controller>
<remote host="192.168.0.100" port="${jboss.domain.master.port:9999}" security-realm="ManagementRealm"/>
</domain-controller>
//set the secret key, basically it's the base64 representation of your slave password
//http://www.freeformatter.com/base64-encoder.html
<server-identities>
<!-- Replace this with either a base64 password of your own, or use a vault with a vault expression -->
<secret value="xxxxxx"/>
</server-identities>
In your master's domain.xml file, don't forget to set the hornetq-server's cluster-password.
<subsystem xmlns="urn:jboss:domain:messaging:2.0">
<hornetq-server>
<cluster-password>${jboss.messaging.cluster.password:absolutely}</cluster-password>
Run the server on both machine. And you should get the images I've posted above. The topology will become:
To test if the clustering is working download the project from:
https://github.com/czetsuya/picketlink-authentication-jsf
Download, build with maven and deploy on the 2 server groups:
Now we can access the application from:
http://192.168.0.110:8080/jboss-as-picketlink-authentication-jsf/home.jsf
To test if clustering is working we need to setup cluster module from apache which is properly documented here: https://docs.jboss.org/author/display/AS71/AS7+Cluster+Howto.
-
How To Run A Wildfly Server Inside Docker
Before we begin you must configure docker, I am using Ubuntu so I followed the guide here: https://docs.docker.com/engine/installation/linux/ubuntulinux/. Choose the appropriate OS that applies to you. Let's do this in sequence: Checkout and...
-
Javaee Development
JavaEE6How to create a javaee6 web app using jboss maven war archetypeCreate a simple javaee6 web app with maven, glassfish and postgresqlHow to validate a JavaEE6 Bean in a jobHow to add JavaEE 6 archetypes in eclipse keplerHow to create a custom bean...
-
How To Configure Mail Resource In Jboss 7.2 With A Sample Java Client
This tutorial assumes that you have the following installed on your local system: JBoss 7.2eclipse to run a projecta mail server, can be gmailIn this page we will summarize how to configure a mail dataSource in Jboss and create a JavaEE6 client to send...
-
How To Create A Glassfish Cluster
This tutorial will attempt to explain, how to create a Glassfish cluster using the Glassfish's admin interface. To do this, you must have download, install and configured Glassfish's domain1 to start. Steps: 1.) Create nodes (What are nodes? See...
-
How To Enable Remote Jvm Monitoring Using Jre's Built In Jconsole
This guide will help you setup a remote jvm monitoring tool using jconsole. The setup: 1.) Ubuntu 12.04 2.) Glassfish 3.1.2.2 3.) jdk1.6.0_32 Steps: 1.) In your glassfish's default domain1 domain.xml file, /glassfish_home/glassfish/domains/domain1/config/domain.xml,...
Tech-Today