Sunday, 13 March 2016

JVM settings at server instance level

Please read my earlier post for JVM settings in JBOSS

This article provides CLI commands to add/remove/change JVM settings at application level. 

Add Heap memory size at server instance level.

[domain@192.168.1.12:9999 /] /host=slave01/server-config=rpa1/jvm=jvm-rpa:add(heap-size=64m, max-heap-size=220m)
{
    "outcome" => "success",
    "result" => undefined,
    "server-groups" => {"undefined" => {"host" => {"slave01" => {"rpa1" => {"response" => {
        "outcome" => "success",
        "response-headers" => {
            "operation-requires-restart" => true,
            "process-state" => "restart-required"
        }
    }}}}}}
}

The fallowing JVM content has been added to  rpa1 server instance in host.xml file

<servers>
        <server name="rpa1" group="rpa-group" auto-start="true">
            <jvm name="jvm-rpa">
                <heap size="64m" max-size="220m"/>
            </jvm>
            <socket-bindings port-offset="100"/>
        </server>

Adding  HeapDumpOnOutOfMemoryError parameter to specific server instance

[domain@192.168.1.12:9999 /] /host=slave01/server-config=rpa1/jvm=jvm-rpa:write-attribute(name=jvm-options,value=["-XX:+HeapDumpOnOutOfMemoryError"])
{
    "outcome" => "success",
    "result" => undefined,
    "server-groups" => {"undefined" => {"host" => {"slave01" => {"rpa1" => {"response" => {
        "outcome" => "success",
        "response-headers" => {
            "operation-requires-restart" => true,
            "process-state" => "restart-required"
        }
}


Adding  HeapDumpPath parameter to specific server instance

[domain@192.168.1.12:9999 /] /host=slave01/server-config=rpa1/jvm=jvm-rpa: add-jvm-option (jvm-option="-XX:HeapDumpPath=/u03/local/opt/jboss-eap-6.2/mydomain/slave1/servers/rpa1/log")
{
    "outcome" => "success",
    "result" => undefined,
    "server-groups" => {"undefined" => {"host" => {"slave01" => {"rpa1" => {"response" => {
        "response-headers" => {
            "operation-requires-restart" => true,
            "process-state" => "restart-required"
        }
}

Check In host.xml file


  <servers>
        <server name="rpa1" group="rpa-group" auto-start="true">
            <jvm name="jvm-rpa">
                <heap size="64m" max-size="220m"/>
                <jvm-options>
                    <option value="-XX:HeapDumpPath=/u03/local/opt/jboss-eap-6.2/mydomain/slave2/servers/rpa2/log"/>
                    <option value="-XX:+HeapDumpOnOutOfMemoryError"/>
                </jvm-options>
            </jvm>
            <socket-bindings port-offset="100"/>
        </server>

If you want to add multiple JVM arguments to server instance,
The CLI command would be:

/host=slave01/server-config=rpa1/jvm=jvm-rpa:write-attribute(name=jvm-options,value=["-XX:+HeapDumpOnOutOfMemoryError","-XX:HeapDumpPath=/u03/local/opt/jboss-eap-6.2/mydomain/slave1/servers/rpa1/log","-Djava.net.preferIPv4Stack=true"]) 

Notice: We will have to bounce the application server for the property to take effect.

Check JVM settings through CLI
[domain@192.168.1.12:9999 /] /host=slave01/server-config=rpa1/jvm=jvm-rpa:read-resource
{                                                                                              
    "outcome" => "success",
    "result" => {
        "agent-lib" => undefined,
        "agent-path" => undefined,
        "debug-enabled" => undefined,
        "debug-options" => undefined,
        "env-classpath-ignored" => undefined,
        "environment-variables" => undefined,
        "heap-size" => "64m",
        "java-agent" => undefined,
        "java-home" => undefined,
        "jvm-options" => [
            "-XX:+HeapDumpOnOutOfMemoryError",
            "-XX:HeapDumpPath=/u03/local/opt/jboss-eap-6.2/mydomain/slave1/servers/rpa1/log",
            "-Djava.net.preferIPv4Stack=true"
        ],
        "max-heap-size" => "220m",
        "max-permgen-size" => undefined,
        "permgen-size" => undefined,
        "stack-size" => undefined,
        "type" => undefined
    }
}

Removing  a JVM parameters

[domain@192.168.1.12:9999 /] /host=slave01/server-config=rpa1/jvm=jvm-rpa:remove-jvm-option(jvm-option="-XX:HeapDumpPath=/u03/local/opt/jboss-eap-6.2/mydomain/slave1/servers/rpa1/log")
{
    "outcome" => "success",
    "result" => undefined,
    "server-groups" => {"undefined" => {"host" => {"slave01" => {"rpa1" => {"response" => {
        "outcome" => "success",
        "response-headers" => {
            "operation-requires-restart" => true,
            "process-state" => "restart-required"
        }
    }}}}}}
}


Check application server process, either these changes were effected or not. 

[jboss@middlewaretech log]$ ps -ef | grep -i rpa1

jboss    27158 17553  4 00:26 pts/5    00:00:39 /usr/java/jdk1.7.0_75/jre/bin/java -D[Server:rpa1] -Xms64m -Xmx220m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/u03/local/opt/jboss-eap-6.2/mydomain/slave1/servers/rpa1/log -Djava.net.preferIPv4Stack=true -D[Host Controller]=true -Djboss.domain.master.address=192.168.1.12 -Djava.awt.headless=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djboss.home.dir=/u03/local/opt/jboss-eap-6.2 -Djava.net.preferIPv4Stack=true -Djboss.domain.base.dir=/u03/local/opt/jboss-eap-6.2/mydomain/slave1 -Djboss.server.log.dir=/u03/local/opt/jboss-eap-6.2/mydomain/slave1/servers/rpa1/log -Djboss.server.temp.dir=/u03/local/opt/jboss-eap-6.2/mydomain/slave1/servers/rpa1/tmp -Djboss.server.data.dir=/u03/local/opt/jboss-eap-6.2/mydomain/slave1/servers/rpa1/data -Dlogging.configuration=file:/u03/local/opt/jboss-eap-6.2/mydomain/slave1/servers/rpa1/data/logging.properties -jar /u03/local/opt/jboss-eap-6.2/jboss-modules.jar -mp /u03/local/opt/jboss-eap-6.2/modules -jaxpmodule javax.xml.jaxp-provider org.jboss.as.server


No comments: