Operating System - HP-UX
1753317 Members
5302 Online
108792 Solutions
New Discussion юеВ

Re: startup/shutdown scripts

 
SOLVED
Go to solution
Nago
Advisor

startup/shutdown scripts

I have 11.0 and Oracle8i running on it. I need a script that would stop the database and copy redologs and control files to a disk area , then start the database and listener too.
Please assist me..
9 REPLIES 9
maria paschali
Frequent Advisor

Re: startup/shutdown scripts

Hi,

What you need to know is normally illustrated in the Oracle Installation Guide. There is a script that Oracle have written called dbstart dbshut. You will need to create and modify a script which should be located in your /sbin/init.d called dbora, to call these scripts. This helps when you shutdown the Unix box. It cleanly shutdowns the databases you have running.

There are also a couple of other scripts that you can use to intergrate with these to copy the control files and redo logs onto script.

I don't know if this is what you are actually looking for. but i hope i have pointed you in the right direction.

My dbora script looks like this.

#!/bin/sh
# Set ORA_HOME to be equivalent to the ORACLE_HOME from which
# you wish to execute dbstart and dbshut
#
# Set ORA_OWNER to the user id of the owner of the Oracle
# database in the ORA_HOME
ORA_HOME=/u01/app/oracle/product/8.1.7
ORA_OWNER=oracle
if [ ! -f $ORA_HOME/bin/dbstart ]
then
echo "Oracle startup: cannot start"
exit
fi
case "$1" in
'start')

# Start the Oracle databases:

# The following command assumes that the oracle login will not
# prompt the user for any values

echo "Oracle Startup in progress"
/usr/bin/su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart"
/usr/bin/su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start"
;;

'stop')

# Stop the Oracle databases:
# The following command assumes that the oracle login will not
# prompt the user for any values

echo "Oracle Shutdown in progress"
/usr/bin/su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut"
/usr/bin/su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"
;;
esac
Sridhar Bhaskarla
Honored Contributor

Re: startup/shutdown scripts

Nago,

Get the startup and shutdown scripts from your DBA. You can use any file in /sbin/init.d/ as a template. Copy it to the name that you want. Basically this script takes one argument. There would be four types of the argument. start_msg, stop_msg, start, stop. There are case statements that call different routines based on the argument passed. It is very self-explanatory if you look at any of the scripts in /sbin/init.d Once this is done, create links from either /sbin/rc3.d or /sbin/rc4.d depending on the default run level you have in your /etc/inittab. (mostly rc3.d).

For ex., you call your scripts as oracle,oracle_lsnr first test them

#/sbin/init.d/oracle start
#/sbin/init.d/oracle stop
#/sbin/init.d/oracle_lsnr start
#/sbin/init.d/oracle_lsnr stop

Once these scripts are working, now create links

#ln -s /sbin/init.d/oracle /sbin/rc3.d/S925oracle
#ln -s /sbin/init.d/oracle /sbin/rc3.d/K925oracle
#ln -s /sbin/init.d/oracle_lsnr /sbin/rc3.d/S926oracle_lsnr
#ln -s /sbin/init.d/oracle_lsnr /sbin/rc3.d/K926oracle_lsnr

The above number decide when the scripts are to be run in that run level.

You can also control these scripts by calling the "flag scripts" from /etc/rc.config.d directory. Here you can set a flag like ORACLE=0 or 1 and you can verify this flag in your /sbin/init.d/ script.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Wodisch
Honored Contributor

Re: startup/shutdown scripts

Hello Nago,

the only way to be certain you copy the "real" files, is
to ask the Oracle instance before shutting it down:

su - oracle
svrmgrl
connect internal
startup exclusive
spool files.lst
select name from v$controlfile;
select member from v$logfile;
select name from v$datafile;
spool off
shutdown immediate
exit
echo $ORACLE_HOME/dbs/init$ORACLE_SID.ora > list
grep '/' files.lst | tr -d ' ' >> list
cp $(cat list) /backup
dbstart

This will make a full offline backup of you instance.
But really, it needs more to set up a proper procedure
to backup and restore a productive Oracle DB server!
Be careful. Kevin Loneys book "DBA Handbook" might
be a good starting point for you.

HTH,
Wodisch
CHRIS ANORUO
Honored Contributor
Solution

Re: startup/shutdown scripts

Hi Nago,

The dbshut and dbstart files can be modified in ORACLE_HOME/bin for your instances and yur start/stop script placed in /sbin/init.d folder. For the script callup program in /etc/rc.config.d. With the startup link in /sbin/rc3.d (S###orac???) and stop link file in sbin/rc1.d (K###orac???)with the proper sequence numbers. Always check the etc/rc.log file for any errors. See attached file
When We Seek To Discover The Best In Others, We Somehow Bring Out The Best In Ourselves.
CHRIS ANORUO
Honored Contributor

Re: startup/shutdown scripts

Hello Nago,

This script is for daily Flexcube/Oracle control file and Redo log backups. Pls see the attached file. It shuts down the databases, creates a folder with the day's date. The program also copies your files to a created directory for the day and sends mail to the DBA's
When We Seek To Discover The Best In Others, We Somehow Bring Out The Best In Ourselves.
CHRIS ANORUO
Honored Contributor

Re: startup/shutdown scripts

Hello NAGO!

You can now award your scores so that we know how we have helped you.


Chris
When We Seek To Discover The Best In Others, We Somehow Bring Out The Best In Ourselves.
Wodisch
Honored Contributor

Re: startup/shutdown scripts

Hello, all you helpful "reply" writers,

since s/he does not respond, I guess s/he is
not really interested :-(

BUT, this is a pretty good candidate for a FAQ,
is it not?

Kind regards,
Wodisch
Rajkumar_3
Regular Advisor

Re: startup/shutdown scripts

Hai Nago,

Dont forget to assign the points who helped you....

Rajkumar
Oracle DBA
Deepak Extross
Honored Contributor

Re: startup/shutdown scripts

Rajkumar,

Noble Advice indeed.

From your profile:
This member has assigned points to 45 of 98 responses to his/her questions.

:-)