Wednesday, March 31, 2021

How to restore message from Dead letter queue to original queue

 

How to restore message from Dead letter Queue to original queue for Application processing so that there will not be any impact . 

There are many reasons for the message go into dead letter queue . The actual reason for the message will be seem in the message header . In this we will see how to restore the message back to original queue from DLQ . Will see how to check the reason code later .

Use the dmpmqmsg utility to copy or move the contents of a queue, or its messages, to a file. Formerly the IBM MQ qload utility.

The following command can be used to move the messages from DLQ to original queue:

dmpmqmsg -m <qmgr name> -i <DLQ name> -o <destination queue name> -h
dmpmqmsg used for (queue load and unload)
Note: Please replace <qmgr name>, <DLQ name>, <destination queue name> with real names. The option "-h" is used to remove DLQ header.
-i or -I Input queue name
Note :Using -i browses the queue, whereas using -I gets messages from the queue.

For more options refer link dmpmqmsg help

Tuesday, March 23, 2021

How to enable SSL for JBOSS App Port

Find the below clear steps for enabling SSL for App Port on JBOSS EAP 7.X version . 

1.edit host or standalone.xml and add below JKS 
<security-realms>
<security-realm name="httpsrealm">
<server-identities>
<ssl>
<keystore path="/app/ssl/keystore.jks" keystore-password="xxxx" alias="site"/>
</ssl>
</server-identities>
<authentication>
<truststore path="/app/ssl/truststore.jks" keystore-password="xxxxxx"/>
</authentication>
</security-realm>
</security-realms>

2. Add below under undertow with in the respective profile for domain setup and in standalone.xml for standalone mode setup
<subsystem xmlns="urn:jboss:domain:undertow:3.1">
<buffer-cache name="default"/>
<server name="default-server">
<http-listener name="default" socket-binding="http" redirect-socket="https"/>
<https-listener name="https" secure="true" enabled-protocols="TLSv1.1,TLSv1.2" security-realm="httpsrealm" socket-binding="https"/>
.....
3.Restart and verify the App Https port to see if it reflects configured https certificate

Tuesday, March 16, 2021

Steps to enable SSL to JBOSS Console

 Now a days SSL is a mandatory security check for all the websites to encrypt the data transfer . Also called Data Encrypt at Transit .


Steps to enable SSL to JBOSS Console
------------------------------------------
1. Add below Server-idntities tag and truststore in both Host and Domain controller config giles

<security-realm name="ManagementRealm">
<server-identities>
<ssl protocol="TLS">
<keystore path="D:\JBC\hostname1a.jks" keystore-password="hostname1a" alias="hostname1a"/>
</ssl>
</server-identities>
<authentication>
<truststore path="D:\JBC\hostname1a.jks" keystore-password="hostname1a"/>


2. In the below management-interfaces replace port with secure-port (NOTE: Below change is only on domain-controller file )

<management-interfaces>
<native-interface security-realm="ManagementRealm">
<socket interface="management" port="${jboss.management.native.port:9999}"/>
</native-interface>
<http-interface security-realm="ManagementRealm">
<socket interface="management" secure-port="9990"/>
</http-interface>
<!-- <http-interface security-realm="ManagementRealm">
<socket interface="management" port="${jboss.management.http.port:9990}"/>
</http-interface> -->
</management-interfaces>

3. Restart Domain controller and Host controller .Check console wether the cert is browsing or not and also check wether Host is able to connect to Domain .

Sunday, February 28, 2021

AMQ9513: Maximum number of channels reached MQ

 

If we get this error means max channels are reached . To see total channels used on the QMGR use below command

DISPLAY CHSTATUS(*) CURSHCNV

This command will give all the running channels to get the exact further modify the command like below

echo " dis chs(*) CURSHCNV " |runmqsc QM1 |grep "CHANNEL(" |wc -l

check if the channel max instances reached or Max channels reached and act accordingly .MAXINST can be found on the channel definition 

Unix the qm.ini is located at: /var/mqm/qmgrs/<QMGRNAME>/qm.ini

The queue manager attribute MaxChannels is set too low for the required number of client connections (default is 100) . See if MaxChannels are sufficient for the application if not increased based on the Load . change to this qm.ini require QMGR restart .

If you hit MaxChannels with a client application, you should be returned MQRC_CHANNEL_NOT_AVAILABLE (2537)/MQRC_MAX_CONNS_LIMIT_REACHED (2025)accompanied by AMQERR01.LOG message: AMQ9513: Maximum number of channels reached. There can also be limits on specific SVRCONN channels using MAXINST and MAXINSTC which will cause the same MQRC and error message.

AMQ9513: Maximum number of channels reached MQ

To see this take a look at the DISPLAY CHSTATUS command. There is a status attribute CURSHCNV that shows the number currently being shared over that one SVRCONN instance.

To see the local connections use command:-
DISPLAY CONN(*) ALL WHERE(CHANNEL EQ ' ')
To see the remote connections use command:-
DISPLAY CONN(*) ALL WHERE(CHANNEL NE ' ')

How to calculate the values that we need to set MAXINST,MaxChannels

Max Channel CALCULATIONS for QMGR:
 Number of sending MCA channels:   #‌send    +
 Number of receiving MCA channels: #‌recv    +
 Total of all MAXINST (if used)             #‌clients +  ( or the value of echo " dis chs(*) CURSHCNV " |runmqsc QM1 |grep "CHANNEL(" |wc -l)

  -------------------------------------------------------------

 Set Max Channels to this:                      #‌total
calculating Channel instances specific for each channel

echo " dis chs(CL.SG) CURSHCNV" |runmqsc QM1 | grep "CHANNEL(" |wc -l
echo " dis chs(CL.MY) CURSHCNV" |runmqsc QM1 | grep "CHANNEL(" |wc -l
echo " dis chs(CL.IN) CURSHCNV" |runmqsc QM1 | grep "CHANNEL(" |wc -l
echo " dis chs(SYSTEM.ADMIN.SVRCONN) CURSHCNV" |runmqsc QM1 | grep "CHANNEL(" |wc -l
echo " dis chs(SYSTEM.AUTO.SVRCONN) CURSHCNV" |runmqsc QM1 | grep "CHANNEL(" |wc -l
echo " dis chs(SYSTEM.DEF.SVRCONN) CURSHCNV" |runmqsc QM1 | grep "CHANNEL(" |wc -l
The sum of the above equal to the following command
echo " dis chs(*) CURSHCNV " |runmqsc QM1 |grep "CHANNEL(" |wc -l

When we get the error based on the values we need to modify QMGR qm.ini MaxChannels or MAXINST on the channel to solve the issue .

Monday, February 15, 2021

Apache httpd virtualhost sample snippet

Refer below sample apache httpd virtualhost configuration  


Listen WEBHOST1A:4443
<VirtualHost *:4443>
ServerName x01ib01.abc.com
DocumentRoot "/web/apache/WEB1A/var/www/html"

SSLEngine On
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off
SSLProxyEngine on
ProxyRequests Off
ProxyPreserveHost On
#Only TLSv1.2 enabled with below tag
SSLProtocol -all +TLSv1.2
TraceEnable off
SSLHonorCipherOrder On
SSLCompression Off
SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH
#Certificate configured for the site with below files

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

RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^(DELETE|OPTIONS)
RewriteRule .* - [F]

#We can configure ProxyPass & ProxyPassReverse here to send request back to App Server

</VirtualHost>

How to list Ciphers and protocols from IP and PORT

To get the list of ciphers and protocols for any JAVA port running on the server we can use below simple script .

Replace Server and port on the below snippet and run the for loop .It will list all the Protocols and ciphers supported by the port on the server 
We can use the same snippet to get the ciphers and protocols from from remote server also 
This can only run from Linux/Aix/Sol server

for v in ssl2 ssl3 tls1 tls1_1 tls1_2 tlsv1_3; do
   for c in $(openssl ciphers 'ALL:eNULL' | tr ':' ' '); do
     openssl s_client -connect SERVERIP:PORT -cipher $c -$v < /dev/null > /dev/null 2>&1 && echo $v:\t$c
  done
done

For example i have Linux server where 631 port is up and listening .
Now i want to get the list of Protocols and Cihpers that this server and port supporting .
Replace the IP and port on the given ssl snippet and run on the server . Refer below output.
[wlsuser@localhost tmp]$ netstat -tnpl |grep 631
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN -
tcp6 0 0 ::1:631 :::* LISTEN -
[wlsuser@localhost tmp]$ for v in ssl2 ssl3 tls1 tls1_1 tls1_2;

do for c in $(openssl ciphers 'ALL:eNULL' | tr ':' ' '); do
 openssl s_client -connect 127.0.0.1:631 -cipher $c -$v < /dev/null > /dev/null 2>&1 && echo $v:\t$c
done
done


tls1:tAES256-SHA
tls1:tCAMELLIA256-SHA
tls1:tAES128-SHA
tls1:tSEED-SHA
tls1:tCAMELLIA128-SHA
tls1:tDES-CBC3-SHA
tls1:tIDEA-CBC-SHA
tls1_1:tAES256-SHA
tls1_1:tCAMELLIA256-SHA
tls1_1:tAES128-SHA
tls1_1:tSEED-SHA
tls1_1:tCAMELLIA128-SHA
tls1_1:tDES-CBC3-SHA
tls1_1:tIDEA-CBC-SHA
tls1_2:tAES256-GCM-SHA384
tls1_2:tAES256-SHA256
tls1_2:tAES256-SHA
tls1_2:tCAMELLIA256-SHA
tls1_2:tAES128-GCM-SHA256
tls1_2:tAES128-SHA256
tls1_2:tAES128-SHA
tls1_2:tSEED-SHA
tls1_2:tCAMELLIA128-SHA
tls1_2:tDES-CBC3-SHA
tls1_2:tIDEA-CBC-SHA
[wlsuser@localhost tmp]$

Monday, February 1, 2021

Apache Security Headers [ PEN TEST Fixes ]

 Most of the current Application has a web server as first origin of the request .It is very important to secure the site using headers to prevent the site from being compromised with middleman .

We would like to give some of the important Http headers that can be configured in web server to secure the system

<IfModule mod_headers.c>
	Header always edit Set-Cookie "(?i)^((?:(?!;\s?HttpOnly).)+)$" "$1; HttpOnly"
	Header always edit Set-Cookie "(?i)^((?:(?!;\s?secure).)+)$" "$1; secure"
        Header always append X-Frame-Options: SAMEORIGIN
     	Header set Server "my web server"
	Header set X-XSS-Protection: "1; mode=block"
	Header set Strict-Transport-Security "max-age=63072000; includeSubDomains"
        Header set X-Content-Type-Options nosniff
        Header set Cache-Control "no-cache, no-store"
        Header set Pragma "no-cache"
        Header set Expires 0
        Header set Access-Control-Allow-Origin "*"
        Header always unset "X-Powered-By"
        Header unset "X-Powered-By"
        RequestHeader unset Host
        RequestHeader append Host app.com
	RequestHeader unset Host
        Header set Content-Security-Policy "default-src 'none'; script-src 'self'; style-src 'self';"
</IfModule>

Tuesday, January 19, 2021

Stopping JBOSS using kill (forcefully )

 We can either stop the JBoSS Server or kill the process using kill -9 . If there are multiple JVM process running on the server then it is better to have a script that will do at one shot .

refer below sample script that help to kill all the jboss process running on with path jboss-eap-6.4/ . For you environment identify the unique keyword to get the individual process then pass to kill -9 command as given below .

#!/bin/bash
# For different version update keyword correctly go get jboss process like jboss-eap-7.x

procCount=`ps -ef |grep "jboss-eap-6.4/" |grep -v grep |wc -l`
if [ $procCount -gt 0 ] ; then
ps -ef |grep "jboss-eap-6.4/" |grep -v grep | awk '{ print $2 }' |xargs kill -9 2>&1
if [ $? -eq 0 ] ; then
echo -e " JBOSS Master Stopped successfully"
else
echo -e " Unable to stop ..please check"
fi
else
echo "Jboss is not running .."
fi

Tuesday, January 5, 2021

Create MQ Queue Manager ,Local Queue and Test


In this we will see how to create Queue Manager (QMGR) ,Local Queue and test put , get operation using mq sample programs .

  • A queue manager is a system program that provides queuing services to applications.
  • It provides an application programming interface (MQI) so that programs can put messages on, and get messages from, queues.
  • It is the first WebSphere MQ object to be created after installation.
    It will control all the other MQ objects (queues, process, listeners, channels etc) with in it.
  • A program/application must have a connection to a queue manager before it can use the services of that queue manager.
  • Typically, it’s suggested to create only one queue manager per machine, but one can create others depending on the resources available on the system.
  • Each queue manager has a name that should be unique within a network of queue managers exchanging messages with each other.

1.Create QMGR with the name IBMMQ.QM1. Run below command on the terminal

crtmqm IBMMQ.QM1

2.Display the QMGR status .Run below command .

dspmq

3.Start QMGR .Run below command.

strmqm IBMMQ.QM1

4.Verify the QMGR status with dspmq then Connect to QMGR to define MQ objects. We will create Local Queue here .

runmqsc IBMMQ.QM1
define QLOCAL(TESTQ)

END and Enter to come out of runmqsc terminal

5.Use MQ sample program's amqsput and amqsget from /opt/mqm/samp/bin to put and get message from the Local queue .

/opt/mqm/samp/bin/amqsput TESTQ IBMMQ.QM1
/opt/mqm/samp/bin/amqsget TESTQ IBMMQ.QM1

6.Verify the MQ QMGR data location and log location .

QMGR Data Path
/opt/mqm/qmgrs/IBMMQ.QM1/
QMGR Log Path
/opt/mqm/qmgrs/IBMMQ.QM1/errors/
[mqm@ip-172-31-14-154 ~]$ cd /var/mqm/qmgrs/
[mqm@ip-172-31-14-154 qmgrs]$ ls -rlt
total 4
drwxrwsr-x.  2 mqm mqm    6 Dec 29 15:56  @SYSTEM
drwxrwsr-x. 25 mqm mqm 4096 Dec 30 01:02 'IBMMQ!QM1'
[mqm@ip-172-31-14-154 qmgrs]$ cd IBMMQ\!QM1/
[mqm@ip-172-31-14-154 IBMMQ!QM1]$ ls -lrt
total 32
drwxrws---. 2 mqm mqm    6 Dec 30 01:01 ssl
drwxrwsr-x. 2 mqm mqm    6 Dec 30 01:01 plugcomp
drwxrwsr-x. 2 mqm mqm    6 Dec 30 01:01 userdata
drwxrws---. 2 mqm mqm    6 Dec 30 01:01 scratch
drwxrws---. 3 mqm mqm   19 Dec 30 01:01 @qmpersist
drwxrws---. 3 mqm mqm   19 Dec 30 01:01 @qmgr
drwxrwsr-x. 3 mqm mqm   19 Dec 30 01:01 @app
-rw-rw----. 1 mqm mqm 1552 Dec 30 01:01 qm.ini
-rw-rw----. 1 mqm mqm  732 Dec 30 01:01 mqat.ini
drwxrws---. 2 mqm mqm   40 Dec 30 01:01 qmanager
drwxrws---. 2 mqm mqm   36 Dec 30 01:01 procdef
drwxrws---. 2 mqm mqm   33 Dec 30 01:01 clntconn
drwxrwsr-x. 3 mqm mqm   59 Dec 30 01:01 @ipcc
drwxrws---. 2 mqm mqm   41 Dec 30 01:01 listener
drwxrws---. 2 mqm mqm  114 Dec 30 01:01 namelist
drwxrws---. 2 mqm mqm   47 Dec 30 01:01 comminfo
drwxrws---. 2 mqm mqm  159 Dec 30 01:01 authinfo
drwxrws---. 2 mqm mqm   63 Dec 30 01:01 services
drwxrws---. 2 mqm mqm  268 Dec 30 01:01 channel
drwxrws---. 2 mqm mqm  193 Dec 30 01:01 topic
drwxrws---. 2 mqm mqm   25 Dec 30 01:02 autocfg
-rw-rw-r--. 1 mqm mqm   83 Dec 30 01:02 master
-rw-rw-r--. 1 mqm mqm   83 Dec 30 01:02 active
-rw-rw----. 1 mqm mqm   56 Dec 30 01:02 amqalchk.fil
-rw-rw----. 1 mqm mqm   18 Dec 30 01:02 blockaddr.ini
-rw-rw-r--. 1 mqm mqm  766 Dec 30 01:02 qmstatus.ini
-rw-rw-r--. 1 mqm mqm    0 Dec 30 01:02 amqp.stdout
-rw-rw-r--. 1 mqm mqm    0 Dec 30 01:02 amqp.stderr
drwxrws---. 2 mqm mqm   18 Dec 30 01:02 startprm
drwxrws---. 2 mqm mqm   84 Dec 30 01:02 errors
drwxrwx---. 2 mqm mqm  167 Dec 30 01:02 amqp
drwxrws---. 2 mqm mqm 4096 Dec 30 01:04 queues
[mqm@ip-172-31-14-154 IBMMQ!QM1]$ cd errors/
[mqm@ip-172-31-14-154 errors]$ ls -lrt
total 52
-rw-rw----. 1 mqm mqm     0 Dec 30 01:01 AMQERR03.LOG
-rw-rw----. 1 mqm mqm     0 Dec 30 01:01 AMQERR02.LOG
-rw-rw----. 1 mqm mqm 48237 Dec 30 01:02 AMQERR01.LOG
-rw-rw----. 1 mqm mqm   733 Dec 30 01:02 amqp_0.log
[mqm@ip-172-31-14-154 errors]$ pwd
/var/mqm/qmgrs/IBMMQ!QM1/errors
[mqm@ip-172-31-14-154 errors]$ 

We need to verify AMQERR01.LOG to check any error related to QMGR .

 

Monday, January 4, 2021

How to connect to Linux ec2 instance created in AWS

 

We have just created ec2 Linux instance with AWS free tire . during the ec2 instance provision i have generate new key pair and downloaded the key awskeypar.pem .

Now download putty.exe and puttygen.exe (for extracting private key) as shown on the below screens .

We will login to the AWS console AWS Console and start the instance if not running then take the public IP or Public DNS to connect from putty .

Login as root user .Enter id/mail id and password

Click on ec2 --> Instances

Click on the Instance ID

Copy Public DNS .We will login to putty with this public ip or DNS as shown in the below .

We have both putty.exe and puttygen.exe already downloaded . Let us see how we can connect to the linux terminal using putty.

Firstly get the download key pair from AWS during the ec2 instance creation to download private key .

Click on Load and select the PEM file downloaded tat will extract private key then save it to use in putty .select the ppk file generated here in the below putty.

Click on Yes

Now we have successfully logged in the server .ec2-user is a super user use sudo if we get any permission issue while running the command which require root privilege .

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

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...