Monday, January 4, 2021

JBOSS Standalone script snippets


Below are some of the use full Jboss standalone script snippets .

add-user.sh
#!/bin/sh

ABSOLUTE_PATH="$(cd $(dirname "$0") && pwd -P)"
PROFILE_PATH="${ABSOLUTE_PATH%/*}"
DIR_NAME="${PROFILE_PATH##*/}"	# bin dir
#DIR_NAME="${ABSOLUTE_PATH##*/}"	# root dir

. $ABSOLUTE_PATH/jboss.env

JAVA_OPTS="$JAVA_OPTS -Djboss.server.config.user.dir=$SERVER_BASE_DIR/configuration "

#$JBOSS_HOME/bin/add-user.sh $@
$JBOSS_HOME/bin/add-user.sh
heapdump.sh

#!/bin/sh

ABSOLUTE_PATH="$(cd $(dirname "$0") && pwd -P)"
PROFILE_PATH="${ABSOLUTE_PATH%/*}"
DIR_NAME="${PROFILE_PATH##*/}"	# bin dir
#DIR_NAME="${ABSOLUTE_PATH##*/}"	# root dir

. $ABSOLUTE_PATH/jboss.env

PID=`ps -ef | grep java | grep "NODE_NAME=$NODE_NAME" | grep "jboss.server.base.dir=$SERVER_BASE_DIR" | awk '{print $2}'`
echo "PID:$PID"

if [ "$PID" == "" ]
then
    echo "$NODE_NAME is not running";
    exit 1;
fi

echo "jmap -dump:live,format=b,file=$PID-heapdump-$DATE.bin $PID"
jmap -dump:live,format=b,file=$PID-heapdump-$DATE.bin $PID
# EOF
jboss.env

DATE=`date "+%Y%m%d_%H%M%S"`
UNAME=`id -u -n`
JBOSS_USER="jboss"
NODE_NAME="sample"
##################################################
# JBOSS Common Setup
##################################################
JBOSS_HOME="/app/jboss"
SERVER_HOME="$JBOSS_HOME/SERVERS"
SERVER_BASE_DIR="$SERVER_HOME/$NODE_NAME"
SERVER_BIN_DIR="$SERVER_BASE_DIR/bin"
LOG_HOME="$SERVER_BASE_DIR/logs"

BIND_ADDR="192.168.1.71"
MGNT_ADDR="192.168.1.71"
PRIVATE_ADDR="192.168.1.71"
UNSECURE_ADDR="127.0.0.1"

MULTICAST_ADDR="230.0.0.3"
CLUSTER_PASSWD="CHANGEME!!"
MESSAGE_ADDR="231.7.10.1"
MESSAGE_PORT="9876"

MGNT_HTTP_PORT="9990"
MGNT_HTTPS_PORT="9993"

PORT_OFFSET="0"
PORT_AJP="8009"
PORT_HTTP="8080"
PORT_HTTPS="8443"

##################################################
# Current Host Setup
##################################################
GC_TYPE="g1"		# "cms", "parallel", "g1"(only jdk 7u4 or greater)
USE_LARGEPAGE="false"	# "true", "false"

##################################################
# Configration File
##################################################
SERVER_CONFIG_FILE="standalone-ha.xml"
##################################################
# Java Version Check
JAVA_VER=`java -version 2>&1 | sed 's/.*\?"\(.*\)".*/\1/; 1q'`
JAVA_VER_MAJOR=`java -version 2>&1 | sed 's/.*\?"\([0-9]*\)\..*".*/\1/; 1q'`
JAVA_VER_MINOR=`java -version 2>&1 | sed 's/.*\?"[0-9]*\.\([0-9]*\)\..*/\1/; 1q'`

if [ -z "$JAVA_VER" ]
then
        echo "Java is not installed"
        exit 1
fi
##################################################
# JVM Options
##################################################
JAVA_OPTS="-DNODE_NAME=$NODE_NAME"
JAVA_OPTS="$JAVA_OPTS -server"
JAVA_OPTS="$JAVA_OPTS -XX:+DoEscapeAnalysis"
JAVA_OPTS="$JAVA_OPTS -Xms2048m"
JAVA_OPTS="$JAVA_OPTS -Xmx4096m"

### Garbage Collection Options
JAVA_OPTS="$JAVA_OPTS -verbose:gc"
JAVA_OPTS="$JAVA_OPTS -XX:+HeapDumpOnOutOfMemoryError"
JAVA_OPTS="$JAVA_OPTS -XX:HeapDumpPath=$LOG_HOME/"

# Use on x86_64
JAVA_OPTS="$JAVA_OPTS -XX:+UseCompressedOops"

### Collector type : CMS(low pause)
if [ $GC_TYPE == "cms" ]; then
	JAVA_OPTS="$JAVA_OPTS -XX:+UseConcMarkSweepGC"			         
	JAVA_OPTS="$JAVA_OPTS -XX:+CMSClassUnloadingEnabled"		         
	JAVA_OPTS="$JAVA_OPTS -XX:+UseParNewGC"				         
	JAVA_OPTS="$JAVA_OPTS -XX:+ExplicitGCInvokesConcurrent"		         
	JAVA_OPTS="$JAVA_OPTS -XX:CMSInitiatingOccupancyFraction=80"	         
	JAVA_OPTS="$JAVA_OPTS -XX:CMSIncrementalSafetyFactor=20"	         
	JAVA_OPTS="$JAVA_OPTS -XX:+UseCMSInitiatingOccupancyOnly"	         

### Collector type : Parallel (throughput)
elif [ $GC_TYPE == "parallel" ]; then
	JAVA_OPTS="$JAVA_OPTS -XX:+UseParallelGC"
	JAVA_OPTS="$JAVA_OPTS -XX:+UseParallelOldGC"

### Collector type : G1 (low pause) ONLY USE for JDK 7u4 or greater
elif [ $GC_TYPE == "g1" ]; then
	JAVA_OPTS="$JAVA_OPTS -XX:+UseG1GC"
	JAVA_OPTS="$JAVA_OPTS -XX:+ExplicitGCInvokesConcurrent"
	JAVA_OPTS="$JAVA_OPTS -XX:MaxGCPauseMillis=500"
else
	echo "ERROR: GC_TYPE is NOT SET!!!";
	exit 0;
fi
###########################
# Setting for JVM Versions
if [ $JAVA_VER_MAJOR -ge 11 ]; then
        JAVA_OPTS="$JAVA_OPTS -Xlog:gc*:file=$LOG_HOME/gc-%p-%t.log:tags,uptime,time,level:filecount=10,filesize=50m"
else
        JAVA_OPTS="$JAVA_OPTS -Xloggc:$LOG_HOME/gc_$DATE.log"
        JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCDetails"
        JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCTimeStamps"
        JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCApplicationStoppedTime"

        if [ $JAVA_VER_MINOR -ge 8 ]; then
                JAVA_OPTS="$JAVA_OPTS -XX:+UseCompressedClassPointers"
                JAVA_OPTS="$JAVA_OPTS -XX:CompressedClassSpaceSize=1024M"
                JAVA_OPTS="$JAVA_OPTS -XX:MetaspaceSize=512M"
                JAVA_OPTS="$JAVA_OPTS -XX:MaxMetaspaceSize=512M"
        elif [ $JAVA_VER_MINOR -le 7 ]; then
                JAVA_OPTS="$JAVA_OPTS -XX:PermSize=256M"
                JAVA_OPTS="$JAVA_OPTS -XX:MaxPermSize=256M"
                JAVA_OPTS="$JAVA_OPTS -Djava.security.egd=file:/dev/./urandom"
        fi
fi

### Linux Large Page Setting
if [ $USE_LARGEPAGE == "true" ]; then
	JAVA_OPTS="$JAVA_OPTS -XX:+UseLargePages";
fi

JAVA_OPTS="$JAVA_OPTS -Djava.awt.headless=true"
JAVA_OPTS="$JAVA_OPTS -Djava.net.preferIPv4Stack=true"
JAVA_OPTS="$JAVA_OPTS -Dorg.jboss.resolver.warning=true"

### byteman
JAVA_OPTS="$JAVA_OPTS -Djboss.modules.system.pkgs=org.jboss.byteman"

##################################################
# Bind Address
##################################################
JAVA_OPTS="$JAVA_OPTS -Djboss.bind.address=$BIND_ADDR"
JAVA_OPTS="$JAVA_OPTS -Djboss.bind.address.management=$MGNT_ADDR"
JAVA_OPTS="$JAVA_OPTS -Djboss.bind.address.private=$PRIVATE_ADDR"
JAVA_OPTS="$JAVA_OPTS -Djboss.bind.address.unsecure=$UNSECURE_ADDR"

JAVA_OPTS="$JAVA_OPTS -Djboss.default.multicast.address=$MULTICAST_ADDR"
JAVA_OPTS="$JAVA_OPTS -Djboss.messaging.cluster.password=$CLUSTER_PASSWD"
JAVA_OPTS="$JAVA_OPTS -Djboss.messaging.group.address=$MESSAGE_ADDR"
JAVA_OPTS="$JAVA_OPTS -Djboss.messaging.group.port=$MESSAGE_PORT"

# Management
JAVA_OPTS="$JAVA_OPTS -Djboss.management.http.port=$MGNT_HTTP_PORT"
JAVA_OPTS="$JAVA_OPTS -Djboss.management.https.port=$MGNT_HTTPS_PORT"

# Port Offset
JAVA_OPTS="$JAVA_OPTS -Djboss.socket.binding.port-offset=$PORT_OFFSET"

# Ports
JAVA_OPTS="$JAVA_OPTS -Djboss.ajp.port=$PORT_AJP"
JAVA_OPTS="$JAVA_OPTS -Djboss.http.port=$PORT_HTTP"
JAVA_OPTS="$JAVA_OPTS -Djboss.https.port=$PORT_HTTPS"

# modcluster proxy list
#JAVA_OPTS="$JAVA_OPTS -Djboss.mod_cluster.proxyList=address1:port1,address2:port2"
#JAVA_OPTS="$JAVA_OPTS -Djboss.mod_cluster.excludedContexts=host1:context1,host2:context2,host3:context3"
#JAVA_OPTS="$JAVA_OPTS -Djboss.mod_cluster.jvmRoute="

### JBoss Env Setting - Global
#JAVA_OPTS="$JAVA_OPTS -Djboss.qualified.host.name=$NODE_NAME"
JAVA_OPTS="$JAVA_OPTS -Djboss.home.dir=$JBOSS_HOME"
JAVA_OPTS="$JAVA_OPTS -Djboss.host.name=$NODE_NAME"
JAVA_OPTS="$JAVA_OPTS -Djboss.host.default.config=$HOST_CONFIG_FILE"
JAVA_OPTS="$JAVA_OPTS -Djboss.node.name=$NODE_NAME"
JAVA_OPTS="$JAVA_OPTS -DjvmRoute=$NODE_NAME"
JAVA_OPTS="$JAVA_OPTS -Djboss.tx.node.id=$NODE_NAME"
JAVA_OPTS="$JAVA_OPTS -Dorg.jboss.boot.log.file=$LOG_HOME/boot.log"

### JBoss Env Setting - Standalone mode
JAVA_OPTS="$JAVA_OPTS -Djboss.server.base.dir=$SERVER_BASE_DIR"
JAVA_OPTS="$JAVA_OPTS -Djboss.server.default.config=$SERVER_CONFIG_FILE"
JAVA_OPTS="$JAVA_OPTS -Djboss.server.log.dir=$LOG_HOME"

JAVA_OPTS="$JAVA_OPTS -Djava.library.path=$LD_LIBRARY_PATH"

### Custom Settings
#JAVA_OPTS="$JAVA_OPTS -Dlogging.configuration=file:CONF_DIR/logging.properties"

export JAVA_OPTS

echo "================================================"
echo "JBOSS_HOME=$JBOSS_HOME"
echo "SERVER_HOME=$SERVER_HOME"
echo "NODE_NAME=$NODE_NAME"
echo "HOST_ADDR=$HOST_ADDR"
echo "SERVER_CONFIG_FILE=$SERVER_CONFIG_FILE"
echo "JAVA_VER=$JAVA_VER"
echo "JAVA_OPTS=$JAVA_OPTS"
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
echo "================================================"
# EOF
jboss.properties
org.apache.catalina.connector.URI_ENCODING=UTF-8
org.apache.catalina.connector.USE_BODY_ENCODING_FOR_QUERY_STRING=true

org.apache.catalina.connector.URI_ENCODING=UTF-8
org.apache.catalina.connector.USE_BODY_ENCODING_FOR_QUERY_STRING=true
org.hornetq.core.message.impl.HDR_DUPLICATE_DETECTION_ID=$NODE_NAME
# Cluster Property
jvmRoute=$NODE_NAME
jboss-cli.sh

#!/bin/sh
ABSOLUTE_PATH="$(cd $(dirname "$0") && pwd -P)"
PROFILE_PATH="${ABSOLUTE_PATH%/*}"
DIR_NAME="${PROFILE_PATH##*/}"	# bin dir
#DIR_NAME="${ABSOLUTE_PATH##*/}"	# root dir

. $ABSOLUTE_PATH/jboss.env

#export JAVA_OPTS="$JAVA_OPTS -Djava.awt.headless=false "

if [ "$MGNT_ADDR" == "0.0.0.0" ]
then
	MGNT_ADDR=127.0.0.1
fi

echo "$JBOSS_HOME/bin/jboss-cli.sh  --controller=$MGNT_ADDR:$((MGNT_HTTP_PORT + PORT_OFFSET)) --connect $@"
$JBOSS_HOME/bin/jboss-cli.sh  --controller=$MGNT_ADDR:$((MGNT_HTTP_PORT + PORT_OFFSET)) --connect $@
jstat.sh
#!/bin/sh
ABSOLUTE_PATH="$(cd $(dirname "$0") && pwd -P)"
PROFILE_PATH="${ABSOLUTE_PATH%/*}"
DIR_NAME="${PROFILE_PATH##*/}"	# bin dir
#DIR_NAME="${ABSOLUTE_PATH##*/}"	# root dir

. $ABSOLUTE_PATH/jboss.env
INTERVAL=${1:-1}

PID=`ps -ef | grep java | grep "NODE_NAME=$NODE_NAME" | grep "jboss.server.base.dir=$SERVER_BASE_DIR" | awk '{print $2}'`
echo "PID:$PID"

if [ "$PID" == "" ]
then
    echo "$NODE_NAME is not running";
    exit 1;
fi

echo "jstat -gc $PID $((INTERVAL*1000))"
jstat -gc $PID $(($INTERVAL*1000))
# EOF
kill.sh
#!/bin/sh
ABSOLUTE_PATH="$(cd $(dirname "$0") && pwd -P)"
PROFILE_PATH="${ABSOLUTE_PATH%/*}"
DIR_NAME="${PROFILE_PATH##*/}"	# bin dir
#DIR_NAME="${ABSOLUTE_PATH##*/}"	# root dir

. $ABSOLUTE_PATH/jboss.env

PID=`ps -ef | grep java | grep "NODE_NAME=$NODE_NAME" | grep "jboss.server.base.dir=$SERVER_BASE_DIR" | awk '{print $2}'`
echo $PID

if [ "$PID" == "" ]
then
    echo "JBoss SERVER - [$NODE_NAME] is NOT RUNNING..."
    exit 1;
fi
#ps -ef | grep java | grep "NODE_NAME=$NODE_NAME" | grep "jboss.server.base.dir=$SERVER_BASE_DIR" | awk {'print "kill -9 " $2'} | sh -x
kill -9 $PID

echo "Killing down SERVER $NODE_NAME..."
sleep 10
multicast_receive.sh
#!/bin/sh
ABSOLUTE_PATH="$(cd $(dirname "$0") && pwd -P)"
PROFILE_PATH="${ABSOLUTE_PATH%/*}"
DIR_NAME="${PROFILE_PATH##*/}"	# bin dir
#DIR_NAME="${ABSOLUTE_PATH##*/}"	# root dir

. $ABSOLUTE_PATH/jboss.env

java -cp $JBOSS_HOME/bin/client/jboss-client.jar org.jgroups.tests.McastReceiverTest -mcast_addr $MULTICAST_ADDR -port 5555
# EOF
shutdown.sh
#!/bin/sh
ABSOLUTE_PATH="$(cd $(dirname "$0") && pwd -P)"
PROFILE_PATH="${ABSOLUTE_PATH%/*}"
DIR_NAME="${PROFILE_PATH##*/}"  # bin dir
#DIR_NAME="${ABSOLUTE_PATH##*/}"        # root dir

. $ABSOLUTE_PATH/jboss.env

PID=`ps -ef | grep java | grep "NODE_NAME=$NODE_NAME " | awk '{print $2}'`
echo "PID:$PID"

if [ "$PID" == "" ]
then
    echo "JBoss SERVER - [$NODE_NAME] is NOT RUNNING..."
    exit 1;
fi
if [ "$PORT_OFFSET" != "" ]
then
	MGNT_HTTP_PORT=$(( $MGNT_HTTP_PORT + $PORT_OFFSET ))
fi

if [ "$MGNT_ADDR" == "0.0.0.0" ]
then
	MGNT_ADDR="127.0.0.1"
fi

echo "$JBOSS_HOME/bin/jboss-cli.sh --connect --controller=$MGNT_ADDR:$MGNT_HTTP_PORT --command=shutdown"
$JBOSS_HOME/bin/jboss-cli.sh --connect --controller=$MGNT_ADDR:$MGNT_HTTP_PORT --command=shutdown

if [ $? != 0 ]
then
        exit 1
fi
echo "Server $NODE_NAME Shutting Down..."
while true
do
PID=`ps -ef | grep java | grep "NODE_NAME=$NODE_NAME " | awk '{print $2}'`
echo "PID:$PID"

        if [ "$PID" == "" ]
        then
		echo "Shutdown complete"
                break
        fi
        sleep 2
done
echo "Done."
shutdown_pw.sh

#!/bin/sh

ABSOLUTE_PATH="$(cd $(dirname "$0") && pwd -P)"
PROFILE_PATH="${ABSOLUTE_PATH%/*}"
DIR_NAME="${PROFILE_PATH##*/}"  # bin dir
#DIR_NAME="${ABSOLUTE_PATH##*/}"        # root dir

. $ABSOLUTE_PATH/jboss.env

PID=`ps -ef | grep java | grep "NODE_NAME=$NODE_NAME " | awk '{print $2}'`
echo $PID

if [ "$PID" == "" ]
then
    echo "JBoss SERVER - [$NODE_NAME] is NOT RUNNING..."
    exit 1;
fi
echo -n "Account:"
read USERNAME
echo -n "Password:"
read -s PASSWORD
echo ""

if [ "$PORT_OFFSET" != "" ]
then
	MGNT_HTTP_PORT=$(( $MGNT_HTTP_PORT + $PORT_OFFSET ))
fi

if [ "$MGNT_ADDR" == "0.0.0.0" ]
then
	MGNT_ADDR="127.0.0.1"
fi

echo "$JBOSS_HOME/bin/jboss-cli.sh --connect --controller=$MGNT_ADDR:$MGNT_HTTP_PORT --user=$USERNAME --password=$PASSWORD --command=shutdown"
$JBOSS_HOME/bin/jboss-cli.sh --connect --controller=$MGNT_ADDR:$MGNT_HTTP_PORT --user=$USERNAME --password=$PASSWORD --command=shutdown

if [ $? != 0 ]
then
        exit 1
fi
echo "Server $NODE_NAME Shutting Down..."
while true
do
PID=`ps -ef | grep java | grep "NODE_NAME=$NODE_NAME " | awk '{print $2}'`
echo "PID:$PID"

        if [ "$PID" == "" ]
        then
                break
        fi
        sleep 2
done
echo "Done."
start.sh
#!/bin/sh
ABSOLUTE_PATH="$(cd $(dirname "$0") && pwd -P)"
PROFILE_PATH="${ABSOLUTE_PATH%/*}"
DIR_NAME="${PROFILE_PATH##*/}"	# bin dir
#DIR_NAME="${ABSOLUTE_PATH##*/}"	# root dir

. $ABSOLUTE_PATH/jboss.env

PID=`ps -ef | grep java | grep "NODE_NAME=$NODE_NAME " | awk '{print $2}'`
echo $PID

if [ "$PID" != "" ]
then
    echo "JBoss SERVER - [$NODE_NAME] is already RUNNING..."
    exit 1;
fi
if [ -z "$NODE_NAME" ]
then
	echo -e "\e[33mWARNING\e[0m : \e[32mjboss.env is not configured.\e[0m"
	echo -e "\e[33mWARNING\e[0m : Program Exit."
	exit 1
fi
if [ "$DIR_NAME" != "$NODE_NAME" ]
then
	echo -e "\e[33mWARNING\e[0m : \e[32mDIRECTORY and NODE_NAME are not same\e[0m"
	echo -e "ABSOLUTE_PATH=$ABSOLUTE_PATH"
	echo -e "PROFILE_PATH=$PROFILE_PATH"
	echo -e "DIR_NAME=$DIR_NAME"
	echo -e "NODE_NAME=$NODE_NAME"
	echo -e "\e[33mWARNING\e[0m : Program Exit."
	exit 2
fi

if [ "$JBOSS_USER" != "$UNAME" ]
then
	echo -e "\e[33mWARNING\e[0m : Current User is [\e[31m$UNAME\e[0m]. MUST run to [\e[32m$JBOSS_USER\e[0m]."
	echo -e "\e[33mWARNING\e[0m : Program Exit."
	exit 3
fi

if [ ! -e "$JBOSS_HOME" -o ! -e "$SERVER_HOME" ]; then
	echo "JBOSS_HOME or SERVER_HOME is not Exists";
	exit 4
fi

if [ ! -d "$LOG_HOME" ]; then
	mkdir -p $LOG_HOME
fi

nohup $JBOSS_HOME/bin/standalone.sh -P=$SERVER_BIN_DIR/jboss.properties >> $LOG_HOME/jboss_console.log 2>&1 &

exit 0
# EOF
thread_dump.conf
#!/bin/sh
ABSOLUTE_PATH="$(cd $(dirname "$0") && pwd -P)"
PROFILE_PATH="${ABSOLUTE_PATH%/*}"
DIR_NAME="${PROFILE_PATH##*/}"	# bin dir
#DIR_NAME="${ABSOLUTE_PATH##*/}"	# root dir

. $ABSOLUTE_PATH/jboss.env

PID=`ps -ef | grep java | grep "NODE_NAME=$NODE_NAME" | grep "jboss.server.base.dir=$SERVER_BASE_DIR" | awk '{print $2}'`
echo "PID:$PID"

if [ "$PID" == "" ]
then
    echo "$NODE_NAME is not running";
    exit 1;
fi

for count in {1..5}
do
    echo "`date` Thread Dump : $count"

    echo "jstack -l $PID >> $PID-thread_dump-$DATE-$count.dmp"
    jstack -l $PID >> $PID-thread_dump-$DATE-$count.dmp

    echo "sleep 1 sec"
    sleep 1
done

sysctl.conf
# Allow a 25MB UDP receive buffer for JGroups
net.core.rmem_max = 26214400
# Allow a 1MB UDP send buffer for JGroups
net.core.wmem_max = 1048576
net.core.rmem_default = 26214400
net.core.wmem_default = 1048576

Sunday, January 3, 2021

How to Download latest MQ Trail version

 

Search ibm mq trial version download on google it will open like below

click on the first link . URL is also pasted below .

https://www-01.ibm.com/marketing/iwm/iwm/web/download.do?source=ESD-WSMQ-EVAL&S_PKG=CRR2IML&S_TACT=109J84RW&lang=en_US&dlmethod=http

Click on signup process

Fill the details and verify email then it will take you to download page where you can download mq 9.2 LTS Trail version for the required OS .

If you already have an account just click on Log In on the below shown screen then it will directly take to download page .

Please verify system requirement before installing MQ version .

If the minimum OS version requirement doesn't match then we cannot install MQ successfully .

Monday, December 21, 2020

IBM MQ COLD Restart

 QMGR Recovery when the Disaster happens due to the Disk failures, Server crashes,Server restart without proper stopping QMGR or Human error’s like MQ administrator mistakenly delete QMGR active logs or Corrupted for some reason and unable to start the QMGR due to such failures . During such scenarios QMGR cold start is a very good technique to bring back the MQ from the Disaster failure.

We should verify the QMGR logs ,FFDC logs carefully to conclude the actives logs are corrupted due to any of the above mentioned reasons then only plan for Cold start .Other wise the check the logs for the reason and rectify based on the error . However we are discussing the situation where the active logs are no more or corrupted .

This document helps to understand how to recover qmgr when its active logs are corrupted. Take the backup of Entire /var/mqm/ before doing any changes  It will not take more space .

strmqm PROD.QM1  This will result below error

From the FDC logs/QMGR logs we see below error .

Take a backup copy of the qmgr data, log files any error logs/FDCs/dumps
Backup of /var/mmq/log/

Verify the existing QMGR /var/mqm/qmgrs/PROD.QM1/qm,ini file and take the below values from the QMGR. We will be creating TEMP QMGR with the exact  same attributes . We will not be starting this QMGR .

LogPrimaryFiles=100
LogSecondaryFiles=50
LogFilePages=2048
LogType=CIRCULAR

crtmqm –lc –lf 2048 –lp 100 –ls 50 TEMP

Once the TEMP QMGR is created we will not be starting this . We just need the active logs from /var/mqm/log/TEMP/active and /var/mqm/qmgrs/TEMP/amqalchk.fil file from TEMP QMGR to original QMGR .

/var/mqm/log/TEMP/active/* —> /var/mqm/log/PROD.QM1/active
/var/mqm/qmgrs/TEMP/amqalchk.fil —> /var/mqm/qmgrs/PROD.QM1/

We have replaced corrupted logs with the new logs .
Now start the QMGR with strmqm PROD.QM1
verify the status of QMGR using dspmq
Verify if there are any FDC logs , check the QMGR logs .If all the fine then verify the channel status . If all the channel status are good then we have successfully recovered the QMGR .

Please verify the connectivity with the Applications connecting to this qmgr.
Data in the queues is preserved if messages are persistent.

You can delete TEMP QMGR now . dltmqm TEMP

Monday, December 7, 2020

How to create DataSource in JBOSS

 Follow below steps for creating Data Source in JBOSS which will help for Application to connect DB using it .

STEP 1:
For MySQL
create directory structrue in /jboss/AppServer/jboss-eap-6.4/modules/
com/mysql .with in this create module.xml file with below content and copy driver jar file into this location
module.xml
<module xmlns="urn:jboss:module:1.1" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.0.8-bin.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>

For MariaDB
copy jar to JBOSS_HOME/modules/org/mariadb/main/
copy jar to JBOSS_HOME/modules/org/mariadb/
create module.xml with the below . Maria DB jar and will beloaded during jboss startup and the class from the jar refered in DataSource for connecting to DB
<module xmlns="urn:jboss:module:1.1" name="org.mariadb">
<resources>
<resource-root path="mariadb-java-client-1.3.3.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
STEP 2:Install Driver

Add driver with in <drivers> tag on domain.xml under full-ha profile .This diver will be visible when we create datasouce from JBOSS console .
For mysql
<driver name="mysql" module="com.mysql">
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
For db2
<driver name="mariadb" module="com.mariadb">
<xa-datasource-class>org.mariadb.jdbc.MariaDbDataSource</xa-datasource-class>
<drivers>
<driver name="db2" module="com.ibm.db2">
<driver-class>com.ibm.db2.jcc.DB2Driver</driver-class>
</driver>
For MariaDB
<driver name="mariadb" module="com.mariadb">
<xa-datasource-class>org.mariadb.jdbc.MariaDbDataSource</xa-datasource-class>
STEP 3:Creation DATA SOURCE

Login to JBOSS consile using jbadmin
Go to Configuration tab --> Select full-ha profile in dropdown box -->click on ADD Enter Name :MySqlDS JNDI Name:java:/jdbc/MySqlDS
-->click on next select the previously added driver and click on next
-->Provide Conection url UserName & Password then SAVE and do test connection .


Monday, November 30, 2020

Different types of Queue's in IBM MQ and its usage

 A queue is a container for messages. Business applications that are connected to the queue manager that hosts the queue can retrieve messages from the queue or can put messages on the queue.Let see the MQ objects and some theory about it .

Queues:

  • Broadly queues can be categorized under 2 names, 
  1. Predefined queue
  2. Dynamic Queues

Predefined queues

  • These are created by an administrator using the appropriate WebSphere MQ script (MQSC) commands or GUI tools. 
  • Predefined queues are permanent.
  • They exist independently of the applications that use them and survive WebSphere MQ restarts. 

Local queue (QLOCAL or QL)

  • Local queues are the only type of queue object within a queue manager that can hold messages.
  • Messages placed on the local queue, will occupy space on file system specified for it.
  • An Application can place messages in local queue and can receive messages from it. 
  • Triggering can be enabled for this type of queue.
  • Messages in queue local won’t be passed on to another queue manager. So, to move messages from one local queue to another one needs to use other support packs and third party Utilities.

Alias queue object (QALIAS or QA)

  • Alias queue objects provide a reference to another queue object with a different name. 
  • The target queue object can be a local queue, a remote queue object, or a queue shared within the queue manager cluster.
Notes:
  • Alias queue doesn’t store any messages in it. 
  • An application can place a message and consume messages from Alias Queue.

Few practical scenarios for using Alias Queues,

Satisfying Naming conventions

  • Each company/client will have their own naming standards for identifying objects or coding structures.
  • To satisfy different naming standards one can create any number of Alias queues pointing to same base queue.

Providing Different level of access

  • Allowing each application to access a base queue via an Alias queue, will facilitate us to restrict any particular application/program from accessing that queue without interrupting others.

Hiding the queue from other clients etc

  • Sometimes, internal programs have to exchange information with external parties (clients).
  • Keeping security reasons in mind, we can create alias queue pointing to the actual queue and will inform the other end team about Alias Queue only, not the base queue.

Model queue object (QMODEL or QM)

  • Model queue object is nothing but a template of queue attributes referring which, application can create dynamic queues as needed. 
Notes:
  • The attributes of the model queue object determine the attributes of the dynamic queue created.
  • Model queue doesn’t store any messages in it. 

There are 2 types of dynamic queues, 

  • Temporary dynamic queues
  • Permanent Dynamic queues
  • Type of dynamic queue to be created depends on one of model queue attribute value *DefinitionType*

Remote queue object (QREMOTE or QR)

  • Remote Queue is local definitions of remote destination queue.
  • This will provide destination Queue and Queue manager information to the message placed by Application. 
  • Imagine this with the working of postal box operation for ease of understanding.
  • A message passing through remote queue will get the address attached to it saying where it has to go.
Syntax of remote queue definition,

Define Qremote(Remote queue name) 
RNAME(destination queue name) 
RQMNAME(Destination Queue manager name) 
Xmitq(transmission queue)
  • Remote queue name:
    • It’s the name with which the local queue manager knows it.
  • Rname:
    • This attribute value is destination queue name, to which messages should be reached.
  • RQMNAME:
    • Remote queue manager name in with Rname queue exists.
Notes:
  • Remote queue doesn’t store any messages. 
  • An application can’t pull/get a message from remote queue but can put a message in it. 
  • Remote queue doesn’t have any curdepth attribute as it doesn’t store anything.

Queue manager Alias:

  • Just like, an alias queue is a false name to a actual queue, Queue manager Alias is a false name to represent another queue manager name. its definition can be given as below,
  • Define Qremote(QMGR Alias Name) RNAME(‘’) RQMNAME(NAME of the remote queue)
  • It is same as a remote queue definition but excluding the RNAME parameter.
  • This is used in multi-hopping of messages from one queue manager to another queue manager

Special local queues:

There are some local queues that have special purposes in WebSphere MQ.

 Dead letter queue

  • It is considered to be a backup queue for a queue manager.
  • If queue manager fails to place a message on destination queue then a message will be placed in dead letter queue with reason for failure. 
  • A dead letter queue is special type of local queue. 
  • MQ administrators may analyze the messages available in dead letter queue, and take a decision on to weather to move the messages to application or discard.
  • It is not mandatory for a queue manager to have a dead letter queue, but it is strongly recommended.
  • One can assign a dead letter queue to queue manager by, runmqsc command. Alter qmgr deadq(Name of dead letter queue)

 Initiation queue

  • It holds the trigger messages generated during triggering process .
  • Trigger monitor, which continuously monitors this queue will consume the trigger message and takes appropriate action.

Transmission queue

  • Transmission queue is related to remote queue defined in that queue manager.
  • A message placed in remote will pass on to transmission queue before guided to destination queue manager.
    • The Usage attribute indicates that a local queue is used as a transmission queue.
    • Transmission Queue is generally used for channel triggering.
    • A transmission queue works with message channels to enable queue manager-to-queue manager communication. 

Command queue

  • It receives WebSphere MQ commands from an MQ administration tool (MQ explorer & other tools or commands) running locally or remotely.
  • If this queue is PUT disabled (not available for placing messages), then no Administration tool can work with that queue manager.

Event queue

  • When a queue manager detects an instrumentation event (which is nothing but some significant occurrence in a queue manager such as an error or a warning), it puts an event message describing the event on an event queue. 
  • An event queue can be monitored by a system management application that can get the event message and take appropriate action.
    • For example:
      • SYSTEM.ADMIN.PERFM.EVENT
      • SYSTEM.ADMIN.CHANNEL.EVENT

Default queues

  • Identify the default values of attributes of any new queue that is created. 
  • There is one default queue for each of the four types of queues: local, alias, remote, and model. 
  • Thus, you only need to include in the definition of a queue those attributes whose values are different from the default values.
  • We can alter the default attribute values 
    • For example, 
    • SYSTEM.DEFAULT.LOCAL.QUEUE: holds the default attribute values for any new local queue created.
    • SYSTEM.DEFAULT.REMOTE.QUEUE: holds the default attribute values for any remote queue created.
  • Try looking for default attribute by typing
    • Dis q(SYSTEM*) in runmqsc mode and will show all the object queues.

Dynamic Queues:

  • When an application program issues an MQOPEN call to open a model queue, the queue manager dynamically creates an instance of a local queue with the same attributes as the model queue. This is called a Dynamic Queue.
  • Use a dynamic queue when you do not need the queue after your application ends.

An intro about both types of Dynamic Queues,

  • Temporary Dynamic Queues:
    • They hold non-persistent messages only. 
    • They are non-recoverable. 
    • They are deleted when the queue manager is started. 
    • They are deleted when the application that issued the MQOPEN call that created the queue closes the queue or terminates. 
  • Permanent Dynamic Queues:
    • They hold persistent or non-persistent messages. 
    • They are recoverable in the event of system failures. 
    • They are deleted when an application (not necessarily the one that issued the MQOPEN call that created the queue) successfully closes the queue using the MQCO_DELETE or MQCO_DELETE_PURGE option. 
    • They can be deleted in the same way as a normal queue. 

Listeners:

  • Listener objects are used to accept incoming network requests from remote queue managers, or client applications
  • It’s a continuously running process at a particular port of the machine.
  • It listens to the incoming messages and informs the receiving MCA or server MCA about the network requests.
  • Listener can be controlled by queue manager automatically, i.e, It can start automatically with queue manager startup. For this ensure, the control attribute of listener should be as “QMGR”

Namelists:

  • A namelist is a WebSphere MQ object that contains a list of other WebSphere MQ objects. 
  • Namelists are used by applications such as trigger monitors, where they are used to identify a group of queues. 
  • The advantage of using a namelist is that it is maintained independently of applications; i.e, it can be updated without stopping any of the applications that use it. Also, if one application fails, the namelist is not affected and other applications can continue using it.
  • Namelists are also used with queue manager clusters so that you can maintain a list of clusters referenced by more than one WebSphere MQ object.

Monday, November 9, 2020

How to Encrypt JBOSS Passwords using VAULT

 Here we will see how to encrypt the password used in JBOSS like Keystore password ,key Pass phrase ,Data Source password or any other passwords that need to encrypt can be done with the VAULT and follow steps.

Encrypt Password in JBOSS
------------------------------------
1. Copy jks keystore to /hom/jboss in both Master and Slave
Bring down all controllers
2. 06-Oct-14@14:05:29-jboss@hostname1a:/rh/jboss/app1a/bin>./vault.sh
=====================================================================

JBoss Vault

JBOSS_HOME: /rh/jboss/app1a

JAVA: /usr/IBM/WebSphere/AppServer/java/bin/java

=====================================================================

**********************************
**** JBoss Vault ***************
**********************************
Please enter a Digit:: 0: Start Interactive Session 1: Remove Interactive Session 2: Exit
1

1
Removing the current interactive session
Please enter a Digit:: 0: Start Interactive Session 1: Remove Interactive Session 2: Exit
Removing the current interactive session
Please enter a Digit:: 0: Start Interactive Session 1: Remove Interactive Session 2: Exit
0
Starting an interactive session
Enter directory to store encrypted files:/home/jboss
Enter Keystore URL:/home/jboss/hostname1a.jks
Enter Keystore password:
Enter Keystore password again:
Values match
Enter 8 character salt:12345678
Enter iteration count as a number (Eg: 44):44
Enter Keystore Alias:hostname1a
Initializing Vault
Oct 6, 2014 2:06:33 PM org.picketbox.plugins.vault.PicketBoxSecurityVault init
INFO: PBOX000361: Default Security Vault Implementation Initialized and Ready
Vault Configuration in AS7 config file:
********************************************
...
</extensions>
<vault>
<vault-option name="KEYSTORE_URL" value="/home/jboss/hostname1a.jks"/>
<vault-option name="KEYSTORE_PASSWORD" value="MASK-2exADfZEVkq4nkGflMRrtM"/>
<vault-option name="KEYSTORE_ALIAS" value="hostname1a"/>
<vault-option name="SALT" value="12345678"/>
<vault-option name="ITERATION_COUNT" value="44"/>
<vault-option name="ENC_FILE_DIR" value="/home/jboss/"/>
</vault><management> ...
********************************************
Vault is initialized and ready for use
Handshake with Vault complete
Please enter a Digit:: 0: Store a secured attribute 1: Check whether a secured attribute exists 2: Exit

0
Task: Store a secured attribute
Please enter secured attribute value (such as password):
Please enter secured attribute value (such as password) again:
Values match
Enter Vault Block:db2ds
Enter Attribute Name:db2ds
Secured attribute value has been stored in vault.
Please make note of the following:
********************************************
Vault Block:db2ds
Attribute Name:db2ds
Configuration should be done as follows:
VAULT::db2ds::db2ds::1
********************************************
Please enter a Digit:: 0: Store a secured attribute 1: Check whether a secured attribute exists 2: Exit
1
Task: Verify whether a secured attribute exists
Enter Vault Block:db2ds
Enter Attribute Name:db2ds
A value exists for (db2ds, db2ds)
Please enter a Digit:: 0: Store a secured attribute 1: Check whether a secured attribute exists 2: Exit
[2] + Stopped (SIGTSTP) ./vault.sh
You have mail in /usr/spool/mail/jboss
06-Oct-14@14:14:46-jboss@hostname1a:/rh/jboss/app1a/bin>


3. Add below Vault in both Domain and Host controller
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
FROM CLI

[domain@10.91.74.96:39999 /] /host=/host=master/core-service=vault:add(vault-options=[("KEYSTORE_URL" => "/home/jboss/a01sribapp3a.jks"),("KEYSTORE_PASSWORD" => "MASK-2exADfZEVkq4nkGflMRrtM"), ("KEYSTORE_ALIAS" => "a01sribapp3a"), ("SALT" => "12345678"), ("ITERATION_COUNT" => "44"), ("ENC_FILE_DIR" => "/home/jboss/")])

Manually

<vault>
<vault-option name="KEYSTORE_URL" value="/home/jboss/vaultks.jks"/>
<vault-option name="KEYSTORE_PASSWORD" value="MASK-2exADfZEVkq4nkGflMRrtM"/>
<vault-option name="KEYSTORE_ALIAS" value="vaultks"/>
<vault-option name="SALT" value="12345678"/>
<vault-option name="ITERATION_COUNT" value="44"/>
<vault-option name="ENC_FILE_DIR" value="/home/jboss/"/>
</vault><management> ...

4. Edit domain.xml and in place of password give ${VAULT::db2ds::db2ds::1}

5. Start Domain ,host controllers and servers test the connectivity


Note: There is no way we can decrypt the password that is encrypted using VALUE . We can only check the key value exist or not and update the new password .

Wednesday, October 28, 2020

How to create SAN Certificate and its usage

 SAN Stands for Subject alternative name . Where the same certificate with multiple names used for multiple domains . This will save cost .Example we can generate one certificate and add other domain names in the subject Alternative Names can use for multiple sites .

Follow below steps for generation SAN certificate to configure in Apache WebServer .

create san.conf file with the below sample content
[ req ]
default_bits = 2048
distinguished_name = req_distinguished_name
prompt= no
req_extensions = req_ext
[ req_distinguished_name ]
countryName = Country Name (2 letter code)
stateOrProvinceName = State or Province Name (full name)
localityName = Locality Name (eg, city)
organizationName = Organization Name (eg, company)
commonName = Common Name (e.g. server FQDN or YOUR name)
[ req_ext ]
subjectAltName = @alt_names
[alt_names]
DNS.1 = abc.com
DNS.2 = def.com
DNS.3 = fgh.com

Updated san.conf looks like below for multiple common names

This image has an empty alt attribute; its file name is SAN.png
Generate key with csr file using below openssl command
openssl req -out sslcert.csr -newkey rsa:2048 -sha256 -nodes -keyout private.key -config san.conf
This image has an empty alt attribute; its file name is KeyGeneration-1024x118.png
This image has an empty alt attribute; its file name is files.png

once CSR file is generated you can verify the content on the https://www.entrust.net/ssl-technical/csr-viewer.cfm
copy content of sslcert.csr into the above UR or use below
openssl req -noout -text -in sslcert.csr | grep DNS

This image has an empty alt attribute; its file name is csrver1-1024x625.png
This image has an empty alt attribute; its file name is csrver2-1024x615.png

You can verify CSR with openssl

This image has an empty alt attribute; its file name is DNS.png
Once CSR is verified .Get this signed with Third pary vendor line Entrust ,Symatic --etc
Down load the CSR and root , Intermediate certs in PEM format .

for Apache SSL configuration we need 3 files .
Rename given CER to httpd.cer for SSLCertificateFile . private.key to httpd.key . Create SSLCACertificateFile by appending Intermediate with Root.cer files.

cat intermediate.cer >httpd_ca.crt && cat root.cer >>httpd_ca.crt

SSLCertificateFile /web/apache/WEB1A/ssl/httpd.cer
SSLCertificateKeyFile /web/apache/WEB1A/ssl/httpd.key
SSLCACertificateFile /web/apache/WEB1A/ssl/httpd_ca.crt

Wednesday, October 21, 2020

JBOSS EAP Patching and Rollback steps

Refer below JBOSS patching and reversion steps 

JBOSS Patching

Download Patch from https://access.redhat.com/downloads/.
Before running any jboss commands please make sure JAVA_HOME is set
export JAVA_HOME=/app/java8_64
Go to JAVA_HOME/bin and run jboss-cli.sh then run below to patch
patch apply /path/to/downloaded-patch.zip

[standalone@localhost:9999/] patch apply /tmp/jboss-eap-6.4.2.zip
"outcome" : "success",
"response-headers" : {
"operation-requires-restart" : true,
"process-state" : "restart-required"
}
}
updated modules available in JBOSS_HOME/modules/system/layer/base/.overlay
Once patch is successfull then restart the services

Patch Rollback

[standalone@localhost:9999/] patch rollback --patch-id=jboss-eap-6.4.2.CP --reset-configuration=true
{
"outcome" : "success",
"response-headers" : {
"operation-requires-restart" : true,
"process-state" : "restart-required"
}
}

Restart the services after successfull rollback

-->During Jboss patching if you get any error says /tmp is full . By default jboss used /tmp as temperary directory .
Can change it by -Djava.io.tmpdir=<new path>
export JAVA_OPTS="-Djava.io.tmpdir=<new path>"
--> To preseve any config file use --preserve=[bin/jboss-cli.xml]

Featured

Weblogic Domain Migration

 In this blog we will see domain re-configuration which will be done as part of Weblogic migration from lower version to higher version [ Ex...