How to change the Garbage collection options on JBoss EAP on OpenShift
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 6.x
- 7.x
- OpenJDK 8
- Red hat OpenShift Container Platform (OCP)
Issue
We need to find a way to change the default Garbage Collector settings in the JVM used by JBoss EAP on OpenShift
Resolution
- For EAP 6.4 version 1.6 and later , follow this solution article.
- For JBoss EAP 6.4 till version 1.5 follow below steps:
Use the JAVA_OPTS_APPEND environment variable to add new options to the JVM. See the following example, how to set the JVM non standard option -XX:+UseG1GC in the Deployment Config of a running EAP image:
$ oc get dc
NAME REVISION DESIRED CURRENT TRIGGERED BY
demoeap 3 1 1 config,image(demoeap:latest)
$ oc set env dc/demoeap JAVA_OPTS_APPEND=-XX:+UseG1GC
Now you can check from the Pod logs that the option -XX:+UseG1GC has been included in the JBoss EAP JVM:
$ oc logs demoeap-3-7k00d
Running jboss-eap-7/eap70-openshift image, version 1.4-30
=========================================================================
JBoss Bootstrap Environment
JBOSS_HOME: /opt/eap
JAVA: /usr/lib/jvm/java-1.8.0/bin/java
JAVA_OPTS: -server -verbose:gc -Xloggc:"/opt/eap/standalone/log/gc.log" -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCL
ogFileSize=3M -XX:-TraceClassUnloading -Xms1303m -Xmx1303m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss
.logmanager,jdk.nashorn.api -Djava.awt.headless=true -Xbootclasspath/p:/opt/eap/jboss-modules.jar:/opt/eap/modules/system/layers/base/org/jboss/logmanager/main/jboss-logmanager
-2.0.3.Final-redhat-1.jar:/opt/eap/modules/system/layers/base/org/jboss/logmanager/ext/main/jboss-logmanager-ext-1.0.0.Alpha2-redhat-1.jar -Djava.util.logging.manager=org.jboss
.logmanager.LogManager -javaagent:/opt/eap/jolokia.jar=port=8778,protocol=https,caCert=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt,clientPrincipal=cn=system:master-pro
xy,useSslClientAuthentication=true,extraClientCheck=true,host=0.0.0.0,discoveryEnabled=false -Djava.security.egd=file:/dev/./urandom -XX:+UseG1GC
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments