Building a Mission-Critical Open Source Java Platform - Installing WildFly
In this article we'll continue exploring how to build a mission-critical open source Java platform by installing WildFly and configure our platforms topology...
Join the DZone community and get the full member experience.
Join For Freein the previous article in this series introduced our thoughts on setting up a mission-critical open source java platform using high availability in our web layer . in this article we'll continue by installing wildfly and configure our platforms topology.
note: the terminology in this article, where possible, has been adjusted from the traditional master / slave descriptions to master / subordinate. some of the images displayed have not yet been updated and show the older terminology.
installing
let’s start building the application layer of our environment.these settings will be performed on the following servers:
- server-domain.mmagnani.lab - 10.0.0.193
- server-subordinate-0.mmagnani.lab -10.0.0.194
- server-subordinate-1.mmagnani.lab - 10.0.0.195
[root@server-domain ~]# cat /etc/redhat-release
centos linux release 8.2.2004 (core)
[root@server-domain ~]# systemctl stop firewalld
[root@server-domain ~]# systemctl disable firewalld
[root@server-domain ~]# setenforce 0
[root@server-domain ~]# sed -i "s/^selinux=enforcing/selinux=disabled/g" /etc/selinux/config
[root@server-domain ~]# dnf install java-11-openjdk-devel.x86_64 vim wget unzip telnet -y
[root@server-domain ~]# mkdir -p /usr/local/wildfly
[root@server-domain ~]# wget https://download.jboss.org/wildfly/20.0.0.final/wildfly-20.0.0.final.zip -p /usr/local/wildfly
[root@server-domain ~]# cd /usr/local/wildfly
[root@server-domain ~]# unzip wildfly-20.0.0.final.zip
[root@server-domain ~]# useradd -p `openssl passwd -1 wildfly` wildfly
[root@server-domain ~]# usermod -ag wildfly wildfly
[root@server-domain ~]# chown -r wildfly:wildfly /usr/local/wildfly/wildfly-20.0.0.final
[root@server-domain ~]# vi /etc/systemd/system/wildfly.service
description=wildfly 20.0.0
after=syslog.target network.target
[service]
type=simple
execstart=/usr/local/wildfly/wildfly-20.0.0.final/bin/domain.sh
[install]
wantedby=multi-user.target
[root@server-domain ~]# systemctl enable wildfly
[root@server-domain ~]# reboot
check that the wildfly process has gone up correctly:
[root@server-domain ~]# jps -m
1571 jboss-modules.jar -mp /usr/local/wildfly/wildfly-20.0.0.final/modules
##supressed
now let’s set up “subordinate 0”:
[root@server-subordinate-0 ~]# cat /etc/redhat-release
centos linux release 8.2.2004 (core)
[root@server-subordinate-0 ~]# systemctl stop firewalld
[root@server-subordinate-0 ~]# systemctl disable firewalld
[root@server-subordinate-0 ~]# setenforce 0
[root@server-subordinate-0 ~]# sed -i "s/^selinux=enforcing/selinux=disabled/g" /etc/selinux/config
[root@server-subordinate-0 ~]# dnf install java-11-openjdk-devel.x86_64 vim wget unzip telnet -y
[root@server-subordinate-0 ~]# mkdir -p /usr/local/wildfly
[root@server-subordinate-0 ~]# wget https://download.jboss.org/wildfly/20.0.0.final/wildfly-20.0.0.final.zip -p /usr/local/wildfly
[root@server-subordinate-0 ~]# cd /usr/local/wildfly
[root@server-subordinate-0 ~]# unzip wildfly-20.0.0.final.zip
[root@server-subordinate-0 ~]# useradd -p `openssl passwd -1 wildfly` wildfly
[root@server-subordinate-0 ~]# usermod -ag wildfly wildfly
[root@server-subordinate-0 ~]# chown -r wildfly:wildfly /usr/local/wildfly/wildfly-20.0.0.final
[root@server-subordinate-0 ~]# vi /etc/systemd/system/wildfly.service
description=wildfly 20.0.0
after=syslog.target network.target
[service]
type=simple
execstart=/usr/local/wildfly/wildfly-20.0.0.final/bin/domain.sh
[install]
wantedby=multi-user.target
[root@server-subordinate-0 ~]# systemctl enable wildfly
[root@server-subordinate-0 ~]# reboot
check that the wildfly process has gone up correctly:
[root@server-subordinate-0 ~]# jps -m
1968 jboss-modules.jar -mp /usr/local/wildfly/wildfly-20.0.0.final/modules
##supressed
and now let’s set up “subordinate 1”:
[root@server-subordinate-1 ~]# cat /etc/redhat-release
centos linux release 8.2.2004 (core)
[root@server-subordinate-1 ~]# systemctl stop firewalld
[root@server-subordinate-1 ~]# systemctl disable firewalld
[root@server-subordinate-1 ~]# setenforce 0
[root@server-subordinate-1 ~]# sed -i "s/^selinux=enforcing/selinux=disabled/g" /etc/selinux/config
[root@server-subordinate-1 ~]# dnf install java-11-openjdk-devel.x86_64 vim wget unzip telnet -y
[root@server-subordinate-1 ~]# mkdir -p /usr/local/wildfly
[root@server-subordinate-1 ~]# wget https://download.jboss.org/wildfly/20.0.0.final/wildfly-20.0.0.final.zip -p /usr/local/wildfly
[root@server-subordinate-1 ~]# cd /usr/local/wildfly
[root@server-subordinate-1 ~]# unzip wildfly-20.0.0.final.zip
[root@server-subordinate-1 ~]# useradd -p `openssl passwd -1 wildfly` wildfly
[root@server-subordinate-1 ~]# usermod -ag wildfly wildfly
[root@server-subordinate-1 ~]# chown -r wildfly:wildfly /usr/local/wildfly/wildfly-20.0.0.final
[root@server-domain wildfly]# vi /etc/systemd/system/wildfly.service
description=wildfly 20.0.0
after=syslog.target network.target
[service]
type=simple
execstart=/usr/local/wildfly/wildfly-20.0.0.final/bin/domain.sh
[install]
wantedby=multi-user.target
[root@server-subordinate-1 ~]# systemctl enable wildfly
[root@server-subordinate-1 ~]# reboot
check that the wildfly process has gone up correctly:
[root@server-subordinate-1 ~]# jps -m
1948 jboss-modules.jar -mp /usr/local/wildfly/wildfly-20.0.0.final/modules
##supressed
it is! finally we have wildfly running in domain mode on all three servers.
configuring the master/subordinate architecture
this part of the setup will need a little more hard work because requires attention to detail but don’t worry, let’s go step by step.
the first step is to set the variables correctly so wildfly can understand where our settings are and what we want to do with them.
edit the
domain.conf
file and add the binding settings for the
java_opts
variable:
##around line 50
[root@server-domain ~]# vim /usr/local/wildfly/wildfly-20.0.0.final/bin/domain.conf
if [ "x$java_opts" = "x" ]; then
java_opts="-xms64m -xmx512m -xx:maxmetaspacesize=256m -djava.net.preferipv4stack=true"
java_opts="$java_opts -djboss.modules.system.pkgs=$jboss_modules_system_pkgs -djava.awt.headless=true"
#add this line
java_opts="$java_opts -djboss.bind.address.management=10.0.0.193 -djboss.bind.address=10.0.0.193"
else
##supressed
restart wildfly service and open the server url and note that wildfly is running and accessible: http://10.0.0.193:8080
[root@server-domain ~]# systemctl restart wildfly

the next step is to create/update a management user and a directory for the domain to starting the configuration of wildfly server topology.
[root@server-domain ~]# cd /usr/local/wildfly/wildfly-20.0.0.final/bin
[root@server-domain ~]# ./add-user.sh
what type of user do you wish to add?
a) management user (mgmt-users.properties)
b) application user (application-users.properties)
(a): a
enter the details of the new user to add.
using realm 'managementrealm' as discovered from the existing property files.
username : admin
user 'admin' already exists and is disabled, would you like to...
a) update the existing user password and roles
b) enable the existing user
c) type a new username
(a): a
password recommendations are listed below. to modify these restrictions edit the add-user.properties configuration file.
- the password should be different from the username
- the password should not be one of the following restricted values {root, admin, administrator}
- the password should contain at least 8 characters, 1 alphabetic character(s), 1 digit(s), 1 non-alphanumeric symbol(s)
password : redhat*#2
re-enter password : redhat*#2
what groups do you want this user to belong to? (please enter a comma separated list, or leave blank for none)[ ]:
updated user 'admin' to file '/usr/local/wildfly/wildfly-20.0.0.final/standalone/configuration/mgmt-users.properties'
updated user 'admin' to file '/usr/local/wildfly/wildfly-20.0.0.final/domain/configuration/mgmt-users.properties'
updated user 'admin' with groups to file '/usr/local/wildfly/wildfly-20.0.0.final/standalone/configuration/mgmt-groups.properties'
updated user 'admin' with groups to file '/usr/local/wildfly/wildfly-20.0.0.final/domain/configuration/mgmt-groups.properties'
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="umvkagf0kimy" />
take note of the , this will be used to configure the subordinate connection.
now create a new directory called “master” based on the “domain” directory.
[root@server-domain ~]# pwd
/usr/local/wildfly/wildfly-20.0.0.final
[root@server-domain ~]# cp -rap domain master
edit again the
domain.conf
file and add the configuration dir settings for the
java_opts
variable:
##around line 50
[root@server-domain ~]# vim /usr/local/wildfly/wildfly-20.0.0.final/bin/domain.conf
if [ "x$java_opts" = "x" ]; then
java_opts="-xms64m -xmx512m -xx:maxmetaspacesize=256m -djava.net.preferipv4stack=true"
java_opts="$java_opts -djboss.modules.system.pkgs=$jboss_modules_system_pkgs -djava.awt.headless=true"
#edit this line
java_opts="$java_opts -djboss.bind.address.management=10.0.0.193 -djboss.bind.address=10.0.0.193 -djboss.domain.base.dir=/usr/local/wildfly/wildfly-20.0.0.final/master"
else
##supressed
restart wildfly service and access the management url by logging in with user “admin” and previously updated password: http://10.0.0.193:9990
[root@server-domain ~]# systemctl restart wildfly

in the management console you will notice that we are still using the standard topology but we will work on it in the next steps.

edit the domain.xml file and update the existing groups. the groups must be called “marketing” and “accounting” that will use the “full-ha” profile and “full-ha-sockets”.
[root@server-domain ~]# pwd
/usr/local/wildfly/wildfly-20.0.0.final
[root@server-domain ~]# vim master/configuration/domain.xml
##around line 1895
<server-groups>
<server-group name="marketing" profile="full-ha">
<jvm name="default">
<heap size="64m" max-size="512m"/>
</jvm>
<socket-binding-group ref="full-ha-sockets"/>
</server-group>
<server-group name="accounting" profile="full-ha">
<jvm name="default">
<heap size="64m" max-size="512m"/>
</jvm>
<socket-binding-group ref="full-ha-sockets"/>
</server-group>
</server-groups>
##suppressed
save the domain.xml file.
edit again the
domain.conf
file and add the configuration file settings for the
java_opts
variable:
##around line 50
[root@server-domain ~]# vi /usr/local/wildfly/wildfly-20.0.0.final/bin/domain.conf
if [ "x$java_opts" = "x" ]; then
java_opts="-xms64m -xmx512m -xx:maxmetaspacesize=256m -djava.net.preferipv4stack=true"
java_opts="$java_opts -djboss.modules.system.pkgs=$jboss_modules_system_pkgs -djava.awt.headless=true"
#edit this line
java_opts="$java_opts -djboss.bind.address.management=10.0.0.193 -djboss.bind.address=10.0.0.193 -djboss.domain.base.dir=/usr/local/wildfly/wildfly-20.0.0.final/master -djboss.host.default.config=host-master.xml"
else
##suppressed
restart the wildfly service.
[root@server-domain ~]# systemctl restart wildfly
note that now a new topology will be presented:

the next step is to create the configuration of “subordinate 0” and connect it to “master”.
[root@server-subordinate-0 ~]# pwd
/usr/local/wildfly/wildfly-20.0.0.final
[root@server-subordinate-0 ~]# cp -rap domain subordinate0
edit the host-slave.xml file. add subordinate name and update the existing servers. the servers must be called “server-marketing-0” and “server-accounting-0”. servers must belong to their own group: marketing and accounting.
[root@server-subordinate-0 ~]# vim subordinate0/configuration/host-slave.xml
<?xml version='1.0' encoding='utf-8'?>
##around line 3
<host xmlns="urn:jboss:domain:13.0" name="subordinate0">
<extensions>
##suppressed
##around line 89
<servers>
<server name="server-marketing-0" group="marketing"/>
<server name="server-accounting-0" group="accounting">
<socket-bindings port-offset="100"/>
</server>
</servers>
##suppressed
we also have to set the user and “secret” created in the master so we can connect the “subordinate 0”.
in this same host-slave.xml file add the secret and user:
##around line 13
<security-realms>
<security-realm name="managementrealm">
<server-identities>
<secret value="umvkagf0kimy" />
##supress
##around line 65
<domain-controller>
<remote security-realm="managementrealm" username="admin">
<discovery-options>
<static-discovery name="primary" protocol="${jboss.domain.master.protocol:remote+http}" host="${jboss.domain.master.address}" port="${jboss.domain.master.port:9990}"/>
##suppressed
edit again the
domain.conf
file and add the configuration file settings for the
java_opts
variable:
[root@server-subordinate-0 ~]# vim /usr/local/wildfly/wildfly-20.0.0.final/bin/domain.conf
##around line 50
if [ "x$java_opts" = "x" ]; then
java_opts="-xms64m -xmx512m -xx:maxmetaspacesize=256m -djava.net.preferipv4stack=true"
java_opts="$java_opts -djboss.modules.system.pkgs=$jboss_modules_system_pkgs -djava.awt.headless=true"
##add this line
java_opts="$java_opts -djboss.domain.base.dir=/usr/local/wildfly/wildfly-20.0.0.final/subordinate0 -djboss.host.default.config=host-slave.xml -djboss.domain.master.address=10.0.0.193 -djboss.bind.address=10.0.0.194"
else
##suppressed
restart the wildfly service:
[root@server-subordinate-0 ~]# systemctl restart wildfly
in the “host master” logs you can see the “host subordinate 0” connection log.
[root@server-domain ~]# tail -f /usr/local/wildfly/wildfly-20.0.0.final/master/log/host-controller.log
2020-07-06 16:39:04,153 info [org.jboss.as.domain.controller] (host controller service threads - 24) wflyhc0019: registered remote slave host "subordinate0", jboss wildfly full 20.0.0.final (wildfly 12.0.1.final)
open the management console to see the updated topology: http://10.0.0.193:9990/console

now perform the same procedure for “subordinate 1”.
[root@server-subordinate-1 ~]# pwd
/usr/local/wildfly/wildfly-20.0.0.final
[root@server-subordinate-1 ~]# cp -rap domain subordinate1
edit the host-slave.xml file. add subordinate name and update the existing servers. the servers must be called “server-marketing-1” and “server-accounting-1”. servers must belong to their own group: marketing and accounting.
[root@server-subordinate-1 ~]# vim subordinate1/configuration/host-slave.xml
<?xml version='1.0' encoding='utf-8'?>
##around line 3
<host xmlns="urn:jboss:domain:13.0" name="subordinate1">
<extensions>
##suppressed
##around line 89
<servers>
<server name="server-marketing-1" group="marketing"/>
<server name="server-accounting-1" group="accounting">
<socket-bindings port-offset="100"/>
</server>
</servers>
##suppressed
we also have to set the user and “secret” created in the master so we can connect the “subordinate 1”.
in this same host-slave.xml file add the secret and user:
##around line 13
<security-realms>
<security-realm name="managementrealm">
<server-identities>
<secret value="umvkagf0kimy" />
##supress
##around line 65
<domain-controller>
<remote security-realm="managementrealm" username="admin">
<discovery-options>
<static-discovery name="primary" protocol="${jboss.domain.master.protocol:remote+http}" host="${jboss.domain.master.address}" port="${jboss.domain.master.port:9990}"/>
##suppressed
edit again the
domain.conf
file and add the configuration file settings for the
java_opts
variable:
[root@server-subordinate-1 ~]# vim /usr/local/wildfly/wildfly-20.0.0.final/bin/domain.conf
##around line 50
if [ "x$java_opts" = "x" ]; then
java_opts="-xms64m -xmx512m -xx:maxmetaspacesize=256m -djava.net.preferipv4stack=true"
java_opts="$java_opts -djboss.modules.system.pkgs=$jboss_modules_system_pkgs -djava.awt.headless=true"
##add this line
java_opts="$java_opts -djboss.domain.base.dir=/usr/local/wildfly/wildfly-20.0.0.final/subordinate1 -djboss.host.default.config=host-slave.xml -djboss.domain.master.address=10.0.0.193 -djboss.bind.address=10.0.0.195"
else
##suppressed
restart the wildfly service:
[root@server-subordinate-1 ~]# systemctl restart wildfly
in the “host master” logs you can see the “host subordinate 1” connection log.
[root@server-domain ~]# tail -f /usr/local/wildfly/wildfly-20.0.0.final/master/log/host-controller.log
2020-07-06 16:48:27,522 info [org.jboss.as.domain.controller] (host controller service threads - 24) wflyhc0019: registered remote slave host "subordinate1", jboss wildfly full 20.0.0.final (wildfly 12.0.1.final)
open the management console again to see the updated topology: http://10.0.0.193:9990/console
now we have our topology with one host master, two host subordinates and four wildfly instances. in the next article, we'll be tuning wildfly before deploying our application.
Published at DZone with permission of Mauricio Magnani. See the original article here.
Opinions expressed by DZone contributors are their own.
Trending
-
Top 10 Engineering KPIs Technical Leaders Should Know
-
Automating the Migration From JS to TS for the ZK Framework
-
Operator Overloading in Java
-
Reactive Programming
Comments