There is one difficulty with console return after calling startWebLogic.sh and startManagedWebLogic.sh. Regarding to it I had to run it in background. If startup script runs in background it returns code which means successful completion of "&" operation. If you need to make sure services started correctly code you have two ways:
- do it in WLST
- try to catch "<Notice> <WebLogicServer> <BEA-000360> <Server started in RUNNING mode>
This script installed at development server. As it is not a production variant and have limited number of domains I do not have to spend much time WLST script coding (which is actually python). Lately if it would be necessary I will certainly do advanced script to automatically start/stop WLS domains. There are some simple samples.
#!/bin/sh
# using of LOOPs is regarded to future improovements. May well you will
# have several Admin servers and Several Managed Servers. Just change
# the code to work with arrays.
# The only problem is to check successfull start of Java instances which is in background.
LOG_ADM="/tmp/ora_wls-admin"
LOG_MNGR="/tmp/ora_wls-nmgr"
MW_HOME="/u01/oracle/mw"
WLS_DOMAINS_ADM="base_domain"
WLS_DOMAINS_MNGD="osb_server1 Server-0"
#for compatibility with sh
ADNAME="basedomain"
MDNAME="osbserver1"
# write svn information to a header
version() {
Log " category System scripts"
Log " author V.Bychkov"
Log " changedby $Author: bes $"
Log " version SVN: $Id: oracle.wls-middleware 1002 2011-07-04 04:26:20Z bes $"
Log " revision SVN: $Revision: 1002 $"
install_init() {
_N="$(dirname $0)/$(basename $0)"
rm -f /etc/rc3.d/S99oracle-wls-middleware
rm -f /etc/rc0.d/S99oracle-wls-middleware
ln -s $_N /etc/rc3.d/S99oracle-wls-middleware
ln -s $_N /etc/rc0.d/S99oracle-wls-middleware
}
start() {
_R=0
# admin
echo "Starting Oracle WL Admin Server."
# for ADNAME in $WLSDOMAINS_ADM; do
return $_R
}
stop() {
_R=0
# admin
echo "Stopping Oracle WL Admin Server."
# for ADNAME in $WLSDOMAINS_ADM; do
return $_R
}
case "$1" in
start)
echo "Return code of this script means that all start/stop Oracle scripts started successfully in background. See detailed information in log files in $LOG_ADM and $LOG_MNGR."
exit $RETVAL
#!/bin/sh
# using of LOOPs is regarded to future improovements. May well you will
# have several Admin servers and Several Managed Servers. Just change
# the code to work with arrays.
# The only problem is to check successfull start of Java instances which is in background.
LOG_ADM="/tmp/ora_wls-admin"
LOG_MNGR="/tmp/ora_wls-nmgr"
MW_HOME="/u01/oracle/mw"
WLS_DOMAINS_ADM="base_domain"
WLS_DOMAINS_MNGD="osb_server1 Server-0"
#for compatibility with sh
ADNAME="basedomain"
MDNAME="osbserver1"
# write svn information to a header
version() {
Log " category System scripts"
Log " author V.Bychkov"
Log " changedby $Author: bes $"
Log " version SVN: $Id: oracle.wls-middleware 1002 2011-07-04 04:26:20Z bes $"
Log " revision SVN: $Revision: 1002 $"
Log " link $HeadURL: file:///opt/svn/projects/scripts/oracle/init.d/oracle.wls-middleware $" Log "# date $Date: 2011-07-04 14:26:20 +1000 (Mon, 04 Jul 2011) $"}
install_init() {
_N="$(dirname $0)/$(basename $0)"
rm -f /etc/rc3.d/S99oracle-wls-middleware
rm -f /etc/rc0.d/S99oracle-wls-middleware
ln -s $_N /etc/rc3.d/S99oracle-wls-middleware
ln -s $_N /etc/rc0.d/S99oracle-wls-middleware
}
start() {
_R=0
# admin
echo "Starting Oracle WL Admin Server."
# for ADNAME in $WLSDOMAINS_ADM; do
su - oracle -c "wls; nohup ${MW_HOME}/user_projects/domains/${ADNAME}/bin/startWebLogic.sh >> ${LOGADM}.out 2>> ${LOG_ADM}.err < /dev/null&" _R=$? [ $_R -ne 0 ] && echo "stopWebLogic.sh failed." && exit $_R echo "sleep 100..." sleep 100 # domains echo "Starting Oracle WLS Node Managers." # for MDNAME in $WLSDOMAINS_MNGD; do su - oracle -c "wls; nohup ${MW_HOME}/user_projects/domains/${_ADNAME}/bin/startManagedWebLogic.sh ${MDNAME}>>${LOGMNGR}.out 2>>${LOG_MNGR}.err < /dev/null&" _R=$? [ $_R -ne 0 ] && echo "startManagedWebLogic.sh ${_MDNAME} failed." && exit $_R echo "sleep 100..." sleep 100 # done# done
return $_R
}
stop() {
_R=0
# admin
echo "Stopping Oracle WL Admin Server."
# for ADNAME in $WLSDOMAINS_ADM; do
# domains echo "Stopping Oracle WLS Node Managers." # for MDNAME in $WLSDOMAINS_MNGD; do su - oracle -c "wls; nohup ${MW_HOME}/user_projects/domains/${_ADNAME}/bin/stopManagedWebLogic.sh ${MDNAME}>>${LOGMNGR}.out 2>>${LOG_MNGR}.err < /dev/null&" _R=$? [ $_R -ne 0 ] && echo "stopManagedWebLogic.sh ${_MDNAME} failed." && exit $_R echo "sleep 100..." sleep 100 # done su - oracle -c "wls; nohup ${MW_HOME}/user_projects/domains/${ADNAME}/bin/stopWebLogic.sh >> ${LOGADM}.out 2>> ${LOG_ADM}.err < /dev/null&" _R=$? [ $_R -ne 0 ] && echo "stopWebLogic.sh ${_ADNAME} failed." && exit $_R# done
return $_R
}
case "$1" in
start)
start RETVAL=$? ;; stop) stop RETVAL=$? ;; restart|reload) stop RETVAL=$? [ $RETVAL -ne 0 ] && echo "Error restarting. Can't fork stop script. Sorry..." && exit $RETVAL start RETVAL=$? ;; install-init) install-init ;; *) echo $"Usage: $0 {start|stop|restart|reload|version|install_init}" exit 1esac
echo "Return code of this script means that all start/stop Oracle scripts started successfully in background. See detailed information in log files in $LOG_ADM and $LOG_MNGR."
exit $RETVAL
No comments:
Post a Comment