How to customize Java Virtual Machine Settings in Oracle WebLogic Server 12 on OS Linux / UNIX

In order to achieve the best performance of the application or to avoid performance bottlenecks (and “OutOfMemory” problems) you need to tune your Java Virtual Machine. After you install the WebLogic Server and create a Domain (WebLogic or SOA or Forms or OBIEE etc.) you may set some properties such as Java “Heap size”, tune Java “Garbage Collection” and WebLogic Server start options.

Tune JVM settings

You can set the Variable USER_MEM_ARGS for the Admin Server and each Managed Server to tune the JVM Parameters. For Example:

USER_MEM_ARGS="-Xms1g -Xmx3g -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:NewSize=1g"

Where:

  • Xms1g: JVM initial heap size: In this example: 1 GB
  • Xmx3g: JVM maximal heap size: The heap can grow to 3 GB
  • -XX:+UseParNewGC: Uses parallel version of a younger generation

For more information about JVM tuning parameters please refer to:

Note: in JDK 1.8 parameters for Permanent Generation (XX:PermSize -XX:MaxPermSize) are deprecated.

Customize WebLogic Server start parameters

You can change default WLS start parameters by using the variable “JAVA_OPTIONS”.

For example:

JAVA_OPTIONS="$JAVA_OPTIONS -Dweblogic.MaxMessageSize=300000000"

set the parameter “-Dweblogic.MaxMessageSize=300000000.” additional to default options.

How to set JVM and WebLogic parameters for each managed Server.

The best solution for setting JVM and WebLogic parameters is the creation of file setUserOverrides.sh in the $DOMAIN_HOME/bin directory. This file will be red from the file setDomainEnv.sh during the starting of WebLogic Server.

The file setUserOverrides.sh must be written as a shell script. You can use some shell loops such as “if..fi” or “case… esac”.

 

Below you can find an example of the script setUserOverrides.sh (in  SOA Suite 12.2.1 environment):

#!/bin/bash
echo "Setting from UserOverrides.sh"

# global settings (for all managed servers)
export JAVA_OPTIONS="$JAVA_OPTIONS -Dweblogic.MaxMessageSize=300000000"

# customer settings for each Server
if [ "${SERVER_NAME}" = "AdminServer" ]
then
   echo "Customizing USER_MEM_ARGS for SERVER_NAME ${SERVER_NAME}"
   export USER_MEM_ARGS="-Xms3g -Xmx3g"
   export JAVA_OPTIONS="$JAVA_OPTIONS -Djava.awt.headless=true"
fi
if [ "${SERVER_NAME}" = "soa_server1"  -o "${SERVER_NAME}" = "soa_server2" -o "${SERVER_NAME}" = "soa_server3" ]
then
   echo "Customizing USER_MEM_ARGS for SERVER_NAME ${SERVER_NAME}"
   export USER_MEM_ARGS="-Xms3g -Xmx3g -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:NewSize=1g"
   export JAVA_OPTIONS="$JAVA_OPTIONS -Djava.awt.headless=true"
fi
if [ "${SERVER_NAME}" = "osb_server1"  -o "${SERVER_NAME}" = "osb_server2" -o "${SERVER_NAME}" = "osb_server3" ]
then
   echo "Customizing USER_MEM_ARGS for SERVER_NAME ${SERVER_NAME}"
   export USER_MEM_ARGS="-Xms3g -Xmx3g -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:NewSize=1g"
   export JAVA_OPTIONS="$JAVA_OPTIONS -Djava.awt.headless=true"
fi
if [ "${SERVER_NAME}" = "ess_server1"  -o "${SERVER_NAME}" = "ess_server2" -o "${SERVER_NAME}" = "ess_server3" ]
then
   echo "Customizing USER_MEM_ARGS for SERVER_NAME ${SERVER_NAME}"
   export USER_MEM_ARGS="-Xms1g -Xmx1g -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:NewSize=1g"
   export JAVA_OPTIONS="$JAVA_OPTIONS -Djava.awt.headless=true"
fi
if [ "${SERVER_NAME}" = "owsm_server1"  -o "${SERVER_NAME}" = "owsm_server2" -o "${SERVER_NAME}" = "owsm_server3" ]
then
   echo "Customizing USER_MEM_ARGS for SERVER_NAME ${SERVER_NAME}"
   export USER_MEM_ARGS="-Xms1g -Xmx1g -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:NewSize=1g"
   export JAVA_OPTIONS="$JAVA_OPTIONS -Djava.awt.headless=true"
fi
echo "End setting from UserOverrides.sh"

In this example the global section is used for settings of global variables, which are applied to all managed servers:

# global settinga (for all servers)s

export JAVA_OPTIONS="$JAVA_OPTIONS -Dweblogic.MaxMessageSize=300000000"

In following sections we will set variables for each managed server or for groups of managed server. In the example below is the heap size set to 3 GB (-Xms3g -Xmx3g) for the Group of OSB Servers (osb_server1 / osb_server2 and osb_server3).

The group of OWSM servers gets the heap size 1 GB:

if  [ "${SERVER_NAME}" = "osb_server1" -o "${SERVER_NAME}" = "osb_server2" -o "${SERVER_NAME}" = "osb_server3" ]
then
   echo "Customizing USER_MEM_ARGS for SERVER_NAME ${SERVER_NAME}"
   export USER_MEM_ARGS="-Xms3g -Xmx3g -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:NewSize=1g"
   export JAVA_OPTIONS="$JAVA_OPTIONS -Djava.awt.headless=true"
fi
if [ "${SERVER_NAME}" = "owsm_server1"  -o "${SERVER_NAME}" = "owsm_server2" -o "${SERVER_NAME}" = "owsm_server3" ]
then
   echo "Customizing USER_MEM_ARGS for SERVER_NAME ${SERVER_NAME}"
   export USER_MEM_ARGS="-Xms1g -Xmx1g -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:NewSize=1g"
   export JAVA_OPTIONS="$JAVA_OPTIONS -Djava.awt.headless=true"
fi

Note: you may restart managed servers to activate the new settings.

Enjoy 🙂

Advertisements

Autor: Neselovskyi, Borys

Oracle Database / Middleware / Engineered System Solution Architect

8 Kommentare zu „How to customize Java Virtual Machine Settings in Oracle WebLogic Server 12 on OS Linux / UNIX“

    1. An interesting and useful post Borys!

      I approve of the use of setUserOverrides.sh rather than hacking setDomainEnv.sh etc (which gets overwritten if you re-run the configuration wizard), though I’d normally set JVM memory parameters in the NM startup options for the Managed Server (e.g. in Server Start in the WLS Console).

      Gefällt mir

Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

WordPress.com-Logo

Du kommentierst mit Deinem WordPress.com-Konto. Abmelden / Ändern )

Twitter-Bild

Du kommentierst mit Deinem Twitter-Konto. Abmelden / Ändern )

Facebook-Foto

Du kommentierst mit Deinem Facebook-Konto. Abmelden / Ändern )

Google+ Foto

Du kommentierst mit Deinem Google+-Konto. Abmelden / Ändern )

Verbinde mit %s