Operating System - HP-UX
1827452 Members
3952 Online
109965 Solutions
New Discussion

Oracle Startup / Shutdown Script

 
SOLVED
Go to solution
Gus Mestousis
Frequent Advisor

Oracle Startup / Shutdown Script

Does anyone have a working startup and shutdown script for Oracle 8 on HP-UX 11.00
Basically what I need is a script that I can run prior to a backup kicking off, to bring all the databses down, and then after the backup job is completed to bring them back up. This isn' the normal startup/shutdown script that runs on boot in rc.

ANy help would be appreciated.

Thanks,
Gus
Sure, let me just drop everything and work on your problem.
14 REPLIES 14
Steven E. Protter
Exalted Contributor

Re: Oracle Startup / Shutdown Script

Sorry it took me so long to get to you.

Attached is a tar file.

It contains these three files...

rwxr-xr-x 0/3 1079 Dec 24 08:08 2002 /usr/contrib/bin/shut.oracle
rwxr-xr-x 0/3 159 Dec 24 08:08 2002 /usr/contrib/bin/shutsid.sh
rwxr-x--- 0/3 1246 Nov 6 08:39 2002 /sbin/init.d/oracle


These scripts are designed to read the /etc/oratab file and shut down any instances desginated as Y or active at machine startup.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Printaporn_1
Esteemed Contributor

Re: Oracle Startup / Shutdown Script

Hi Gus,

$ORACLE_HOME/bin/dbshut

it will shutdown instance base on information in /etc/oratab.
enjoy any little thing in my life
Indira Aramandla
Honored Contributor

Re: Oracle Startup / Shutdown Script

Hi,

If you have all the working database defined in your /etc/oratab file the just call
the script $ORACLE_HOME/bin/dbshut to shutdown all the databases before the backup and then after the backup call
the script
$ORACLE_HOME/bin/dbstart

Never give up, Keep Trying
Radhakrishnan Venkatara
Trusted Contributor

Re: Oracle Startup / Shutdown Script

well

we normally uses dbshut and dbstart scripts in bin directory inside $ORACLE_HOME

radhakrishnan
Negative thinking is a highest form of Intelligence
Andreas D. Skjervold
Honored Contributor

Re: Oracle Startup / Shutdown Script

Hi

Just want to add that it might be wise to edit the dbshut script to do a "shutdown immediate" instead of the "shutdown [normal]"
This prevents you from having user sessions blocking the shutdown of the database and thus making the backup invalid.
("Shutdown normal" awaits the end of transactions before shutting down the instance)

rgds
Andreas
Only by ignoring what everyone think is important, can you be aware of what everyone ignores!
Yogeeraj_1
Honored Contributor
Solution

Re: Oracle Startup / Shutdown Script

hi Gus,

We use startup and shutdown scripts found in the /etc/rc*.d directories to make things happen. Many times, these just run a script "dbstart" and "dbshut".

It is preferable to do it yourself though.

Normally, you would setup (as root) the startup/shutdown script in /etc/rc3.d and /etc/rc0.d. Mine are /etc/rc3.d/S100oracle" (startup)and "/etc/rc0.d/K100oracle" (kill).

These scripts are actually a symbolic link to the single script /etc/init.d/oracle. It contains only:


#!/bin/sh

# Start/stop processes required for oracle

case "$1" in
'start')
su - oracle8i -c orastart
su - ias902 -c webstop
;;
'stop')
su - ias902 -c webstop
su - oracle8i -c orastop
;;
esac


In my case, i have 2 Oracle accounts on my machine, one for the 9iAS and 1 for the database. I run simply a script "orastart" to start stuff for them and "orastop" to stop them. I write orastart and orastop. The nice thing about this is that if oracle8i needs to add/remove something from its startup/shutdown -- he doesn't need to get root to update the script, he just modifies orastart/stop.


The orastart script for Oracle8i is as follows:

#!/bin/csh

lsnrctl start

svrmgrl << EOF
connect internal
startup
exit
EOF

Put it in $ORACLE_HOME/bin for Oracle8i. It starts the listener, starts the database.

The shutdown script is similar, it looks like:


#!/bin/csh

lsnrctl stop

svrmgrl << EOF
connect internal
shutdown immediate
exit
EOF


If I needed to start more then one listener, I would have the appropriate commands in there to do so.

This shows how to automate the starting of virtually anything (not just Oracle stuff) on HP-UX....


Hope this helps!

regards
Yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Steven E. Protter
Exalted Contributor

Re: Oracle Startup / Shutdown Script

I would note the reason I don't use dbshut is that it sometimes hangs, making my cold backup window a real problem.

Same thing has happend during system shutdown.

My scripts solve both problems.

I hope that the earlier answers by myself or other help, if so, please throw the other guys some points.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Brian Crabtree
Honored Contributor

Re: Oracle Startup / Shutdown Script

Actually, your best option is to issue a "shutdown abort", "startup restrict", and a "shutdown immediate". This will disconnect all of the sessions (including hung ones not affected by a shutdown immediate) as well as clear up any lock issues that might occur and force all sessions into rollback. The restricted startup will keep any users without restricted session from logging in (ie: automated applications, users connecting directly, etc), and the shutdown immediate will ensure that you have a clean shutdown.

Thanks,

Brian
Dan Zucker
Regular Advisor

Re: Oracle Startup / Shutdown Script

I strongly suggest that the listener not be shutdown, started up, or queried.

I find that the commands that handle the listener require a terminal. There is probably a way around, but since the dtaa base is closed even with an open listener, I just do not bother.

Rory R Hammond
Trusted Contributor

Re: Oracle Startup / Shutdown Script

RE: S. Protter statement that
his shutdowns sometimes "hangs". Shutting down Oracle using the oracle supplied dbshut normally should never hang if You FIRST modify the scripts as noted in a previous thread, by changing to "shutdown immediate" from just "shutdown". Out of the box oracle supplied dbshut script only has "shutdown". A "shutdown" without the immediate or abort option gives the appearance of Oracle hanging, because it is waiting for everyone to logout. I do not recommend "shutdown abort" as an accepted method for taking oracle down. If you have to do an abort, It would be wise to find out what is hanging your Oracle instance. The "hang" might be caused by a long transaction being rolled back or Archive log space is full.

On my system I do not have the luxury to have regular downtimes for backups. All our backup are hotbackups. . We schedule the backups during non peak times. Recovery and full restoral has not been a problem. You should automate Oracle shutdown/startup for OS System reboots. Which is why dbshut/dbstart is associated with /sbin/init.d /etc/rc.d etc.. I also think normal backups should be done without shutting down oracle. If the shuting down of oracle "cleans" things up, time would be better served finding out why unwanted processes/thread/client sessions "things" are hanging around.

I will get off my soap box now.
Good Luck
Rory
There are a 100 ways to do things and 97 of them are right
Gus Mestousis
Frequent Advisor

Re: Oracle Startup / Shutdown Script

I have tried in the past to backup the databses while they are still up, and experience great difficulty on the restores. Due to the environment that I am in, I only have the luxury of shutting them down for a couple f hours during off-peak weekend use. The daily backups are done with the db up, and usually don't work when restoring. Have you had success restoring databses that you backed up while they were up? I am using Omniback, and am looking into adding the Online Extension to it for this reason, in the mean time I feel more comfortable knowing I have a good set every week with the db in a down state.

Thanks everyone for the replies. I'll be sure to assign points to all.

Gus
Sure, let me just drop everything and work on your problem.
Andreas D. Skjervold
Honored Contributor

Re: Oracle Startup / Shutdown Script

Hi

To your question about runnig online backups; use Oracle Recovery Manager (RMAN).

It lets you do online backup (full or incremental) and all kinds of recovery scenarioes.

Do not know if you have to use some software to connect to Omniback. We use Legato and this requires an rather expensive module for connectiong the RMAN to the Legato software (but it works well)

rgds
Andreas
Only by ignoring what everyone think is important, can you be aware of what everyone ignores!
Yogeeraj_1
Honored Contributor

Re: Oracle Startup / Shutdown Script

Hi,

As Andreas said above, RMAN is the way to go!

BECAUSE

RMAN decreases the chance of you making a mistake.

do you regularly test your backups?
I was with a customer who wanted to know why their system was down for days -- yes, days. Why so long? Well, they had a problem, had to restore from backup. Never tested said backup. Discovered all of a sudden their script kicked off the copies BEFORE the alter tablespace begin backup. Whoops - System was fried. Support helped them scavenge what they could but basically, it was a rebuild of the entire big database. That would not happen with RMAN -- less for them to think about, less mistakes possible.

Consider the following also:
You have a single bad block in a 16gig datafile, you are using RMAN in 9i. What do you do? You do an in place recovery of just the bad block, you do not offline the datafile, you do not offline the tablespace, you do not do 16gig of IO to restore the file, you do not roll 16gig of data forward. You recover an individual 8k block.

What would have happened if you didn't use RMAN?
take tablespace offline, restore 16gig, roll it forward then bring it online.

Which gives you less downtime?
Which fully recovers the fastest?
Which would you prefer to do?

In the end -- if you know what you are doing fully, you TEST the backups on a recurring basis, you don't mind being down for a bad block -- the old fashioned way works but -- times are changing, there are more and more reasons to use it.

I would also recommend that you do your backup to disk first then send them to tape (of course if you can afford it!)

Good luck!

If you want more about RMAN, please let us know...

regards
Yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Rory R Hammond
Trusted Contributor

Re: Oracle Startup / Shutdown Script

I restored live backups on several occasions. Without rman. but we do have mirroring.
1. We put oracle in backup mode.
2. then broke the mirrors
3. took oracle out of backup
mode
4. fsck the the mirrors.
5. mount the mirrors in a
different sub directory.
6. backed them up.

Having said the above. RMAN is better. especially if you do not have mirroring.

Rory
There are a 100 ways to do things and 97 of them are right