Bookmark this page

Lab: Configuring the Java Virtual Machine

Configure the Java Virtual Machine (JVM) settings for an JBoss EAP managed domain.

Resources
Files /opt/domain
Application URL NA

Outcomes

You should be able to configure the Java Virtual Machine (JVM) options used by Red Hat Enterprise Application Platform (JBoss EAP) servers running in a managed domain.

Use the following command to prepare the environment:

[student@workstation ~]$ lab start jvm-review

You can use either the JBoss EAP management console or the management CLI to achieve your objectives. Keep in mind that the management CLI is the preferred option in production environments.

A JBoss EAP administrator has set up a managed domain with two host controllers running on servera and serverb machines. The domain controller runs on the workstation machine. The domain and host configuration files are stored in the /opt/domain directory on all three machines.

Instructions

  1. Start the domain controller on the workstation machine.

    Use /opt/domain as the jboss.domain.base.dir value. The host file for the domain controller is named host-master.xml. Note that the /opt/domain directory is owned by the jboss user, so you must start the domain controller using sudo -u jboss /opt/jboss-eap-7.4/bin/domain.sh …​.

    [student@workstation ~]$ sudo -u jboss /opt/jboss-eap-7.4/bin/domain.sh \
    -Djboss.domain.base.dir=/opt/domain/ --host-config=host-master.xml
  2. Start the two host controllers on the servera and the serverb machines.

    Use /opt/domain as the jboss.domain.base.dir value. The host file for the host controllers is host-slave.xml. Note that the /opt/domain directory is owned by the jboss user, so you must start the host controller using ssh jboss@server-name /opt/jboss-eap-7.4/bin/domain.sh …​.

    Note

    You can safely ignore the following output:

    WARNING: An illegal reflective access operation has occurred
    WARNING: Illegal reflective access by org.wildfly.extension.elytron.SSLDefinitions (jar:file:/opt/jboss-eap-7.4/modules/system/layers/base/.overlays/layer-base-jboss-eap-7.4.11.CP/org/wildfly/extension/elytron/main/wildfly-elytron-integration-15.0.26.Final-redhat-00001.jar!/) to method com.sun.net.ssl.internal.ssl.Provider.isFIPS()
    WARNING: Please consider reporting this to the maintainers of org.wildfly.extension.elytron.SSLDefinitions
    WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
    WARNING: All illegal access operations will be denied in a future release

    Refer to https://access.redhat.com/solutions/4996491.

    1. Start the host controller on servera.

      Open a new terminal window on the workstation machine and run the following command:

      [student@workstation ~]$ ssh -t jboss@servera /opt/jboss-eap-7.4/bin/domain.sh \
      -Djboss.domain.base.dir=/opt/domain/ \
      -Djboss.domain.master.address=172.25.250.9 \
      --host-config=host-slave.xml

      Note the use of the -t option for the ssh command to allocate a pseudo-terminal. You must use this option to properly propagate the signals that Ctrl+C sends to the remote machine.

    2. Start the host controller on serverb.

      Open a new terminal window on the workstation machine and run the following command:

      [student@workstation ~]$ ssh -t jboss@serverb /opt/jboss-eap-7.4/bin/domain.sh \
      -Djboss.domain.base.dir=/opt/domain/ \
      -Djboss.domain.master.address=172.25.250.9 \
      --host-config=host-slave.xml

      Note the use of the -t option for the ssh command to allocate a pseudo-terminal. You must use this option to properly propagate the signals that Ctrl+C sends to the remote machine.

    3. Verify that both host controllers connect to the domain controller and form a managed domain.

      Look at the console window where you started the domain controller and verify that both servera and serverb are registered as secondary controllers to the domain controller.

      [Host Controller] 03:28:53,434 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: JBoss EAP 7.4.11.GA (WildFly Core 15.0.26.Final-redhat-00001) (Host Controller) started in 3622ms - Started 80 of 81 services (22 services are lazy, passive or on-demand)
      [Host Controller] 03:29:12,302 INFO  [org.jboss.as.domain.controller] (Host Controller Service Threads - 37) WFLYHC0019: Registered remote slave host "servera", JBoss JBoss EAP 7.4.11.GA (WildFly 15.0.26.Final-redhat-00001)
      [Host Controller] 03:29:47,951 INFO  [org.jboss.as.domain.controller] (Host Controller Service Threads - 37) WFLYHC0019: Registered remote slave host "serverb", JBoss JBoss EAP 7.4.11.GA (WildFly 15.0.26.Final-redhat-00001)
  3. Configure the JVM options for the managed domain with the following specifications:

    • The minimum and maximum heap size of the default JVM on the host controller servera should be set to 512 MB.

    • For all the servers in the Group1 server group, create a new JVM configuration named group1-jvm. Set the minimum JVM heap size to 512m (512 MB) and the maximum JVM heap size to 1024m (1 GB). Enable the -XX:+UseShenandoahGC flag for this server group.

    • For the serverb.2 server, create a new JVM configuration named serverb.2-jvm that overrides any inherited settings. Set the minimum and maximum JVM heap size to 1024m (1 GB). Enable the -XX:+AggressiveOpts and -server flags for this server.

    • Leave all other JVM options at default values.

    Ensure that all the servers in the managed domain are started with these settings and without any errors. Verify that the JVM flags with which the servers are running, using the ps -aef command on the respective hosts.

    Note

    When you start the managed domain at the beginning of the lab, all the servers are set to start automatically. Make sure you stop all the servers before you make changes to the JVM options in the managed domain.

    1. Launch the management CLI to configure the JVM.

      In a new terminal window on the workstation, start the management CLI and connect to the domain controller as the jboss user:

      [student@workstation ~]$ sudo -u jboss \
      /opt/jboss-eap-7.4/bin/jboss-cli.sh \
      --connect --controller=172.25.250.9:9990
      [domain@172.25.250.9:9990 /]
    2. Stop the servers in the Group1 server group.

      [domain@172.25.250.9:9990 /] /server-group=Group1:\
      stop-servers(blocking=true)
      {
          "outcome" => "success",
      ...output omitted...
      }
    3. Stop the servers in the Group2 server group.

      [domain@172.25.250.9:9990 /] /server-group=Group2:\
      stop-servers(blocking=true)
      {
          "outcome" => "success",
      ...output omitted...
      }
    4. Configure the default JVM for the servera host controller to use a minimum amount of heap memory of 512 MB.

      [domain@172.25.250.9:9990 /] /host=servera\
      /jvm=default:write-attribute(name=heap-size,value=512m)
      {
          "outcome" => "success",
      ...output omitted...
      }
    5. Configure the maximum amount of heap memory to 512MB.

      [domain@172.25.250.9:9990 /] /host=servera\
      /jvm=default:write-attribute(name=max-heap-size,value=512m)
      {
          "outcome" => "success",
      ...output omitted...
      }
    6. Configure a JVM minimum amount of memory for server group Group1 of 512 MB, and a maximum amount of memory of 1024 MB. Also, pass the -XX:+UseShenandoahGC as an option to the JVM .

      [domain@172.25.250.9:9990 /] /server-group=Group1\
      /jvm=group1-jvm:add\
      (heap-size=512m,max-heap-size=1024m,jvm-options=["-XX:+UseShenandoahGC"])
      {
          "outcome" => "success",
      ...output omitted...
      }
    7. Configure the JVM for serverb.2 server. The minimum amount of memory for the server must be 1024 MB, and the maximum amount of memory to 1024 MB. Also, pass the -XX:+AggressiveOpts and -server as parameters to the JVM .

      [[domain@172.25.250.9:9990 /] /host=serverb\
      /server-config=serverb.2\
      /jvm=serverb.2-jvm:add\
      (heap-size=1024m,max-heap-size=1024m,\
      jvm-options=["-XX:+AggressiveOpts","-server"])
      {
          "outcome" => "success",
      ...output omitted...
      }
    8. Start the servers in Group1.

      [domain@172.25.250.9:9990 /] /server-group=Group1\
      :start-servers(blocking=true)
      {
          "outcome" => "success",
      ...output omitted...
      }
    9. Start the servers in Group2.

      [domain@172.25.250.9:9990 /] /server-group=Group2\
      :start-servers(blocking=true)
      {
          "outcome" => "success",
      ...output omitted...
      }
    10. In a different terminal window, verify the JVM options by using the ps command on each host.

      [student@workstation ~]$ ssh jboss@servera ps -efa|grep servera
      jboss       5593    5012 18 04:06 ?        00:00:13 /usr/lib/jvm/java-11-openjdk-11.0.14.1.1-6.el9.x86_64/bin/java -D[Server:servera.1] -D[pcid:200855209] -Xms512m -Xmx1024m -XX:+UseShenandoahGC -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Djboss.domain.base.dir=/opt/domain/
      ...output omitted...
      jboss       5758    5012 34 04:07 ?        00:00:14 /usr/lib/jvm/java-11-openjdk-11.0.14.1.1-6.el9.x86_64/bin/java -D[Server:servera.2] -D[pcid:976193559] -Xms64m -Xmx256m -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Djboss.domain.base.dir=/opt/domain/
      ...output omitted...
      [student@workstation ~]$ ssh jboss@serverb ps -efa|grep serverb
      jboss       5595    5013  5 04:06 ?        00:00:17 /usr/lib/jvm/java-11-openjdk-11.0.14.1.1-6.el9.x86_64/bin/java -D[Server:serverb.1] -D[pcid:1126635811] -Xms512m -Xmx1024m -XX:+UseShenandoahGC -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Djboss.domain.base.dir=/opt/domain/
      ...output omitted...
      jboss       5758    5013  5 04:07 ?        00:00:16 /usr/lib/jvm/java-11-openjdk-11.0.14.1.1-6.el9.x86_64/bin/java -D[Server:serverb.2] -D[pcid:709043458] -Xms1024m -Xmx1024m -XX:+AggressiveOpts -server -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Djboss.domain.base.dir=/opt/domain/
      ...output omitted...
  4. Shut down the servers, server groups, host controllers, and the entire managed domain by using the management CLI.

    1. Stop all servers in Group1.

      [domain@172.25.250.9:9990 /] /server-group=Group1:stop-servers(blocking=true)
      {
          "outcome" => "success",
      ...output omitted...
      }
    2. Stop the servers in Group2.

      [domain@172.25.250.9:9990 /] /server-group=Group2:stop-servers(blocking=true)
      {
          "outcome" => "success",
      ...output omitted...
      }
    3. Shut down the host controller on servera. Observe the console window of servera and verify that the host controller has been shut down.

      [domain@172.25.250.9:9990 /] /host=servera:shutdown()
      {
          "outcome" => "success",
      ...output omitted...
      }
    4. Shut down the host controller on serverb. Observe the console window of serverb and verify that the host controller has been shutdown.

      [domain@172.25.250.9:9990 /] /host=serverb:shutdown()
      {
          "outcome" => "success",
      ...output omitted...
      }
  5. Clean up and grading.

    1. Press Ctrl+C to stop the domain controller. Alternatively, you can shutdown the domain controller using the /host=master:shutdown() management CLI command.

    2. Press Ctrl+C to exit the management CLI if you used the CLI in the lab. Alternatively, you can exit the CLI by typing exit.

    3. Run the following command from the workstation to grade the exercise:

      [student@workstation ~]$ lab grade jvm-review

Finish

As the student user 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 jvm-review

Revision: ad248-7.4-18a9db2