UNIX for Dummies Questions & Answers

This forum is closed for new posts. Please post beginner questions to learn unix and learn linux in this forum UNIX for Beginners Questions & Answers

Script to force Oracle database shutdown when shutdown immediate does not work

 
 
Thread Tools Search this Thread Display Modes
    #1  
Old 03-09-2010
aixhp aixhp is offline
Registered User
 
Join Date: Aug 2008
Last Activity: 11 March 2010, 1:39 PM EST
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Script to force Oracle database shutdown when shutdown immediate does not work

I have Oracle 9i R2 on AIX 5.2. My Database is running in shared server mode (MTS).

Sometimes when I shutdown the database it shutsdown cleanly in 4-5 mints and sometimes it takes good 15-20 minutes and then I get some ora-600 errors and only way to shutdown is by opening another session and doing the shutdown abort.

Is there a way/workaround so I can do this with some script like if my database is not shutdown properly in 15-20 minutes since I issue "shutdown immediate" command it kicks of shutdown abort command? Something like this

**************************************************
"checks for smon/PMON if database still up then connects and issues shutdown abort"
**************************************************

Thanks

Last edited by aixhp; 03-10-2010 at 03:11 PM..
Sponsored Links
    #2  
Old 03-10-2010
Scott Scott is offline Forum Staff  
Administrator
 
Join Date: Jun 2009
Last Activity: 8 July 2018, 4:41 PM EDT
Posts: 9,062
Thanks: 402
Thanked 1,279 Times in 1,082 Posts
I would cite as the main reason for not receiving a response to your question, up to now, the poor subject title you used. It in no way convey's the nature of your question.

Having said that(!) here's my lame attempt at a solution:

Code:
$ cat ShutdownDB
#!/bin/ksh
WAIT_MINS=15

ShutdownDB() {
echo "Shutdown database [$ORACLE_SID]..."
  sqlplus / as sysdba << ! > /dev/null
    shutdown immediate;
!
}

ForceShutdownDB() {
  echo "Forcing DB shutdown, please wait..."
  sqlplus / as sysdba << ! > /dev/null
    shutdown abort;
    startup restrict;
    shutdown immediate;
!
}

ShutdownDB &
sleep 10

X=0
while true; do
  jobs > /dev/null
  if [ $(jobs | wc -l) -eq 0 ]; then
    break
  else
    [ $X -le $WAIT_MINS ] && echo "Waiting $((WAIT_MINS -$X)) minute(s)..." && X=$((X + 1)) && sleep 60 && continue
  fi
  kill %1
  sleep 3
  ForceShutdownDB
  break
done

echo "Database stopped."

$ ./ShutdownDB
Shutdown database [DB1]...
Waiting 15 minute(s)...
Waiting 14 minute(s)...
...
...
Waiting 1 minute(s)...
Waiting 0 minute(s)...
Forcing DB shutdown, please wait...
Database stopped.

HTH
Sponsored Links
    #3  
Old 03-10-2010
aixhp aixhp is offline
Registered User
 
Join Date: Aug 2008
Last Activity: 11 March 2010, 1:39 PM EST
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks scottn for sharing your Script. Sorry for the poor title. I will try to do better next time.
    #4  
Old 03-10-2010
Scott Scott is offline Forum Staff  
Administrator
 
Join Date: Jun 2009
Last Activity: 8 July 2018, 4:41 PM EDT
Posts: 9,062
Thanks: 402
Thanked 1,279 Times in 1,082 Posts
No problems, I've renamed the thread
Sponsored Links
    #5  
Old 03-10-2010
methyl methyl is offline
Registered User
 
Join Date: Mar 2008
Last Activity: 8 June 2016, 9:58 PM EDT
Posts: 6,402
Thanks: 288
Thanked 676 Times in 645 Posts
Personally I would modify the Oracle provided script "dbshut" to issue "shutdown immediate" rather than just "shutdown". It is ruthless in disconnecting sessions but lets you get on with the next task such as a database backup. This botch "technique" has worked well for Oracle 7,8,9 daily for many years.

Last edited by methyl; 03-10-2010 at 07:15 PM..
Sponsored Links
    #6  
Old 03-10-2010
Scott Scott is offline Forum Staff  
Administrator
 
Join Date: Jun 2009
Last Activity: 8 July 2018, 4:41 PM EDT
Posts: 9,062
Thanks: 402
Thanked 1,279 Times in 1,082 Posts
Quote:
Originally Posted by methyl View Post
Personally I would modify the Oracle provided script "dbshut" to issue "shutdown immediate" rather than just "shutdown". It is ruthless in disconnecting sessions but lets you get on with the next task such as a database backup. This botch "technique" has worked well for Oracle 7,8,9 .
Here's what dbshut says:

Quote:
# This script is used to shutdown ORACLE from /etc/rc(.local).
# It should ONLY be executed as part of the system boot procedure.
I didn't see anything about shutting down or rebooting a server in the question.

Besides, the OP was asking about when shutdown immediate takes too long. The simple solution would be to wait the hour for the ORA-01013 and take that as a no.

I would investigate the 0600 though.
Sponsored Links
    #7  
Old 03-11-2010
methyl methyl is offline
Registered User
 
Join Date: Mar 2008
Last Activity: 8 June 2016, 9:58 PM EDT
Posts: 6,402
Thanks: 288
Thanked 676 Times in 645 Posts
Hi scottn

I missed the point that the O/P was only shutting down the instance not the whole computer. Therefore probably not using Oracle supplied scripts.

It think the O/P original issue is caused by issuing "shutdown" rather than "shutdown immediate" ... then having to issue "shutdown abort" if it takes too long.

Many admins (myself included) write parodies of the contents dbshut and dbstart to stop/start individual databases at will.
Sponsored Links
 

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Battery Empty -> force shutdown ccc BSD 3 08-06-2009 03:05 PM
Capturing Oracle Shutdown error ganapati UNIX for Advanced & Expert Users 15 04-19-2007 08:26 AM
Shutdown script kingsto88 HP-UX 0 03-20-2007 08:43 PM
A script for shutdown kelu UNIX for Dummies Questions & Answers 12 08-23-2006 09:09 PM
Shutdown script alpha_manic UNIX for Advanced & Expert Users 10 09-14-2005 04:14 PM



All times are GMT -4. The time now is 06:25 PM.

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.
×
UNIX.COM Login
Username:
Password:  
Show Password





Not a Forum Member?
Forgot Password?