Operating System - HP-UX
1751853 Members
5553 Online
108782 Solutions
New Discussion юеВ

Re: startup/shutdown script for oracle 8i database

 
Evella Dawson
Advisor

startup/shutdown script for oracle 8i database

Need assistance. MY OS is HPUX 11. I am in need of a script that I can use in a CRON to shutdown and startup my 8i database mon - fri, from 12 midnight to 6am.
persistence is the road to success
13 REPLIES 13
Stefan Schulz
Honored Contributor

Re: startup/shutdown script for oracle 8i database

Hi,

can't you use the normal start/stop script which should be installed in /sbin/init.d/oracle?

I think if that this should produce the least problems. Just use cron to start/stop oracle with this script and redirect the output (STDOUT/STDERR) to a file or /dev/null

Hope this helps

Regards Stefan
No Mouse found. System halted. Press Mousebutton to continue.
Alexey A. Shumilin
New Member

Re: startup/shutdown script for oracle 8i database

Hi !

It's my script for shutdown and startup db.

I have 2 instances of Oracle on my server and
necessary for me to switch oracle environment.

Look these file:
David Burgess
Esteemed Contributor

Re: startup/shutdown script for oracle 8i database

How about something like this in roots crontab :-

0 0 * * * su -oracle -c dbshut
0 6 * * * su -oracle -c dbstart

It's been a while since I used oracle, but I recall Oralce supply scripts to do this. You'll just need the full path to dbshut and dbstart in roots crontab.

cd $ORACLE_HOME
find . -name dbshut
find . -name dbstart

On AIX they are in

/u01/app/oracle/product/8.0.4/bin

I imagine you'll find them in a similar place.

Therefore the crontab entry would be this :-

0 0 * * * su -oracle -c /u01/app/oracle/product/8.0.4/bin/dbshut
0 6 * * * su -oracle -c /u01/app/oracle/product/8.0.4/bin/dbstart

HTH

Dave.
David Burgess
Esteemed Contributor

Re: startup/shutdown script for oracle 8i database

You might also want to create a script called dbabort based on dbshut that does a dbabort, dbstart and dbshut to ensure a clean shutdown if dbshut hangs due to users still being logged in.

Put this in the crontab to run say 10 minutes after dbshut. If you want to do a backup, make sure it starts after dbabort has completed.

Dave.
Andreas D. Skjervold
Honored Contributor

Re: startup/shutdown script for oracle 8i database

Hi

First you'll have to get inplace the automatic startup script for starting oracle when startup of server:

Update /etc/oratab with SID:ORACLE_HOME:Y line for your database.

Put inplace init.d script dbora:
/sbin/init.d/dbora:
---
#!/sbin/sh
# Start/stop of Oracle database
#
ORA_HOME=/oracle/product/8.1.7
ORA_OWNER=oracle
if [ ! -f $ORA_HOME/bin/dbstart -o ! -d $ORA_HOME ]
then
echo "Oracle startup: cannot start"
exit
fi
case "$1" in
start_msg)
echo "Start ORACLE databases"
;;

stop_msg)
echo "Stop ORACLE databases"
;;
'start')
# Start the oracle databases
/usr/bin/su - $ORA_OWNER -c $ORA_HOME/bin/dbstart
;;
'stop')
# Stop the oracle databases
/usr/bin/su - $ORA_OWNER -c $ORA_HOME/bin/dbshut
;;
esac
---

Create link to runlevel directories:
ln -s /sbin/init.d/dbora /sbin/rc0.d/K10dbora
ln -s /sbin/init.d/dbora /sbin/rc2.d/S99dbora


You might also want to edit the $ORACLE_HOME/bin/dbshut script to read "shutdown immediate" instead of "shutdown"


Then simply use this script in your crontab:
01 00 * * /sbin/init.d/dbora stop >/tmp/orashut.log 2>&1
00 06 * * /sbin/init.d/dbora start >/tmp/orastart.log 2>&1

Andreas
Only by ignoring what everyone think is important, can you be aware of what everyone ignores!
Evella Dawson
Advisor

Re: startup/shutdown script for oracle 8i database


HI David

Thanks for the info. I have two Oracle SIDs.

Will this process shutdown both?
Do I have to modify the dbabort(a copy of dbshut) inorder to shutdown if a user is still logged on?
If so, what do I have to change?
persistence is the road to success
David Burgess
Esteemed Contributor

Re: startup/shutdown script for oracle 8i database

Hiya,

dbstart, dbshut and dbabort will look at the 3rd field of /etc/oratab (location of oratab may be somewhere else). This field will be either Y or N. If set to Y then the scripts will act on these databases.

In dbabort you will need to change the shutdown bit from

connect internal
shutdown
EOF

to

connect internal
shutdown abort
startup
shutdown
EOF

Try it on a test database to make sure it works ok before putting it into live.

I'm not sure if you would be better off using something like not mounting the database when you restart it to keep the users from getting in after you've just cleaned up after them!

If in doubt check with Oracle support!

Remember that oratab may control whether the database starts at system boot. ie there may be an rc script than checks for this. Also check that no in house written scripts rely on oratab. You don't want to affect them!

HTH

Dave.
T G Manikandan
Honored Contributor

Re: startup/shutdown script for oracle 8i database

#vi stutdb
ps -ef|grep ora_reco|grep -v grep|awk '{print $9}'| cut -c 10- >givedb
for i in `cat givedb`
do
ORACLE_SID=$i
export ORACLE_SID
svrmgrl << !
connect internal;
shutdown immediate;
!
echo "database has been shutdown properly"
done

#vi startdb
for i in 'cat givedb'
do
svrmgrl << !
connect internal;
startup force;
!
lsnrctl start
done
Jeanine Kone
Trusted Contributor

Re: startup/shutdown script for oracle 8i database

In response to Dave's last message, just do a startup restrict after the abort to make sure no users log in.