The bounce script will take the input as WebLogic instance name.
Then the script should do search for the corresponding Java Process id of given WebLogic instance.
That Java Process ID can be used for finding:
1. Thread dump
2. Domain directory
3. Shutdown instance (kill the process)
Above 1, 3 are commonly used commands but 2nd one required when situation like this, on the same machine if there exists multiple WebLogic domain instances then how to find the WebLogic instance started from? Here, I need to find the origin directory of startManagedWebLogic.sh used which gives the WebLogic domain directory. How to resolve this? The solution is pwdx command in Solaris gives you this directory path by passing process id to it.
This solution gives me to start the WebLogic instance which is residing in irrespective WebLogic domain. That's all I need to make the bounce script.
The bounce script goes like this
#========================================================== # This script you can keep in common accessing PATH # such as in $JAVA_HOME/bin # For WebLogic instance take ThreadDump, Shutdown, and Start #=========================================================== flag=0 if [ "$1" = "" ]; then echo "Usage : $0 [instance]" exit else instance="$1" pid=`jps -v|grep $instance|awk '{print $1}'` echo 'pid ' $pid domainPath=` pwdx $pid |awk '{print $2}'` kill -3 $pid sleep 3 kill -3 $pid sleep 3 kill -3 $pid #Now shutting down the instance here kill -9 $pid #verifying the instance is existance if not wait while : do jps -v |grep $instance if [ $? -eq 1 ]; then echo 'kill success' flag=`expr $flag + 1` break; else echo 'kill failed... sleeping 1 sec' sleep 1 fi done #Once kill is success then you can proceed for Start it # Here you can call startManagedWebLogic.sh script if [ $flag -gt 0 ]; then . ${domainPath}/startinstance.sh $instance fi fi
Recently one of my blog ->pingbox user asked me about pwdx command, does it works on HP-UX? I thought I should update this post with proper references.
There is compatibility list given for pwdx command:
pwdx compatibility
Alternate solution is cwd for Linux.
Please suggest your ideas, Keep commenting
Good Script
ReplyDeleteIt Helps me a lot for My Jboss server Automation scripts.
I really thank full for you for sharing Your Knowledge and to think us about these technologies!
:)
Can we use this script to restart an instance which is tied to a nodemanager. Doesn't nodemanager keep track of the instance and try to restart it as soon as the script kills it?
ReplyDeleteThis script is not for who have NodeManager in their environment. If you have NodeManager you can use WLST to bounce the instance.
ReplyDeletekill -3 doesnot work on GNU/Linux.. any ideas?
ReplyDeleteThat command works in GNU/Linux also... if not try kill -QUIT . But the output will be generated in the standard out. If the server is running in background you can check the redirecting log file have the threadDump. other option is jstack .
ReplyDeleteI am facing a problem. Once the script reaches the line kill -9 $pid
ReplyDeleteit kills the server process and stops executing further. What could I be missing? I have tried entering an echo statement right below the kill -9 $pid to see if it goes beyond that point but no luck.
I am using x86_64 x86_64 x86_64 GNU/Linux
Did you check pwdx working in ur Linux machine? if not use cwd.
ReplyDeletei want to understanded about thread dump & heep dump concet in weblogic 11g (10.3.3)
ReplyDeletehi this is das i want the some regular use commands for weblogic in linux
ReplyDeleteHow Can you kill JVM processes? How about running, and not finished threads? There are other ways to stop Admin Server and other managed servers...
ReplyDeleteMonitor: WebSolutionsWeblogicProd:S&P-PROD-NJ09- Web Solutions-Webogic_ws_4-nj09mhf0459.edmz:22440-url-
ReplyDeleteGroup: Web Solutions-Weblogic-Prod
Status: timed out reading
Hi I am getting above error everyday or two.
May i know the issue here for timed out.
Not able to find anything in logs.
Jus servlet exception and javax.servlet.jsp.JspException: Broken pipe
Can you share a script when this issue comes it should auotmatically restart that instance.
Naveen N
navin.wls6@gmail.com
Monitor: WebSolutionsWeblogicProd:S&P-PROD-NJ09- Web Solutions-Webogic_ws_4-nj09mhf0459.edmz:22440-url-
ReplyDeleteGroup: Web Solutions-Weblogic-Prod
Status: timed out reading
Hi I am getting above error everyday or two.
May i know the issue here for timed out.
Not able to find anything in logs.
Jus servlet exception and javax.servlet.jsp.JspException: Broken pipe
Can you share a script when this issue comes it should auotmatically restart that instance.
Naveen N
navin.wls6@gmail.com