
Advanced Oracle Weblogic start/stop script
The Oracle WebLogic 11g application server product line is the industry’s most comprehensive #Java platform for developing, deploying, and integrating enterprise applications. It provides the foundation for application grid, which is an architecture that enables enterprises to outperform their competitors while minimizing operational costs.
Some notes
This script may look unsecure (and it is)
Since password are store inside (admin server login: admin and password is admin), by doing so I can restart Oracle Weblogic in a cron job since stopping wont query the console for the login and password: feel free to remove these lines in blue
I always recommend to install web process in its own user group and use a dedicated user to mitigate any securities issues:
# groupadd weblogic
# useradd -g weblogic-c weblogicuser for weblogic’ -m weblogic
# su – weblogic
Install then weblogic in /home/weblogic
Respect the order of component for starting
- Start Weblogic Node Manager,
- Start WebLogic Admin server,
- Start all Managed Server in any order.
and stopping components
- Stop the Node Manager
- Stop all Managed WebLogic server
- Stop WebLogic
Names of the managed server
managed server names are in the script so add remove start and stop command for them
Logs files of start and stop operations
are written in 2 files, that use timestamp, see WLS_LOG_START and WLS_LOG_STOP
/etc/init.d/weblogic file
Create a new file as root in /etc/init.d/weblogic
# vi /etc/init.d/weblogic
and paste inside the following
#!/bin/sh
# description: webLogic adminServer and managedServer start script
## customized below to your likings
WLS_DOMAIN=mytestdomain
WLS_BASE=/home/weblogic/
WLS_HOME=${WLS_BASE}/bea/user_projects/domains/$WLS_DOMAIN
WLS_NODE_HOME=${WLS_BASE}/bea/wlserver_10.3/server/bin
WLS_OWNER=weblogic
WLS_ADMIN_PORT=7001
WLS_ADMIN_LOGIN=admin
WLS_ADMIN_PWD=admin
WLS_LOG_START=${WLS_BASE}/logs/start.`date ‘+%d%m%y’`.log
WLS_LOG_STOP=${WLS_BASE}/logs/stop.`date ‘+%d%m%y’`.log
WLS_MANAGED_SERVER1=dev
WLS_MANAGED_SERVER2=test
JAVA_OPTIONS=”${JAVA_OPTIONS} -Dweblogic.management.username=${WLS_ADMIN_LOGIN}”
JAVA_OPTIONS=”${JAVA_OPTIONS} -Dweblogic.management.password=${WLS_ADMIN_PWD}”
export JAVA_OPTIONSif [ ! -f $WLS_HOME/startWebLogic.sh ]
then
echo “WebLogic startup: cannot $WLS_HOME/startWebLogic.sh ”
exit
fistartWeblogic()
{
su – $WLS_OWNER -c “nohup $WLS_NODE_HOME/startNodeManager.sh > ${WLS_LOG_START} 2>&1 &”
sleep 10
su – $WLS_OWNER -c “nohup $WLS_HOME/startWebLogic.sh >> ${WLS_LOG_START} 2>&1 &”
sleep 10
su – $WLS_OWNER -c “nohup $WLS_HOME/bin/startManagedServer.sh >> ${WLS_LOG_START} 2>&1 &”
sleep 10
su – $WLS_OWNER -c “nohup $WLS_HOME/bin/startManagedServer.sh >> ${WLS_LOG_START} 2>&1 &”
return 0
}stopWeblogic()
{
su – $WLS_OWNER -c “nohup $WLS_NODE_HOME/stopNodeManager.sh > ${WLS_LOG_STOP} 2>&1 &”
sleep 10
su – $WLS_OWNER -c “nohup $WLS_HOME/bin/stopManagedWebLogic.sh $WLS_MANAGED_SERVER1 t3://localhost:$WLS_ADMIN_PORT ${WLS_ADMIN_LOGIN} ${WLS_ADMIN_PWD} >> ${WLS_LOG_STOP} 2>&1 &”
sleep 10
su – $WLS_OWNER -c “nohup $WLS_HOME/bin/stopManagedWebLogic.sh $WLS_MANAGED_SERVER2 t3://localhost:$WLS_ADMIN_PORT ${WLS_ADMIN_LOGIN} ${WLS_ADMIN_PWD} >> ${WLS_LOG_STOP} 2>&1 &”
sleep 10
su – $WLS_OWNER -c “nohup $WLS_HOME/bin/stopWebLogic.sh >> ${WLS_LOG_STOP} 2>&1 &”
return 0
}case “$1” in
‘start’)
startWeblogic
;;
‘stop’)
stopWeblogic
;;
‘restart’)
stopWeblogic
startWeblogic
;;
*)
echo “Usage: $0 start|stop|restart”
exit 1
;;
esac