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


Saturday 12 March 2016

server groups

A server group is a collection of server instances that are managed and configured as one. In a managed domain, every application server instance belongs to a server group, even if it is the only member. The server instances in a group share the same profile configuration and deployed content. 

All servers (server instances) of the same server group perform the same tasks because they share the same profile configuration and deployed content.

A domain can consist of multiple server groups. Different server groups can be configured with different profiles and deployments. A domain can be configured with different server tiers providing different services.

Different server groups can also have the same profile and deployments. This can, for example, allow for rolling application upgrades where the application is upgraded on one server group and then updated on a second server group, avoiding a complete service outage.

Adding a Server Group

Launch the management CLI in Linux by typing the following text at the command prompt:
[domain@192.168.1.12:9999 /] /server-group=rpa-group:add(profile=full-ha, socket-binding-group=full-ha-sockets)
{
    "outcome" => "success",
    "result" => undefined,
    "server-groups" => undefined
}

fallowing content has been added to domain.xml
<server-groups>
        <server-group name="rpa-group" profile="full-ha">
            <socket-binding-group ref="full-ha-sockets"/>
        </server-group>
    </server-groups>


A server group includes the following mandatory attributes:

name: the server group name.
profile: the server group profile name.
socket-binding-group: the default socket binding group used for servers in the group. This name can be overridden on a per-server basis in host.xml. However, this is a mandatory element for every server group and the domain cannot start if it is missing.

A server group includes the following optional attributes:

deployments: the deployment content to be deployed on the servers in the group.
system-properties: the system properties to be set on servers in the group
jvm: the default JVM settings for all servers in the group. The host controller merges these settings with any other configuration provided in host.xml to derive the settings used to launch the server's JVM.
socket-binding-port-offset: the default offset to be added to the port values given by the socket binding group.

Removing a Server Group

You may want to remove a server group when you no longer need it—for example, in situations where no applications are running on these server groups.

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

Note : Unable to access Web Admin Console on JBoss EAP 6.2 and facing error : "Insufficient privileges to access".

When "domain.xml" is used without any profile and "server-group" then admin console shows "insufficient privileges"

Resolution
EAP 6.2.0 web console unnecessarily checks for the existence of a server-group.
As a work around, add a dummy profile and server group.

Adding a Server to a Server Group
[domain@192.168.1.12:9999 /] /host=slave01/server-config=rpa1:add(auto-start=true, group=rpa-group, socket-binding-port-offset=100)
{
    "outcome" => "success",
    "result" => undefined,
    "server-groups" => undefined
}


HOSTNAME is defined in host.xml in the JBOSS_HOME/domain/configuration directory.
SERVER_NAME is the name of the server that you want to add.
SERVER_GROUP_NAME is the name of the server group to which you want to add the new server.

fallowing content has been added to host.xml of slave01 HC.
<servers>
        <server name="rpa1" group="rpa-group" auto-start="true">
            <socket-bindings port-offset="100"/>
        </server>

Starting Servers in a Server Group
[domain@192.168.1.12:9999 /] /server-group=rpa-group:start-servers()
{
    "outcome" => "success",
    "result" => undefined,
    "server-groups" => undefined
}

Stopping Servers in a Server Group
[domain@192.168.1.12:9999 /] /server-group=rpa-group:stop-servers
{
    "outcome" => "success",
    "result" => undefined,
    "server-groups" => undefined
}

Removing a server

first stop the server, then you can able to remove the server.
[domain@192.168.1.12:9999 /] /host=slave02/server-config=server-two:stop(server=true)
{
    "outcome" => "success",
    "result" => "STOPPING"
}

[domain@192.168.1.12:9999 /] /host=slave02/server-config=server-two:remove()
{
    "outcome" => "success",
    "result" => undefined,
    "server-groups" => undefined
}



Friday 4 March 2016

Clearing all messages from a queue through Shell Script

I have written a shell script to find out how many messages are struck in queue and purging/deleting messages from queue.

 Download the following script and store it in a location such as /usr/local/bin.
 Provide the file permissions and ownership for this script as you see fit. In this example, they are:

$ chmod 755 /usr/local/bin/clear-mq-messages.sh
$ chown mqm:mqm /usr/local/bin/clear-mq-messages.sh
$ ls -l /usr/local/bin/clear-mq-messages.sh
-rwxr-xr-x   1 mqm      mqm            1296 Oct 30 14:34 clear-mq-messages.sh

#!/usr/bin/ksh
echo -e "\nPlease enter the \"queuemanager\" !!!"
                read queuemanager
echo -e "\nPlease enter the \"input_queue\" !!!"
        read inputqueue

struck_message=`echo  "DISPLAY QL($inputqueue) CURDEPTH" | runmqsc $queuemanager | grep 'CURDEPTH(' | sed 's/.*CURDEPTH//' | tr -d '()'`

if [ $struck_message = "0" ]; then
   
echo -e "==============================================="
echo "now no messages in " $inputqueue
echo -e "==============================================="
echo -e "\n\nThank you!!! Bye!!!\n"
exit 0
else
echo -e "==============================================="
    echo "the" $inputqueue "CURDEPTH count is" $struck_message
echo -e "==============================================="

fi
echo -e "Would you really like to flush the $inputqueue? <y/N> "
read prompt
if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]
then
echo -e "************************************************"
echo "clear qlocal($inputqueue)" | runmqsc $queuemanager
 echo -e "************************************************"
               
struck_message2=`echo  "DISPLAY QL($inputqueue) CURDEPTH" | runmqsc $queuemanager | grep 'CURDEPTH(' | sed 's/.*CURDEPTH//' | tr -d '()'`

echo "Now the CURDEPTH count is" $struck_message2
echo -e "************************************************"
else
echo -e "\n\nThank you!!! Bye!!!\n\n"
                  exit 0
fi

Let see how this script will work

while script executing time this script will ask QueueManager name & queue name. 




 Let see CURDEPTH  count only....


If CURDEPTH count is zero, the script will work as below



I hope this information is helpful to you

Thursday 3 March 2016

The WebSphere MQ Queue Load / Unload Utility

How to Load/UnLoad messages from Websphere MQ Queues Using Qload & Unload Utility

The WebSphere MQ Queue Load / Unload Utility allows the user to copy or move the contents of a queue, its messages, to a file. This file can be saved away as required and used at some later point to reload the messages back onto the queue. This file has a specific format understood by the utility, but is human-readable, so that it can be updated in an editor before being reloaded.

Create Queue Manager:
 crtmqm QM1
start Queue mqnqger:
strmqm QM1
Create local queues:
runmqsc QM1
DEFINE QLOCAL(Q1)
DEFINE QLOCAL(Q2)

Put 10 messages into queue1

Sample Commands :

1. Backup messages from a Queue to a file:
 qload –m QM1 –i Q1 –f /tmp/bkpmsg

2. import messages from a file to the queue:
qload –m QM1 –o LQ1 –f /tmp/bkpmsg

3. Copying messages from a queue to another queue:
qload –m QM1 –i Q1 –o Q2

4. Copying certain number of messages from a queue to another queue:
(e.g) we need to copy first 15 messages from a Q1 to Q2
qload –m QM1 –i Q1 –o Q2 –r#20

“-r” Parameter:
x  =  Process x messages only
x..y  =  Process messages between x and y
X#y  =  Process messages from x to y count
#y  =  Process first y count of messages (just like in e.g)

5. Move entire message from a queue to another queue:
qload –m QM1 –i Q1 –o Q2

6. Unload and remove 10 messages, starting at message 530:

qload –m QM1 –I Q1 –f /tmp/bkpmsg –dA –r53#10

7.Unload and remove messages from 43 to 52:

qload –m QM1 –I Q1 –f /tmp/bkpmsg –dA –r43..52

No messages are removed from the queue as the lower case “i” instructs qload to use browse.

8.Unload and remove first message on queue Q1, with deletion:


qload –m QM1 –I Q1 –f /tmp/bkpmsg –dA –r1