Book Image

Wildfly Cookbook

Book Image

Wildfly Cookbook

Overview of this book

Table of Contents (23 chapters)
WildFly Cookbook
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Running WildFly in domain mode


The Domain mode is something totally new since JBoss AS 4, 5, and 6. It was first introduced in JBoss AS 7.

It's about grouping several WildFly instances into one single group, a server-group using the WildFly nomenclature. In fact, we group the WildFly server into one logical server-group, and all the WildFly instances will share the same configuration. By this we intend that they share the same WildFly profile (default, ha, full, and full-ha), same deployments, and so on. What will not be shared is specific instance configuration such as IP bind address, ports, and others.

Suppose you have an application and you want it to deploy on four servers of your infrastructure (or test rather than preproduction or production). You will need to configure a server-group, associate the four server instances to it, and you are done. Dealing just with the server-group, all your settings and changes will be spread to all the related server instances. This was definitely a big miss in JBoss AS, but now we have it.

Note

Remember that a server-group does not form a cluster in any way.

Getting ready

When dealing with domain mode, there are two new terms to know and understand: domain controller (DC) and host controller (HC).

The first one, the DC, acts as the parent process, the "gran maestro" of an orchestra. Every single change is provided by the DC towards all the HCs of all server-groups. The DC configuration file is named domain.xml, whilst the HC configuration file is named host.xml.

Note

To avoid confusion, it's better to clarify the terminology that we will use in the book. We might refer to the server running the domain controller as the "master" or the "domain". Alternatively, we might refer to a running WildFly instance that is not the domain, as the "host", or "slave".

One more thing to know is that contrary to the standalone mode where you have different files for different profiles, in the domain mode you end up with just one file (there is another one named host.xml, but we will talk about it soon) having all the profiles configured in for you. Profiles are the same as for the standalone mode. We will learn how to associate a profile to a server-group in the chapter dedicated to the domain mode.

Let's have a look at the domain folder:

Folder's name

Description

configuration

Configuration files for the domain and for the host controller and any servers running off this installation. All configuration information for the servers managed within the domain is located here and is the single place for configuration information.

content

An internal working area for the host controller that controls this installation. This is where it internally stores the deployment content. This directory is generated by WildFly when it starts and is not meant to be manipulated by the end users. Note that the domain mode does not support deploying content based on scanning a file system.

lib/ext

Location for the installed library jars referenced by applications using the Extension-List mechanism.

log

Location where the host controller process writes its logs. The process controller, a small lightweight process that actually spawns the other host controller processes and any application server processes also writes a log here.

servers

Writable area used by each application server instance that runs from this installation. Each application server instance will have its own subdirectory, created when the server is first started. In each server's subdirectory there will be the following subdirectories:

  • data: Information written by the server that needs to survive a restart of the server

  • log: The server's log files

  • tmp: Location for temporary files written by the server

tmp

Location for temporary files written by the server

tmp/auth

Special location used to exchange authentication tokens with local clients so they can confirm that they are local to the running AS process.

So, the configuration folder contains all the configuration files. Let's have a look at all of them:

File name

Description

domain.xml (default name)

This is the main configuration file that includes all WildFly profiles plus all other configurations needed to run the AS. When WildFly starts, it will look for a file named domain.xml if not differently specified.

host.xml (default name)

This is the host controller configuration file provided by the WildFly installation. In this you will find the entire specific configurations about server instances. When WildFly starts, it will look for a file named host.xml if not differently specified.

host-master.xml

This is a host controller configuration example file provided by the WildFly installation. It shows you how to configure WildFly running only the domain controller.

host-slave.xml

This is a host controller configuration example file provided by the WildFly installation used to configure WildFly running as slave and connecting to the domain controller.

How to do it...

Let's try running WildFly in the domain mode with its default settings (two server-groups—first one with two instances named server-one and server-two, last one with one instance named server-three with auto-start disabled). Do as follows:

$ CD $WILDFLY_HOME
$ ./bin/domain.sh -b 0.0.0.0 -bmanagement 0.0.0.0
====================================================================

  JBoss Bootstrap Environment

  JBOSS_HOME: /home/wildfly/WFC/wildfly

  JAVA: /home/wildfly/WFC/jdk8/bin/java

  JAVA_OPTS: -Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true

====================================================================

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
08:50:53,715 INFO  [org.jboss.modules] (main) JBoss Modules version 1.4.2.Final
08:50:53,804 INFO  [org.jboss.as.process.Host Controller.status] (main) WFLYPC0018: Starting process 'Host Controller'
[Host Controller] Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[Host Controller] 08:50:54,154 INFO  [org.jboss.modules] (main) JBoss Modules version 1.4.2.Final
[Host Controller] 08:50:54,841 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.4.Final
[Host Controller] 08:50:54,869 INFO  [org.jboss.as] (MSC service thread 1-7) WFLYSRV0049: WildFly Full 9.0.0.Beta2 (WildFly Core 1.0.0.Beta2) starting
[Host Controller] 08:50:55,326 INFO  [org.xnio] (MSC service thread 1-7) XNIO version 3.3.0.Final
[Host Controller] 08:50:55,328 INFO  [org.jboss.as] (Controller Boot Thread) WFLYHC0003: Creating http management service using network interface (management) port (9990) securePort (-1)
[Host Controller] 08:50:55,332 INFO  [org.xnio.nio] (MSC service thread 1-7) XNIO NIO Implementation Version 3.3.0.Final
[Host Controller] 08:50:55,391 INFO  [org.jboss.remoting] (MSC service thread 1-7) JBoss Remoting version 4.0.8.Final
[Host Controller] 08:50:55,415 INFO  [org.jboss.as.remoting] (MSC service thread 1-1) WFLYRMT0001: Listening on 0.0.0.0:9999
[Host Controller] 08:50:56,189 INFO  [org.jboss.as.host.controller] (Controller Boot Thread) WFLYHC0023: Starting server server-one
08:50:56,199 INFO  [org.jboss.as.process.Server:server-one.status] (ProcessController-threads - 3) WFLYPC0018: Starting process 'Server:server-one'
[Server:server-one] 08:50:56,527 INFO  [org.jboss.modules] (main) JBoss Modules version 1.4.2.Final
[Server:server-one] 08:50:56,692 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.4.Final
[Server:server-one] 08:50:56,753 INFO  [org.jboss.as] (MSC service thread 1-7) WFLYSRV0049: WildFly Full 9.0.0.Beta2 (WildFly Core 1.0.0.Beta2) starting
...
[Host Controller] 08:50:57,401 INFO  [org.jboss.as.domain.controller.mgmt] (Remoting "master:MANAGEMENT" task-4) WFLYHC0021: Server [Server:server-one] connected using connection [Channel ID 56504cde (inbound) of Remoting connection 0f0a1d33 to /192.168.59.3:50968]
[Host Controller] 08:50:57,420 INFO  [org.jboss.as.host.controller] (Controller Boot Thread) WFLYHC0023: Starting server server-two
08:50:57,423 INFO  [org.jboss.as.process.Server:server-two.status] (ProcessController-threads - 3) WFLYPC0018: Starting process 'Server:server-two'
[Host Controller] 08:50:57,430 INFO  [org.jboss.as.host.controller] (server-registration-threads - 1) WFLYHC0020: Registering server server-one
...
[Server:server-two] 08:50:58,213 INFO  [org.jboss.modules] (main) JBoss Modules version 1.4.2.Final
[Server:server-two] 08:50:58,513 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.4.Final
[Server:server-two] 08:50:58,621 INFO  [org.jboss.as] (MSC service thread 1-6) WFLYSRV0049: WildFly Full 9.0.0.Beta2 (WildFly Core 1.0.0.Beta2) starting

How it works...

The domain controller is responsible for initiating all local host controllers along with the configured instances. Now, opening the WildFly Admin Console, you can see an overview of the details of both your instances:

WildFly's runtime domain overview

From the domain perspective, you can see two server-groups named main-server-group with full profile and the other-server-group with full-ha profile. The latter is not running because its auto-start property is set to false.

Note

This time, even if running in the domain mode for the first time, we did not have to create a new user, because we already did so while setting up the standalone mode.

See also

We will take a deep dive into the domain mode soon. In Chapter 3, Running WildFly in Domain Mode, all configuration files will be described in detail apart from learning how to choose the correct profile and how to manage your instance with both the Admin Console and the CLI. We will analyze the domain and host controller processes. We will create various examples of server groups, running locally and in pseudo-different machines. We will also deploy both the management tools and analyze how this behaves in the domain mode.