Bookmark this page

Guided Exercise: Configuring Host Controllers

Create two host controllers and configure them to be secondaries to the previously created domain controller.

Resources
Files: /home/student/AD248/labs/domain-host
Application URL: http://172.25.250.9:8230/ http://172.25.250.9:9080/ http://172.25.250.9:8080/

Outcomes

You should be able to start two host controllers that are secondaries to a domain controller.

Before beginning the guided exercise, run the following command to prepare the environment:

[student@workstation ~]$ lab start domain-host

The /home/student/AD248/labs/domain-host directory contains a configured Red Hat JBoss Enterprise Application Platform (JBoss EAP) domain controller in the machine1 directory. In this exercise, you simulate two new host controllers by using the machine2, and machine3 directories.

Instructions

  1. Create additional base directories for two host controllers.

    1. In your /home/student/AD248/labs/domain-host directory, create two subdirectories: machine2 and machine3.

      [student@workstation ~]$ cd /home/student/AD248/labs/domain-host
      [student@workstation domain-host]$ mkdir machine2
      [student@workstation domain-host]$ mkdir machine3
    2. Copy the directory opt/jboss-eap-7.4/domain/configuration into both the machine2, and the machine3 directories. You use these two directories to simulate two separate machines that connect to your domain controller.

      [student@workstation domain-host]$ cp -R /opt/jboss-eap-7.4/domain/configuration \
        machine2/
      [student@workstation domain-host]$ cp -R /opt/jboss-eap-7.4/domain/configuration \
        machine3/
  2. Configure distinct host names.

    1. Using a text editor, open the /home/student/AD248/labs/domain-host/machine2/configuration/host-slave.xml file.

    2. Notice this host does not have a name. Each host in a domain needs a distinct name, you must assign the host2 value to the name attribute, as follows:

      <host name="host2" xmlns="urn:jboss:domain:16.0">
  3. Verify the IP address of the domain controller.

    1. Notice that host-slave.xml is configured to be a secondary controller based on the following domain-controller setting that includes the <remote> element:

      <domain-controller>
          <remote security-realm="ManagementRealm">
              <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>

      You use the jboss.domain.master.address system property to start the host2 and host3 secondary controllers later in this guided exercise.

  4. Avoid port conflicts from multiple host controllers.

    1. To avoid port conflicts, you must set different ports for each secondary host controller running on the workstation machine.

      The machine1 domain controller uses the 9990 default port. Thus, you must change the host2 management interface port number. In the <http-interface> section, change the default port to 29990:

      <management-interfaces>
        <http-interface security-realm="ManagementRealm">
           <http-upgrade enabled="true"/>
           <socket interface="management" port="${jboss.management.http.port:29990}"/>
        </http-interface>
      </management-interfaces>
    2. Notice in all <interfaces> elements that the IP address is assigned to the 127.0.0.1 loopback interface by default.

      In a multi-machine environment the primary controller cannot connect to secondary hosts through the loopback interface.

      Replace the 127.0.0.1 loopback IP address in both of the default values with the 172.25.250.9 workstation machine IP address:

      <interface name="management">
          <inet-address value="${jboss.bind.address.management:172.25.250.9}"/>
      </interface>
      <interface name="public">
         <inet-address value="${jboss.bind.address:172.25.250.9}"/>
      </interface>
  5. Inspect the host servers.

    1. In the host-slave.xml file for the host2 host controller, notice that there are already two servers defined, server-one and server-two:

      <server name="server-one" group="main-server-group"/>
      <server name="server-two" group="other-server-group">
          <socket-bindings port-offset="150"/>
      </server>

      The server-one server belongs to the main-server-group server group, and server-two belongs to the other-server-group server group.

      Also note that server-two uses a port offset of 150 to avoid conflicts between the two servers.

      Save the changes to host-slave.xml and close your text editor.

  6. Start the domain controller.

    1. Before running the host controller, start the domain controller on machine1 using a new terminal window:

      [student@workstation ~]$ cd /opt/jboss-eap-7.4/bin
      [student@workstation bin]$ ./domain.sh \
      -Djboss.domain.base.dir=/home/student/AD248/labs/domain-host/machine1/ \
      --host-config=host-master.xml
    2. Start host2 using the host-slave.xml configuration file that has its management interface bind to 172.25.250.9 on the 29999 port .

      Run the following command from your /opt/jboss-eap-7.4/bin directory in the original terminal window:

      [student@workstation domain-host]$ cd /opt/jboss-eap-7.4/bin
      [student@workstation bin]$ ./domain.sh \
      -Djboss.domain.base.dir=/home/student/AD248/labs/domain-host/machine2/ \
      --host-config=host-slave.xml \
      -Djboss.domain.master.address=172.25.250.9

      Note

      Notice that the prefix of each log entry in the terminal window is either [HostController] or the name of the server that caused the log event, which is either [Server:server-one] or [Server:server-two] in your deployment.

    3. Inspect the terminal window of the machine2 host controller. Review the log output and notice the host controller connecting to the master. Inspect also the messages indicating that server-one and server-two are starting.

      [Host Controller] 07:55:09,730 INFO  [org.jboss.as.host.controller] (Controller Boot Thread) WFLYHC0148: Connected to master host controller at remote+http://172.25.250.9:9990
      [Host Controller] 07:55:09,832 INFO  [org.jboss.as.host.controller] (Controller Boot Thread) WFLYHC0023: Starting server server-one
    4. Inspect the domain controller terminal window. There is a log entry showing the secondary controller connecting:

      [Host Controller] 07:55:09,718 INFO  [org.jboss.as.domain.controller] (Host Controller Service Threads - 37) WFLYHC0019: Registered remote slave host "host2", JBoss JBoss EAP 7.4.11.GA (WildFly 15.0.26.Final-redhat-00001)
  7. Verify that the host2 secondary controller is in the domain.

    1. In your browser, navigate to the http://172.25.250.9:9990/ domain controller management console. Use admin as the username, and redhat123 as the password.

    2. Verify that server-one and server-two show in the list on the Runtime page under the host2 host.

  8. Configure the host3 host controller.

    1. Using a text editor, open the /home/student/AD248/labs/domain-host/machine3/configuration/host-slave.xml file. Ensure that you do not stop the domain controller and the host2 host controller.

    2. Add a name attribute to the <host> element and assign it the host3 value:

      <host name="host3" xmlns="urn:jboss:domain:16.0">
    3. Change the management interface port to 39990:

      <http-interface security-realm="ManagementRealm">
          <http-upgrade enabled="true"/>
          <socket interface="management" port="${jboss.management.http.port:39990}"/>
      </http-interface>
    4. In the <interfaces> section, replace 127.0.0.1 in the default value of jboss.bind.address.management and jboss.bind.address with the 172.25.250.9 workstation machine IP address:

      <interface name="management">
          <inet-address value="${jboss.bind.address.management:172.25.250.9}"/>
      </interface>
      <interface name="public">
         <inet-address value="${jboss.bind.address:172.25.250.9}"/>
      </interface>
    5. Delete server-one from the <servers> section.

    6. Rename server-two to server-three and change its port-offset to be 1000. Your <servers> section should appear as follows:

      <servers>
        <server name="server-three" group="other-server-group">
           <socket-bindings port-offset="1000"/>
        </server>
      </servers>
    7. Save your changes to host-slave.xml and exit your text editor.

  9. Start the host3 secondary host controller.

    1. Open a new terminal window and run the following commands to start host3 as a slave in your domain:

      [student@workstation domain-host]$ cd /opt/jboss-eap-7.4/bin
      [student@workstation bin]$ ./domain.sh \
      -Djboss.domain.base.dir=/home/student/AD248/labs/domain-host/machine3/ \
      --host-config=host-slave.xml \
      -Djboss.domain.master.address=172.25.250.9
    2. Inspect the domain controller terminal window . You must see a log entry showing the secondary controller connecting:

      [Host Controller] 08:10:26,650 INFO  [org.jboss.as.domain.controller] (Host Controller Service Threads - 44) WFLYHC0019: Registered remote slave host "host3", JBoss JBoss EAP 7.4.11.GA (WildFly 15.0.26.Final-redhat-00001)
  10. Verify that the host3 secondary host controller is in the domain.

    1. Go back to your management console and refresh the Runtime page.

    2. Verify that the server-three is running on host3.

    3. The following diagram shows what your domain now looks like:

      Table 4.1. Domain servers

      ServerAddressPort-Offset
      server-one172.25.250.9:80800
      server-two172.25.250.9:8230150
      server-three172.25.250.9:90801000

  11. Verify that the servers are running.

    1. On the workstation machine, open a web browser and navigate to http://172.25.250.9:8080/. This default JBoss EAP Welcome page that is served by the server-one server.

    2. Point your web browser to http://172.25.250.9:8230/. This default JBoss EAP Welcome page that is served by the server-two server.

    3. Point your web browser to http://172.25.250.9:9080/. This default JBoss EAP Welcome page that is served by the server-three server.

  12. Stop a host controller. Press Ctrl+C in the host2 terminal window to start the shutdown of host2.

    1. Inspect the output in the terminal window and notice that the server-one and server-two processes are stopped, followed by the host controller process.

      08:14:14,853 INFO  [org.jboss.as.process.Server:server-two.status] (reaper for Server:server-two) WFLYPC0011: Process 'Server:server-two' finished with an exit status of 130
      [Host Controller] 08:14:14,854 INFO  [org.jboss.as.host.controller] (ProcessControllerConnection-thread - 2) WFLYHC0027: Unregistering server server-two
      08:14:14,865 INFO  [org.jboss.as.process.Server:server-one.status] (reaper for Server:server-one) WFLYPC0011: Process 'Server:server-one' finished with an exit status of 130
      [Host Controller] 08:14:14,866 INFO  [org.jboss.as.host.controller] (ProcessControllerConnection-thread - 2) WFLYHC0027: Unregistering server server-one
      [Host Controller] 08:14:14,914 INFO  [org.jboss.as] (MSC service thread 1-1) WFLYSRV0050: JBoss EAP 7.4.11.GA (WildFly Core 15.0.26.Final-redhat-00001) stopped in 803ms
      [Host Controller]
      08:14:14,925 INFO  [org.jboss.as.process.Host Controller.status] (reaper for Host Controller) WFLYPC0011: Process 'Host Controller' finished with an exit status of 130
      08:14:14,926 INFO  [org.jboss.as.process] (Shutdown thread) WFLYPC0016: All processes finished; exiting
    2. Inspect the terminal window of the domain controller. You must see a log event similar to the following, stating that host2 is removed from the managed domain:

      [Host Controller] 08:14:14,111 INFO  [org.jboss.as.domain.controller] (management task-1) WFLYHC0026: Unregistered remote slave host "host2"
    3. Start host2 again. When the start finishes, you can see a log event in the machine1 terminal window showing that the host2 registers again in the domain.

      [student@workstation bin]$ ./domain.sh \
      -Djboss.domain.base.dir=/home/student/AD248/labs/domain-host/machine2/ \
      --host-config=host-slave.xml \
      -Djboss.domain.master.address=172.25.250.9
  13. Stop the domain controller.

    1. Press Ctrl+C in the machine1 terminal window to shutdown the domain controller.

    2. Refresh the web page at http://172.25.250.9:8080/. The page displays properly, even though the master host controller is no longer running.

    3. Start the domain controller again:

      [student@workstation bin]$ ./domain.sh \
      -Djboss.domain.base.dir=/home/student/AD248/labs/domain-host/machine1/ \
      --host-config=host-master.xml
    4. Inspect the output in the terminal window and wait. You should see host2 and host3 reconnecting to the domain controller after a few seconds.

  14. Use Ctrl+C to stop the domain controller and the two host controllers.

Finish

On the workstation machine, use the lab command to complete this exercise. This step is important to ensure that resources from previous exercises do not impact upcoming exercises.

[student@workstation ~]$ lab finish domain-host

Revision: ad248-7.4-18a9db2