
Wildfly application server provides two modes of how to run application one wildfly application server. It is very simple if you run your application on a single server for one instance. But in case you are running your application on a cluster of server a cross multliple instances, managing those servers' instances could be quite challenging. In this case, Wildfly Application provide domain mode to run and manage application on multiple instances.
Wildfly application server domain mode is a way of managing multiple Wildfly instances from a single point of control. It allows you to configure, deploy, monitor and administer your applications across different hosts and servers. In domain mode, you have a domain controller that acts as the central authority for the configuration and operations of all the servers in the domain. You also have one or more host controllers that manage the local servers on each host machine. The domain controller and the host controllers communicate through a secure management protocol. Each Server group share configuration with all instances.
In this post, I will show you how to configure Wildfly Application to run in the domain mode by configuring domain controller, host controller, creating server group, creating host and adding host to those server group. The content of this post is organized as below.
Content table
- Configuring Domain Mode ( Domain Controller and Host Controller)
- Create Server Groups and Hosts
- References
For my environment, I have used as below setup
- OS : Ubuntu 20.04
- Application Server : Wildlfly 23.0.2
- Runtime : OpenJDK 11
Configuring Domain Mode (Domain Controller and Host Controller)
First, we need to configure domain controller server. Once you have finished installing wildfly application server, you need to change wildfly from statndalone mode to domain mode.
$sudo vim /etc/wildfly/wildfly.conf
# The configuration you want to run
WILDFLY_CONFIG=domain.xml
# The mode you want to run
WILDFLY_MODE=domain
# The address to bind to
WILDFLY_BIND=0.0.0.0
Next is to edit /etc/systemd/system/widfly.service
$ sudo vim /etc/systemd/system/wildfly.service
[Unit]
Description=The WildFly Application Server
After=syslog.target network.target
Before=httpd.service
[Service]
Environment=LAUNCH_JBOSS_IN_BACKGROUND=1
EnvironmentFile=-/etc/wildfly/wildfly.conf
User=root
LimitNOFILE=102642
PIDFile=/var/run/wildfly/wildfly.pid
ExecStart=/opt/wildfly/bin/launch.sh $WILDFLY_MODE $WILDFLY_CONFIG $WILDFLY_BIND
StandardOutput=null
[Install]
WantedBy=multi-user.target
Now, we will configure domain.xml and host.xml. First, we will configure domain.xml. In the domain.xml, you need to define server-group in the server-groups
$cd /opt/wildfly/domain/configuration/
$sudo cp domain.xml domain.xml.bak
$sudo vim domain.xml
<server-groups>
<server-group name="backend-server-group" profile="full">
<jvm name="default">
<heap size="64m" max-size="512m"/>
</jvm>
<socket-binding-group ref="full-sockets"/>
</server-group>
</server-groups>
Next is to configure host.xml. In the host.xml file, you need to set define management interface
$sudo cp host.xml host.xml.bak
$sudo cp host.xml host.xml.org
$sudo cp host-master.xml host.xml
$sudo vim host.xml
<!-- add native interface -->
<management-interfaces>
<native-interface security-realm="ManagementRealm">
<socket interface="management" port="${jboss.managment.native.port:9999}"/>
</native-interface>
<http-interface security-realm="ManagementRealm">
<http-upgrade enabled="true"/>
<socket interface="management" port="${jboss.management.http.port:9990}"/>
</http-interface>
</management-interfaces>
<!-- allow IP -->
<interfaces>
<interface name="management">
<inet-address value="0.0.0.0"/>
</interface>
<interface name="public">
<inet-address value="0.0.0.0"/>
</interface>
</interfaces>
Then, you add user for wildfly application server.
$cd /opt/widlfly/bin
$bash 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 : widlfyuser
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 :
Re-enter Password :
What groups do you want this user to belong to? (Please enter a comma separated list, or leave blank for none)[ ]:
About to add user 'widlfyuser' for realm 'ManagementRealm'
Is this correct yes/no? yes
Added user 'widlfyuser' to file '/opt/wildfly/standalone/configuration/mgmt-users.properties'
Added user 'widlfyuser' to file '/opt/wildfly/domain/configuration/mgmt-users.properties'
Added user 'widlfyuser' with groups to file '/opt/wildfly/standalone/configuration/mgmt-groups.properties'
Added user 'widlfyuser' with groups to file '/opt/wildfly/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 Jakarta Enterprise Beans calls.
yes/no? yes
To represent the user add the following to the server-identities definition <secret value="QWJjZEAxMjM/" />
It is important that you need to take note of <secret value="QWJjZEAxMjM/" />
Now, you need to restart the wildfly application server
$sudo systemctl restart wildfly
Create Server Group and Add Host to domain controller
After you finished configuring domain controller server (for domain.xml and host.xml), you need to configure host (slave) server to add those host to the domain controller. For the host server, you don't need domain.xml
$cd /opt/wildfly/domain/configuration
$sudo mv domain.xml domain.xml.bak
$sudo cp host.xm host.xml.bak
$sudo mv host-slave.xml host.xml
<!-- Add password for wildflyuser -->
<security-realm name="ManagementRealm">
<server-identities>
<secret value="QWJjZEAxMjM/" />
</server-identities>
<authentication>
<local default-user="$local" skip-group-loading="true"/>
<properties path="mgmt-users.properties" relative-to="jboss.domain.config.dir"/>
</authentication>
<authorization map-groups-to-roles="false">
<properties path="mgmt-groups.properties" relative-to="jboss.domain.config.dir"/>
</authorization>
</security-realm> <!-- change port for local management interface -->
<management-interfaces>
<http-interface security-realm="ManagementRealm">
<http-upgrade enabled="true"/>
<socket interface="management" port="${jboss.management.http.port:19990}"/>
</http-interface>
</management-interfaces>
<!-- specify domain controller -->
<domain-controller>
<remote security-realm="ManagementRealm" username="wildflyuser">
<discovery-options>
<static-discovery name="primary" protocol="${jboss.domain.master.protocol:remote+http}" host="${jboss.domain.master.address}" port="${jboss.domain.master.port:9990}"/>
</discovery-options>
</remote>
</domain-controller>
<!-- allow IP for management interface -->
<interfaces>
<interface name="management">
<inet-address value="0.0.0.0"/>
</interface>
<interface name="public">
<inet-address value="0.0.0.0"/>
</interface>
</interfaces>
<!-- create server in the server group -->
<servers>
<server name="server-1" group="backend-server-group"/>
</servers>
Now, restart your application server and you could be able to register server-1 to domain controller.
No comments:
Post a Comment