WildFly Managed Domain on Raspberry Pi (Tech Tip #27)

Tech Tip #25 showed how to configure WildFly on Raspberry Pi. This tech tip will show how to setup a WildFly managed domain over two hosts running on Raspberry Pi.

Lets understand some basic concepts first.

WildFly can run in two modes:

  • Managed Domain allows you to run and manage a multi-server domain topology
  • Standalone allows to run a single instance of server

Multiple standalone instances can be configured to form a highly available cluster. It is up to the user to coordinate management across multiple servers though.

Servers running in managed domain mode are referred to as the members of a “domain”. A single Domain Controller acts as the central management control point for the domain. A domain can span multiple physical or virtual hosts, with all WildFly instances on a given host under the control of a Host Controller process. One Host Controller instance is configured to act as the Domain Controller. The Host Controller on each host interacts with the Domain Controller to control the lifecycle of the application server instances running on its host and to assist the Domain Controller in managing them.

It is important to understand that administration of servers (standalone or managed domain) is orthogonal to clustering and high availability. In the managed domain mode, a server instance always belong to a Server Group. A domain can have multiple Server Groups. Each group can be configured with different profiles and deployments.

wildfly-clustering-architecture-techtip27

For example, default WildFly installation comes with “main-server-group” and “other-server-group” as shown:

“main-server-group” has two servers: “server-one” and “server-two”. “other-server-group” has one server: “server-three”.

default-server-group-techtip27

By default, these are all configured on a single machine (localhost) with Host Controller and Domain Controller co-located. This is defined in “domain/configuration/host.xml”.

Each Server Group is configured with a profile. These profiles are defined, and associated with a Server Group, in “domain/configuration/domain.xml”. Default WildFly installation comes with two profiles: “full” and “full-ha”.

“main-server-group” is configured with “full” profile and “other-server-group” is configured with “full-ha” profile.

server-group-profiles-techtip27

Profile is a named set of subsystem configurations that adds capabilities like Servlet, EJB, JPA, JTA, etc. The “full-ha” profile also enable all subsystems needed to establish cluster (infinispan, jcluster, and mod_cluster).

OK, enough explanation, lets get into action!

Make sure to install WildFly on each of the Raspberry Pi following Tech Tip #25.

docs.jboss.org/author/display/WFLY8/WildFly+8+Cluster+Howto explain in detail on how to setup Domain Controller and Host Controller on two hosts and enable clustering. This tech tip follows these instructions and adapt them for WildFly. This tech tip will show how to configure WildFly managed domain over two Raspberry Pis.

raspi-cluster-techtip27

A subsequent blog will show how to configure cluster over this managed domain.

Here is what we’ll do:

  • Call one host as “master” and another as “slave”.
  • Both will run WildFly 8.1 CR2, master will run as Domain Controller and slave will run under the domain management of master
  • Deploy a project into domain, and verify that the application is deployed on both master and slave hosts.

Each WildFly was connected to a display to obtain the IP address and enable SSH access. It can be enabled by invoking

Scroll down to the SSH option and enable it. Then the two Raspberry Pis were configured to run in headless mode (no keyboard, mouse, or monitor).

raspi-wildfly-setup-techtip27

  1. Domain Configuration – Configure master and slave “host.xml”
    1. Master configuration
      1. Login to the master Raspberry pi:

        The default password is “raspberry”.
      2. By default, WildFly is configured to run in server VM. As mentioned in Tech Tip #25, this is not support on JDK bundled on Raspbian. This needs to be updated at two places. Edit “bin/domain.sh”:

        and remove the lines marked 80 through 110.
      3. Edit host.xml

        Remove “-server” option by removing lines 75 through 77 as shown below:

         
      4. The default setting for <interfaces> in this file looks like:

        Change this to:

        10.0.0.27 is master’s IP address.
    2. Slave configuration
      1. Login to the slave Raspberry pi:

        The default password is “raspberry”.
      2. Edit “domain.sh” and remove the lines as done for server. This will ensure that non-server, or client, JVM is used for running the domain.
      3. Edit “host.xml”
      4. Set the host name by changing

        to
      5. Remove “-server” option by removing lines 75 through 77 as explained above.
      6. Modify <domain-controller> such that slave can connect to master’s management port. Change

        to

        10.0.0.27 is master’s IP address.
      7. Change the default <interfaces> from:

        to:

        10.0.0.28 is slave’s IP address.
  2. Security Configuration
    1. Master
      1. Using “add-user.sh” script, create a user in Management Realm for master.
      2. Using “add-user.sh” script, create a user in Management Realm for slave. The username must be equal to the name given in the slave’s <host> element in “host.xml”.

        The answer to the last question is “yes” as this slave will be connecting to master.

        Note that output’s last line contains a <secret …> element. Copy this string as this will need to be used in slave’s “host.xml”.

    2. Slave
      1. Configure “domain/configuration/host.xml” for authentication by changing the security-realms element from:

        to

        The <secret …> element added here is obtained when “add-user.sh” is invoked for slave in the previous step. Slave’s host name is “slave”, master has a username by “slave”, and adding <secret …> element (base64 code for the password) allows the slave to connect to master.

  3. Change the default username/password for HornetQ otherwise it will throw a pesky warning in the server log as:

    Edit “domain/configuration/domain.xml” in master and change:

    to

    Make this change in “domain/configuration/domain.xml” for slave as well.

  4. Disable the firewall on master and slave by giving the following command on each host.

  5. Start the master first as:

    The last message in the log will look like:

    After the master has completely started, start the slave as:

    The last message in the log will look like:

    The server log for master will also show a message indicating that the slave is now a registered host with master:

  6. Deploy the application
    1. Check out a simple application that puts/gets some HTTP session data.

      This workspace has other samples related to WildFly. But the one that we care about it is in “clustering/http” directory. Change to that directory and build the sample as:

      This will generate a WAR file in the “target” directory.

    2. “jboss-cli” is a Command Line management tool for standalone and managed domains. It is bundled as a script in the “bin” directory. It can connect to remote servers as well. Now that we’ve Domain Controller running on master and Host Controller running on slave, lets connect it from your local machine as:

      10.0.0.27 is IP address of the master. The generated WAR file can now be deployed as:

      This shows the following output in master’s log:

      And slave’s log shows:

Accessing the application on master (http://10.0.0.27:8330/http-1.0-SNAPSHOT/index.jsp) shows:

master-default-output-techtip27

Accessing the application on slave (http://10.0.0.28:8330/http-1.0-SNAPSHOT/index.jsp) shows:

slave-default-output-techtip27

So we could easily deploy a Java EE application to multiple WildFly instances, running on RaspberryPi, in managed domain mode, with a single command. How cool ?

Next blog will explain how to setup cluster on these multiple instances.

Be Sociable, Share!

3 thoughts on “WildFly Managed Domain on Raspberry Pi (Tech Tip #27)

  1. Hey there! This is kind of off topic but I need some help from an established
    blog. Is it very hard to set up your own blog? I’m not very
    techincal but I can figure things out pretty fast.
    I’m thinking about setting up my own but I’m not sure where to
    start. Do you have any ideas or suggestions?
    Many thanks

    my site; quotes

  2. hello.

    it seems that the layout is broken on this page…. Is see lot of tags from the markup language –> < ….. and the whole page turned unreadable.

Leave a Reply

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


9 × = twenty seven

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">