This may not be of use to you, but at companies I worked at I always tried
to use a single utility on all platforms.  So we purchsed a simple unix
command processor software package for our nt clones.  Any would do but we
choose MKS toolkit.  That way all our unix scripts we invested time
developing ran fine with our newer NT servers.

A Unix Script to bounce all DB2 instances that also works fine under NT with
a korn shell processor:

#!/bin/ksh
. $HOME/.profile >/dev/null 2>&1
echo "Bounce DB2 Started at `date`"
ERRORS=false

#-------------------------------------------------------------------------#
#--  Get all instances on the machine.  Then loop through each instance --#
#-------------------------------------------------------------------------#
DB2ILIST="`db2ilist`"
for DB2INST in $DB2ILIST
do

   #----------------------------------------------------------------------#
   #--  Run the "db2profile" of the current instance to set the DB2xxx  --#
   #--  variables.  We could also do an "attach" from here instead.     --#
   #----------------------------------------------------------------------#
   . /db2_6000/$DB2INST/sqllib/db2profile >/dev/null 2>&1
   db2 attach to $DB2INST
   echo "\nStarting Instance $DB2INST

   #----------------------------------------------------------------------#
   #--  Kick all applications off the system.  Wait 20 seconds to ensure--#
   #--  that their gone.  Then stop and restart DB2.  If DB2 does not   --#
   #--  come back up again, page the oncall DBA.                        --#
   #----------------------------------------------------------------------#
   db2 force application all
   sleep 10
   db2stop
   if [ $? -ne 0 ]; then
      echo "Unable to stop db2"
      ERRORS=true
   fi
   db2start
   if [ $? -ne 0 ]; then
      echo "Unable to restart db2 after shutdown"
      ERRORS=true
      epage aixdba "`hostname` $DB2INST DB2 will not restart after bounce"
   fi

   #----------------------------------------------------------------------#
   #--  Issue the terminate command to prepare for the next instance    --#
   #----------------------------------------------------------------------#
   db2 terminate
done

echo "\nBounce ended at `date`"

#-------------------------------------------------------------------------#
#--  If there were any errors, send myself a note.                      --#
#-------------------------------------------------------------------------#
if [ "$ERRORS" = true ];then
   mail -s "`hostname` DB2 Bounce Errors" aixdba
fi




> -----Original Message-----
> From: Ronald Draper [SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, May 17, 2001 1:40 PM
> To:   [EMAIL PROTECTED]
> Subject:      DB2EUG: Shutting down a DB2 NT server cleaning
> 
> We are trying to develop a batch file that will cleanly stop all of the
> DB2 instances and services, so we can do maintenance on the box.  The
> servers have multiple instances on the box.  I can shut down the first
> instance with no problems but when I try attaching to the second instance
> it fails.  Any help would be greatly appreciated.  Here is a copy of the
> code in the batch file: 
> 
> ** Stopping the Cool-Gen services to DB2  ** 
> !NET STOP TE-AD-51-1; 
> !NET STOP TE-UF-51-1; 
> 
> !NET STOP TE-AD-51-2; 
> !NET STOP TE-UF-51-2; 
> 
> !NET STOP TE-AD-51-CRID1; 
> !NET STOP TE-UF-51-CRID1; 
> 
> ATTACH TO NRDEVL1 USER XXXXXXXX USING XXXXXXXXXXX; 
> 
> LIST APPLICATIONS FOR DATABASE NRDAIRD1 SHOW DETAIL; 
> LIST APPLICATIONS FOR DATABASE NRDHPPD1 SHOW DETAIL; 
> 
> DB2STOP FORCE; 
> 
> ATTACH TO NRTEST1 USER XXXXXX USING XXXXX; 
> 
> LIST APPLICATIONS FOR DATABASE NRDAIRT1 SHOW DETAIL; 
> 
> DB2STOP FORCE; 
> 
> DB2ADMIN STOP;
> 
> Here is what is returned 
> 
> 
> !NET STOP TE-AD-51-1 
> 
> !NET STOP TE-UF-51-1 
> 
> !NET STOP TE-AD-51-2 
> 
> !NET STOP TE-UF-51-2 
> 
> !NET STOP TE-AD-51-CRID1 
> 
> !NET STOP TE-UF-51-CRID1 
> 
> ATTACH TO NRTEST1 USER XXXXXXXX USING         
> 
>    Instance Attachment Information 
> 
>  Instance server        = DB2/NT 6.1.0 
>  Authorization ID       = XXXXXXXXXX 
>  Local instance alias   = NRTEST1 
> 
> 
> LIST APPLICATIONS FOR DATABASE NRDAIRT1 SHOW DETAIL 
> 
> Auth Id  Application Name     Appl.      Application Id
> Seq# Number of  Coordinating Coordinator     Status
> Status Change Time         DB Name  DB Path 
>                               Handle
> Agents     Node Number  pid/thread 
> -------- -------------------- ---------- ------------------------------
> ---- ---------- ------------ ---------------
> ------------------------------ -------------------------- --------
> -------------------- 
> XXXXXXX  NR34S201.exe         21         *LOCAL.NRTEST1.010516123102
> 0001 1          0            336             UOW Waiting
> Not Collected                       NRDAIRT1 F:\NRTEST1\NODE0000\SQL00001\
> 
> XXXXXXX  NR34S202.exe         22         *LOCAL.NRTEST1.010516123113
> 0001 1          0            344             UOW Waiting
> Not Collected                       NRDAIRT1 F:\NRTEST1\NODE0000\SQL00001\
> 
> 
> 
> DB2STOP FORCE 
> DB20000I  The DB2STOP command completed successfully. 
> 
> ATTACH TO NRDEVL1 USER XXXXXXX USING         
> SQL1032N  No start database manager command was issued.  SQLSTATE=57019 
> 
> LIST APPLICATIONS FOR DATABASE NRDAIRD1 SHOW DETAIL 
> SQL1032N  No start database manager command was issued.  SQLSTATE=57019 
> 
> LIST APPLICATIONS FOR DATABASE NRDHPPD1 SHOW DETAIL 
> SQL1032N  No start database manager command was issued.  SQLSTATE=57019 
> 
> DB2STOP FORCE 
> SQL1032N  No start database manager command was issued.  SQLSTATE=57019 
> 
> DB2ADMIN STOP 
> DB21034E  The command was processed as an SQL statement because it was not
> a 
> valid Command Line Processor command.  During SQL processing it returned: 
> SQL1024N  A database connection does not exist.  SQLSTATE=08003 
> 
> Any help would be greatly appreciated.  This script is being used by the
> network team to shut down the server, so DB2 doesn't have to do a crash
> recovery. 
> 
> Ron Draper
> Computer Information Technology Specialist I
> Missouri Department of Natural Resources
> MIS Program
> 526-1077
> 
> [EMAIL PROTECTED]
> Microsoft Certified Professional
> 

=====
To unsubscribe, send 'unsubscribe' to [EMAIL PROTECTED]
For other info (and scripts), see http://people.mn.mediaone.net/scottrmcleod

Reply via email to