Chapter 9. Configuring JVM Settings
Configuration of Java Virtual Machine (JVM) settings is different for a standalone JBoss EAP server, or a JBoss EAP server in a managed domain.
For a standalone JBoss EAP server instance, the server startup processes pass JVM settings to the JBoss EAP server at startup. These can be declared from the command line before launching JBoss EAP, or using the System Properties screen in the management console.
In a managed domain, JVM settings are declared in the host.xml
and domain.xml
configuration files, and can be configured at host, server group, or server levels.
System properties must be configured in JAVA_OPTS
to be used by JBoss EAP modules (such as the logging manager) during startup.
9.1. Configuring JVM Settings for a Standalone Server
JVM settings for standalone JBoss EAP server instances can be declared at runtime by setting the JAVA_OPTS
environment variable before starting the server.
An example of setting the JAVA_OPTS
environment variable on Linux is shown below.
$ export JAVA_OPTS="-Xmx1024M"
The same setting can be used in a Microsoft Windows environment:
set JAVA_OPTS="Xmx1024M"
Alternatively, JVM settings can be added to the standalone.conf
file in the EAP_HOME/bin
folder, which contains examples of options to pass to the JVM.
Setting the JAVA_OPTS
environment variable will override the default values from standalone.conf
, which may cause JBoss EAP startup issues.
9.2. Configuring JVM Settings for a Managed Domain
In a JBoss EAP managed domain, you can define JVM settings at multiple levels. You can define custom JVM settings on a particular host, and then apply those settings to server groups, or to individual server instances.
By default, server groups and individual servers will inherit the JVM settings from their parent, but you can choose to override JVM settings at each level.
The JVM settings in domain.conf
are applied to the Java process of the JBoss EAP host controller, and not the individual JBoss EAP server instances controlled by that host controller.
9.2.1. Defining JVM Settings on a Host Controller
You can define JVM settings on a host controller, and apply those settings to server groups or individual servers. JBoss EAP comes with a default
JVM setting, but the following management CLI command demonstrates creating a new JVM setting named production_jvm
with some custom JVM settings and options.
/host=HOST_NAME/jvm=production_jvm:add( heap-size=2048m, max-heap-size=2048m, max-permgen-size=512m, stack-size=1024k, jvm-options=["-XX:-UseParallelGC"] )
You can also create and edit JVM settings in the JBoss EAP management console by selecting the Runtime tab, selecting Hosts, and clicking JVM on the host you want to edit.
These settings are stored in the within the <jvm>
tag in host.xml
.
9.2.2. Applying JVM Settings to a Server Group
When creating a server group, you can specify a JVM configuration that all servers in the group will use. The following management CLI commands demonstrate creating a server group name groupA
that uses the production_jvm
JVM settings that were shown in the previous example.
/server-group=groupA:add(profile=default, socket-binding-group=standard-sockets) /server-group=groupA/jvm=production_jvm:add()
All servers in the server group will inherit JVM settings from production_jvm
.
You can also override specific JVM settings at the server group level. For example, to set a different heap size, you can use the following command:
/server-group=groupA/jvm=production_jvm:write-attribute(name=heap-size,value="1024m")
After applying the above command, the server group groupA
will inherit the JVM settings from production_jvm
, except for the heap size which has an overridden value of 1024m
.
You can also edit server group JVM settings in the JBoss EAP management console by selecting the Runtime tab, selecting Server Groups, and clicking View for the server group you want to edit.
These settings for a server group are stored in domain.xml
.
9.2.3. Applying JVM Settings to an Individual Server
By default, an individual JBoss EAP server instance will inherit the JVM settings of the server group it belongs to. However, you can choose to override the inherited settings with another complete JVM setting definition from the host controller, or choose to override specific JVM settings.
For example, the following command overrides the JVM definition of the server group in the previous example, and sets the JVM settings for server-one
to the default
JVM definition:
/host=HOST_NAME/server-config=server-one/jvm=default:add()
Also, similar to server groups, you can override specific JVM settings at the server level. For example, to set a different heap size, you can use the following command:
/host=HOST_NAME/server-config=server-one/jvm=default:write-attribute(name=heap-size,value="1024m")
You can also edit server JVM settings in the JBoss EAP management console by selecting the Runtime tab, selecting Hosts, selecting the relevant host. Then select the relevant server, and click View for the server you want to edit.
These settings for an individual server are stored in host.xml
.
9.3. Displaying the JVM Status
You can view the status of JVM resources, such as heap and thread usage, for standalone or managed domain servers from the management console. While statistics are not displayed in real time, you can click Refresh Results to provide an up-to-date overview of JVM resources.
To display the JVM status for a standalone JBoss EAP server:
- Select the Runtime tab, and then select Standalone Server. In the Monitor column, select JVM and click View.
To display the JVM status for a JBoss EAP server in a managed domain:
- Select the Runtime tab, and then select the server group and server that you want to view. In the Monitor column, select JVM and click View.
This shows the following heap usage information:
- Max
- The maximum amount of memory that can be used for memory management.
- Used
- The amount of used memory.
- Committed
- The amount of memory that is committed for the Java Virtual Machine to use.
Other information, such as JVM uptime and thread usage, is also available.
9.4. Specifying 32 or 64-bit JVM Architecture
In some environments, such as Hewlett-Packard HP-UX and Solaris, the -d32
or -d64
switch is used to specify whether to run in a 32-bit or 64-bit JVM. The default is 32-bit if neither option is indicated.
Specifying 64-Bit Architecture for a Standalone Server
-
Open
EAP_HOME/bin/standalone.conf
. -
Add the following line to append the
-d64
option toJAVA_OPTS
.
JAVA_OPTS="$JAVA_OPTS -d64"
Specifying 64-Bit Architecture for a Managed Domain
When running a managed domain, you can specify the 64-bit environment for host and process controllers in addition to server instances.
Set the host and process controllers to run in the 64-bit JVM.
-
Open
EAP_HOME/bin/domain.conf
. Add the following line to append the
-d64
option toJAVA_OPTS
. Ensure that this is inserted before wherePROCESS_CONTROLLER_JAVA_OPTS
andHOST_CONTROLLER_JAVA_OPTS
are set.JAVA_OPTS="$JAVA_OPTS -d64"
Example JVM options in
domain.conf
# # Specify options to pass to the Java VM. # if [ "x$JAVA_OPTS" = "x" ]; then JAVA_OPTS="-Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true" JAVA_OPTS="$JAVA_OPTS -Djboss.modules.system.pkgs=$JBOSS_MODULES_SYSTEM_PKGS -Djava.awt.headless=true" JAVA_OPTS="$JAVA_OPTS -Djboss.modules.policy-permissions=true" JAVA_OPTS="$JAVA_OPTS -d64" else echo "JAVA_OPTS already set in environment; overriding default settings with values: $JAVA_OPTS" fi
-
Open
Set the server instances to run in the 64-bit JVM.
Add
-d64
as a JVM option in your appropriate JVM configuration. The command below shows it being added to thedefault
JVM configuration./host=HOST_NAME/jvm=default:add-jvm-option(jvm-option="-d64")