Sunday, December 6, 2009

Using adstrtal.sh and adstpall.sh to start and stop MWA

For EBS, there are scripts to start and stop all servers except MWA servers. It would be nice If we can use adstrtal.sh and adstpall.sh in $COMMON_TOP/admin/scripts/$CONTEXT_NAME to start and stop MWA servers. Normally, adstrtal.sh and adstpall.sh control web, forms, concurrent manager, report server, and discoverer servers. For MWA, we have to use mwactl.sh in $MWA_TOP/bin.

mwactl.sh start
mwactl.sh -login sysadmin/sysadminpw stop

Per Note 731320: How to start/stop MWA services using control scripts adstrtal.sh/adstpall.sh, we need to apply TXK patch 5985992 (latest as of 12/2/2009: p7164202: 11i rapidclone consolidated fixes may/2009) and MWA patch 5712178, update s_mwastatus in context file to “enabled”, run autocfg. There is a new script for MWA created in $COMMON_TOP/admin/scripts/$CONTEXT_NAME:

mwactlwrpr.sh

adstrtal.sh can start all services including MWA but adstpall.sh could stop all services except MWA as mwactlwrpr.sh still needs sysadmin password.

mwactlwrpr.sh start|stop userid/password.

Passing apps/appspw for starting MWA is fine. However, for stoping MWA, we have to use sysadmin:

mwactlwrpr.sh stop sysadmin/sysadminpw

Created a SR to ask Oracle Support for help. Oracle asked me to apply patch 8405261: 1OFF:7510101:11.5.10.2:ADSTPALL>MWACTLWRPR.SH>DOES NOT STOP MWA LISTENERS WITH APPS USER. After applying this patch, I still could not shutdown mwa using adstpall.sh.

Per bug note: 7510101, there is a patch p7510101_11i_GENERIC.zip to fix the problem. This patch is not longer available. It appears it got replaced by p8405261_11i_GENERIC.zip which I have applied.

My SR is still open and Oracle is working on this issue.

Our issue is due to the $TWO_TASK setting in dbc file for the RAC environment. After appling patch 9535311: TXK autoconfig and templates rollup patch U and patch 9395815: cannot stop mwa server using mwactlwrpr.sh and mwactl.sh due to two_task, the issue has been resolved.

For shared appltop environment with two web nodes, need to modify the template $MWA_TOP/admin/template/mwactlwrpr.sh and add sub dir $CONTEXT_NAME before mwa.cfg and add –java_config after mwactl.sh to point to context sensitive mwa.cfg. Then running adautocfg to populate the start and stop scripts. See MWA Troubleshooting Tips for Release 11i [ID 269991.1], Section 12 How to use MWA in a Shared APPL_TOP environment:

Do the following for starting a MWA Telnet Server :
---------------
mwactl -java_config "-Dmwa.cfg=[path to config file]" -mwatop [path to mwatop] start [port number]

In case you still could not stop MWA, then modify the template for mwactlwrpr.sh as:
#{ echo $USERPASS; } | nohup $top/$script_path/mwactl.sh stop_force $telnet_port >> /dev/null 2>&1 &
nohup $top/$script_path/mwactl.sh -login $USERPASS stop_force $telnet_port >> /dev/null 2>&1 &

Here is the customized template for mwactlwrpr.sh:

#!/bin/sh
###################################################################
# MWACommand line utility to start and start the telnet server through autoconfig
###################################################################
# Author kkesavar
###################################################################
# Command line utility to start and stop the telnet server
# Usage
# mwactlwrpr.sh start userid/pwd
# mwactlwrpr.sh stop userid/pwd
# $Header: mwactlwrpr.sh 115.0.11510.4 2008/11/24 12:29:02 pbonthu noship $

# %s_dummy%
# This is to override the File.Gen.4 which requires a placeholder variable

if [ $# -ne 2 ];
then
printf "\nmwactlwrpr: Program has wrong number of arguments\n"
printf "Usage: mwactlwrpr start userid/pwd\n"
printf "Usage: mwactlwrpr stop userid/pwd\n"
printf "Usage: mwactlwrpr start -nopromptmsg\n"
printf "Usage: mwactlwrpr stop -nopromptmsg\n"
exit 1
fi

if [ -z "${MWA_TOP}" ]
then
printf "mwactlwrpr: Unable to determine MWA_TOP"
printf "mwactlwrpr: Please make sure that MWA_TOP is defined"
exit 1
fi

control_code=$1

if test "$2" = "-nopromptmsg";
then
read USERNAME
read PASSWORD
USERPASS=${USERNAME}/${PASSWORD}
else
userid_pwd=$2
fi

if test "$control_code" != "start" -a "$control_code" != "stop" ;
then
printf "\nFirst argument must be start or stop\n"
exit 1
fi

if [ -f $MWA_TOP/bin/mwactl.sh ]
then
top="$MWA_TOP"
script_path="bin"
config_path="secure"
else
if [ -z "${INST_TOP}" ]
then
printf "mwactlwrpr: Unable to determine INST_TOP"
printf "mwactlwrpr: Please make sure that INST_TOP is defined"
exit 1
else
top="$INST_TOP"
script_path="admin/scripts"
config_path="admin/install"
fi
fi

# Userid/pwd parameter in case of starting the service is not used anywhere
# It is here because it was requested by the ATG team for consistency purposes

if test "$control_code" = "start" ;
then

###### MWA Server - Start ######
# Check all the ports where the servers are going to be started
# If the ports are free i.e., no process is holding these ports, no issues
# Otherwise kill the processes which are holding these ports

printf "\nStarting MWA Wrapper script. Checking if all ports are free to start the servers and dispatcher...\n"
telnet_ports=`cat $top/$config_path/$CONTEXT_NAME/mwa.cfg | grep -i '^mwa.TelnetPortNumber=' | awk -F= '{ print $2}' | awk -F, '{
n = 1;
while ( $n != "") {
print $n; n=n+1; }
}'`

while [ ! -z "$telnet_ports" ]
do
telnet_port=`echo $telnet_ports | awk ' { FS = " " }; { print $1 }'`
lsof -i | grep $telnet_port > devnull
# Start the server on this port, only if it not used by any other process
if [ $? -eq 0 ]
then
echo "PortNumber:" $telnet_port " is not free to start the server. Please specify a different port in the configuration file (or) end the process using this port"
else
echo "Starting MWA Server on Port number:" $telnet_port
nohup $top/$script_path/mwactl.sh -java_config "-Dmwa.cfg=$top/$config_path/$CONTEXT_NAME/mwa.cfg" -mwatop $top start $telnet_port >> /dev/null 2>&1 &
exit_code=$?
fi

telnet_ports=`echo $telnet_ports | awk '{ FS = " "}; {
n = 2;
while ( $n != "") {
print $n; n=n+1; }
}'`
done

###### MWA Dispatcher - Start ######
# Check the ports where the dispatcher is going to be started
# If the ports are free i.e., no process is holding these ports, no issues
# Otherwise kill the processes which are holding these ports

dispatcher_port=`cat $top/$config_path/$CONTEXT_NAME/mwa.cfg | grep -i '^mwa.Dispatcher=' | awk -F: '{ print $2}' | awk -F- '{ print $1}'`

lsof -i | grep $dispatcher_port > devnull
# Start the dispatcher on this port, only if it not used by any other process
if [ $? -eq 0 ]
then
echo "PortNumber:" $dispatcher_port " is not free to start the dispatcher. Please specify a different port in the configuration file (or) end the process using this port"
else
echo "Starting MWA Dispatcher on Port number:" $dispatcher_port
$top/$script_path/mwactl.sh -java_config "-Dmwa.cfg=$top/$config_path/$CONTEXT_NAME/mwa.cfg" -mwatop $top start_dispatcher >> /dev/null 2>&1 &
exit_code=$?
fi
fi

if test "$control_code" = "stop" ;
then
printf "\nStopping MWA Servers and the dispatcher ....\n"

###### MWA Servers - Stop ######
#Stopping the servers on the ports in which they are started

telnet_ports=`cat $top/$config_path/$CONTEXT_NAME/mwa.cfg | grep -i '^mwa.TelnetPortNumber=' | awk -F= '{ print $2}' | awk -F, '{
n = 1;
while ( $n != "") {
print $n; n=n+1; }
}'`

while [ ! -z "$telnet_ports" ]
do
telnet_port=`echo $telnet_ports | awk ' { FS = " " }; { print $1 }'`

ps -ef | grep $telnet_port | grep Listener > devnull
# Execute the stop server command only if MWA Server is running on the specified port
if [ $? -eq 0 ]
then

if [ -z "$userid_pwd" ] ;
then
echo "Stopping MWA Server on Port number:" $telnet_port
#{ echo $USERPASS; } | nohup $top/$script_path/mwactl.sh stop_force $telnet_port >> /dev/null 2>&1 &
nohup $top/$script_path/mwactl.sh -login $USERPASS stop_force $telnet_port >> /dev/null 2>&1 &
else
echo "Stopping MWA Server on Port number:" $telnet_port
nohup $top/$script_path/mwactl.sh -login $userid_pwd stop_force $telnet_port >> /dev/null 2>&1 &
fi
fi
telnet_ports=`echo $telnet_ports | awk '{ FS = " "}; {
n = 2;
while ( $n != "") {
print $n; n=n+1; }
}'`

done

exit_code=$?

###### MWA Dispatcher - Stop ######

dispatcher_port=`cat $top/$config_path/$CONTEXT_NAME/mwa.cfg | grep -i '^mwa.Dispatcher=' | awk -F: '{ print $2}' | awk -F- '{ print $1}'`

ps -ef | grep MWADIS | grep -v grep > devnull
# Execute the stop dispatcher command only if MWA Dispatcher is running on the specified port
if [ $? -eq 0 ]
then
echo "Stopping MWA Dispatcher on Port number:" $dispatcher_port
$top/$script_path/mwactl.sh -java_config "-Dmwa.cfg=$top/$config_path/$CONTEXT_NAME/mwa.cfg" stop_dispatcher >> /dev/null 2>&1 &
exit_code=$?
fi
fi
exit $exit_code

No comments:

Post a Comment