Friday, 6 November 2015

JVM Heap memory Settings in JBoss Domain Mode

An important feature of the managed domain is the ability to define JVM settings at multiple levels.You can configure custom JVM settings at the host level, by server group, or by server instance. The more specialized child elements will override the parent configuration.

If you define a generic JVM at host level, it will be overridden by the same JVM at serer group level.
If you define a generic JVM at server level, then that will be the final choice for that server. 


Host Level: In this case, The configuration will apply to all servers that are defined in host.xml

Server Group Level: In this case, The configuration will apply to all servers that are part of the group

Server level: In this case, The Configuration is used just for the single host.

1.Host Level:

The following example shows a JVM declaration in the host.xml configuration file. Any server that belongs to this host will inherit these settings.

<jvms>
        <jvm name="default">
            <heap size="64m" max-size="256m"/>
            <permgen size="256m" max-size="256m"/>
            <jvm-options>
                <option value="-server"/>
            </jvm-options>
        </jvm>
    </jvms>

please restart application server once you changes have done. 

jbossas@middleware bin]$ ps -ef | grep java | grep -i GB_SERVER01
jbossas  10280  9618 16 22:22 pts/2    00:00:06 /usr/java/jdk1.7.0_75/jre/bin/java -D[Server:GB_SERVER01] -XX:PermSize=128m -XX:MaxPermSize=128m -Xms64m -Xmx256m -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=/u02/local/opt/jboss-eap-6.2 -Djava.net.preferIPv4Stack=true -Djboss.domain.base.dir=/u02/local/opt/mydomain/slave01/ -Djboss.server.log.dir=/u02/local/opt/mydomain/slave01/servers/GB_SERVER01/log -Djboss.server.temp.dir=/u02/local/opt/mydomain/slave01/servers/GB_SERVER01/tmp -Djboss.server.data.dir=/u02/local/opt/mydomain/slave01/servers/GB_SERVER01/data -Dlogging.configuration=file:/u02/local/opt/mydomain/slave01/servers/GB_SERVER01/data/logging.properties -jar /u02/local/opt/jboss-eap-6.2/jboss-modules.jar -mp /u02/local/opt/jboss-eap-6.2/modules -jaxpmodule javax.xml.jaxp-provider org.jboss.as.server


2.Server Group Level:

The following example shows a JVM declaration for a server group in the domain. xml configuration file.

<server-groups>
        <server-group name="GB_SERVER_GROUP01" profile="full-ha">
            <jvm name="default">
                <heap size="100m" max-size="225m"/>
            </jvm>
 </server-group>
 </server-groups>


In this instance a server group called GB_SERVER_GROUP01 is declaring a heap size of 100 megabytes, and a maximum heap size of 225 megabytes. Any server that belongs to this group will inherit these settings.

please restart application server once you changes have done. 

[jbossas@middleware bin]$ ps -ef | grep java | grep -i GB_SERVER0

jbossas  10741  9618 36 22:24 pts/2    00:00:11 /usr/java/jdk1.7.0_75/jre/bin/java -D[Server:GB_SERVER01] -XX:PermSize=256m -XX:MaxPermSize=256m -Xms100m -Xmx225m -server -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=/u02/local/opt/jboss-eap-6.2 -Djava.net.preferIPv4Stack=true -Djboss.domain.base.dir=/u02/local/opt/mydomain/slave01/ -Djboss.server.log.dir=/u02/local/opt/mydomain/slave01/servers/GB_SERVER01/log -Djboss.server.temp.dir=/u02/local/opt/mydomain/slave01/servers/GB_SERVER01/tmp -Djboss.server.data.dir=/u02/local/opt/mydomain/slave01/servers/GB_SERVER01/data -Dlogging.configuration=file:/u02/local/opt/mydomain/slave01/servers/GB_SERVER01/data/logging.properties -jar /u02/local/opt/jboss-eap-6.2/jboss-modules.jar -mp /u02/local/opt/jboss-eap-6.2/modules -jaxpmodule javax.xml.jaxp-provider org.jboss.as.server

jbossas  10915  9201 88 22:25 pts/1    00:00:10 /usr/java/jdk1.7.0_75/jre/bin/java -D[Server:GB_SERVER02] -XX:PermSize=256m -XX:MaxPermSize=256m -Xms100m -Xmx225m -server -D[Host Controller]=true -Djboss.domain.master.address=192.168.1.12 -Djava.awt.headless=true -D-Xms=125 -Djboss.modules.system.pkgs=org.jboss.byteman -Djboss.home.dir=/u02/local/opt/jboss-eap-6.2 -Djava.net.preferIPv4Stack=true -D-Xmx=225 -Djboss.domain.base.dir=/u02/local/opt/mydomain/slave02/ -Djboss.server.log.dir=/u02/local/opt/mydomain/slave02/servers/GB_SERVER02/log -Djboss.server.temp.dir=/u02/local/opt/mydomain/slave02/servers/GB_SERVER02/tmp -Djboss.server.data.dir=/u02/local/opt/mydomain/slave02/servers/GB_SERVER02/data -Dlogging.configuration=file:/u02/local/opt/mydomain/slave02/servers/GB_SERVER02/data/logging.properties -jar /u02/local/opt/jboss-eap-6.2/jboss-modules.jar -mp /u02/local/opt/jboss-eap-6.2/modules -jaxpmodule javax.xml.jaxp-provider org.jboss.as.server

3.Server level:

The following example shows a JVM declaration for a server level in the host.xml configuration file.

<servers>
        <server name="GB_SERVER01" group="GB_SERVER_GROUP01" auto-start="true">
            <jvm name="default" debug-enabled="false">
                <heap size="90m" max-size="180m"/>
            </jvm>
            <socket-bindings socket-binding-group="full-ha-sockets" port-offset="100"/>
        </server>
</servers>


Here , The server defination overrides other host/group defination. 

please restart application server once you changes have done. 


[jbossas@middleware bin]$ ps -ef | grep java | grep -i GB_SERVER0
jbossas  11207  9618 33 22:27 pts/2    00:00:11 /usr/java/jdk1.7.0_75/jre/bin/java -D[Server:GB_SERVER01] -XX:PermSize=256m -XX:MaxPermSize=256m -Xms90m -Xmx180m -server -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=/u02/local/opt/jboss-eap-6.2 -Djava.net.preferIPv4Stack=true -Djboss.domain.base.dir=/u02/local/opt/mydomain/slave01/ -Djboss.server.log.dir=/u02/local/opt/mydomain/slave01/servers/GB_SERVER01/log -Djboss.server.temp.dir=/u02/local/opt/mydomain/slave01/servers/GB_SERVER01/tmp -Djboss.server.data.dir=/u02/local/opt/mydomain/slave01/servers/GB_SERVER01/data -Dlogging.configuration=file:/u02/local/opt/mydomain/slave01/servers/GB_SERVER01/data/logging.properties -jar /u02/local/opt/jboss-eap-6.2/jboss-modules.jar -mp /u02/local/opt/jboss-eap-6.2/modules -jaxpmodule javax.xml.jaxp-provider org.jboss.as.server


Definig JVM's through CLI:

The CLI command to define a new JVM looks like:

[domain@192.168.1.12:9999 /] /host=master/jvm=default:add(heap-size=64m, max-heap-size=220m)

the JVM named default will have a minimum heap size of 64 m and max heap size of 220mb.


Server Group Level:

check current heap size :

[domain@192.168.1.12:9999 /] /server-group=GB_SERVER_GROUP01/jvm=default:read-resource
{
    "outcome" => "success",
    "result" => {
        "agent-lib" => undefined,
        "agent-path" => undefined,
        "env-classpath-ignored" => undefined,
        "environment-variables" => undefined,
        "heap-size" => "100m",
        "java-agent" => undefined,
        "java-home" => undefined,
        "jvm-options" => undefined,
        "max-heap-size" => "225m",
        "max-permgen-size" => undefined,
        "permgen-size" => undefined,
        "stack-size" => undefined,
        "type" => undefined
    }
}


[domain@192.168.1.12:9999 /] /server-group=GB_SERVER_GROUP01/jvm=default:write-attribute(name=heap-size, value=110)
{
    "outcome" => "success",
    "result" => undefined,
    "server-groups" => {"GB_SERVER_GROUP01" => {"host" => {
        "slave01" => {"GB_SERVER01" => {"response" => {
            "outcome" => "success",
            "result" => undefined,
            "response-headers" => {
                "operation-requires-restart" => true,
                "process-state" => "restart-required"
            }
        }}},
        "slave02" => {"GB_SERVER02" => {"response" => {
            "outcome" => "success",
            "result" => undefined,
            "response-headers" => {
                "operation-requires-restart" => true,
                "process-state" => "restart-required"
            }
        }}}
    }}}
}

please restart application server once you changes have done.


[domain@192.168.1.12:9999 /] /server-group=GB_SERVER_GROUP01:restart-servers
{
    "outcome" => "success",
    "result" => undefined,
    "server-groups" => undefined
}

the resulting JVM settings look like

[domain@192.168.1.12:9999 /] /server-group=GB_SERVER_GROUP01/jvm=default:read-resource
{
    "outcome" => "success",
    "result" => {
        "agent-lib" => undefined,
        "agent-path" => undefined,
        "env-classpath-ignored" => undefined,
        "environment-variables" => undefined,
        "heap-size" => 110,
        "java-agent" => undefined,
        "java-home" => undefined,
        "jvm-options" => undefined,
        "max-heap-size" => "225m",
        "max-permgen-size" => undefined,
        "permgen-size" => undefined,
        "stack-size" => undefined,
        "type" => undefined
    }
}

1 comment: