cancel
Showing results for 
Search instead for 
Did you mean: 

Dbshut and dbstart

SOLVED
Go to solution
Qcheck
Super Advisor

Dbshut and dbstart

Hi All,

I am unixadmin and dba's gave the scripts to start the oracle when server reboots and stop the database gracefully when the server is going to reboot/shutdown.

Now the problem is it doesn't stop the database and hangs there...

What I did was, created the following files:

/sbin/init.d/dbshut
/sbin/init.d/dbstart

And linked as follows:

/sbin/rc0.d/K01dshut -> /sbin/init.d/dbshut
/sbin/rc3.d/S824dbstart -> /sbin/init.d/dbstart

And when rebooted the server, oracle didn't come up.

Any ideas, how to put startup and shutdown scripts in HPUX.

Thanks
21 REPLIES
Rick Garland
Honored Contributor

Re: Dbshut and dbstart

For the dbshut, is the 'shutdown immediate' included, or is it just 'shutdown'

Qcheck
Super Advisor

Re: Dbshut and dbstart

Hi Rick,

Thanks for the response but where should I include 'shutdown immediate'?

Thanks
Steven E. Protter
Exalted Contributor
Solution

Re: Dbshut and dbstart

Shalom,

dbshut ships with a bug.

It should say shutdown immediate but says shutdown.

shutdown waits for the users to terminate their sessions, which means pretty much forever.

change dbshut and you should be fine.

There are however not bugs that I know of in dbstart.

Put a set -x in the top of that script and/or redirect the output to a file and restart your server for further diagnostics.

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
Qcheck
Super Advisor

Re: Dbshut and dbstart

Hi Steve,

Still I didn't get.

Instaed of /sbin/init.d/dbshut are you saying to put /sbin/init.d/shutdown?

Thanks
David Bellamy
Respected Contributor

Re: Dbshut and dbstart

Hello Pratibha the dbshut and dbstart scripts should also be copied to the /etc/rc.config.d
directory.
Rick Garland
Honored Contributor

Re: Dbshut and dbstart

As SEP has stated, in the dbshut is the command 'shutdown' - this should be 'shutdown immediate'

This would hang the shutdown because the database is waiting for all connections to be closed. If users are working, or do not logout, connections will never close and the shutdown will not complete.

Qcheck
Super Advisor

Re: Dbshut and dbstart

The dbshut script has the following:

#!/usr/bin/sh

/usr/bin/su oracle -c '

Thanks
DCE
Honored Contributor

Re: Dbshut and dbstart


You need to modify the dbshut script.

vi the file and look the for the line containing shutdown

change the line to shutdown immediate

HTH DCE
Greg Vaidman
Respected Contributor

Re: Dbshut and dbstart

you probably don't want to run dbshut and dbstart directly out of the sytem startup like you're doing, since they usually should be executed by the oracle user (usually "oracle"). You'll want to make a copy of /sbin/init.d/template and put an su to your oracle user to run those commands, e.g.,

su - oracle -c "/opt/oracle/product/9.2.0/bin/dbstart"

etc.

you can make one script that does the dbshut in response to the "stop" parameter and dbstart in response to the "start" parameter. then create the links as you have above, but to the new script.
Ninad_1
Honored Contributor

Re: Dbshut and dbstart

Hi,
It seems that you are calling the script which shuts down the database as per your note
"/usr/bin/su oracle -c '"
Please check if this script, your dba gave to you, has the shutdown immediate command. Or post the script.
It seems that your database did not shutdown properly and hence it failed to start.
Also check the contents of /etc/oratab - usually this is referred by scripts to check if database is to be started automatically during startup
There should be a Y for the database SID you want to startup.

Regards,
Ninad
rariasn
Honored Contributor

Re: Dbshut and dbstart

Sample shutdown:

echo "INFO_SGAURD_DESA: Parando Oracle CASS100"

su - oracle -c '
. /home/oracle/oradb/conf/profile_oradb

#Borramos el fichero orapwORADB
rm $ORACLE_HOME/dbs/orapwORADB

sqlplus /nolog <connect / as sysdba
shutdown immediate
exit;
EOF
'

"profile_oradb":

set +u
id|grep oracle > /dev/null
if [ $? -eq 0 ]
then
ORACLE_HOME=/opt/oracle
export ORACLE_HOME
ORACLE_SID=ORADB
export ORACLE_SID
export PS1='$LOGNAME@'`/usr/bin/hostname`[$ORACLE_SID]':$PWD$ '
else
ORACLE_HOME=/opt/oracle
export ORACLE_HOME
unset ORACLE_SID
TWO_TASK=ORADB
export TWO_TASK
export PS1='$LOGNAME@'`/usr/bin/hostname`[$TWO_TASK]':$PWD$ '
fi

ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
export ORA_NLS33

rgs,

ran
Frank de Vries
Respected Contributor

Re: Dbshut and dbstart

Yes, that happens.
That is because the Oracle software comes
default like this. (Thinking we live
in an ideal world were all users log out
as they should etc.. etc..)

You and I know that is never the case,
so the first thing I do when I deal with
an Oracle db on hpux.

I modify the dbshut and
change shutdown to shutdown immediate
and I modify the oraenv file and
delete the last lines with osh

And this has been so since the nineties.
Amazing hey.

Keep cooking:)
Look before you leap
Senthil Kumar .A_1
Honored Contributor

Re: Dbshut and dbstart

Hi Prathiba,

Form you following line...

/sbin/rc0.d/K01dshut -> /sbin/init.d/dbshut
/sbin/rc3.d/S824dbstart -> /sbin/init.d/dbstart

I noticed that the sequencer script dbstart is fine, but dbshut is pushed too low down. Make sure, you link it in /sbin/rc2.d instead /sbin/rc0.d

Basically it should be...

/sbin/rc2.d/K01dshut -> /sbin/init.d/dbshut

In your current case, your DB is being shutdown after all your network service goes down in rc2 - rc1 transition. During rc1 - rc0 transition there is no network service available when you are performing DB shutdown currently. This could be one reason for a hang though may not confirm. Also apart from network services ,there are numerous other services you had be missing at the time of rc1 - rc0 transition.

So try changing dbshut to "rc2.d" instead of "rc0.d" dir and test it.

Regards,
Senthil Kumar .A
Let your effort be such, the very words to define it, by a layman - would sound like a "POETRY" ;)
Senthil Kumar .A_1
Honored Contributor

Re: Dbshut and dbstart

Also,

instead of K01dshut, rename it as K176dshut.

Try these commands to rectify...

rm /sbin/rc0.d/K01dshut
ln -s /sbin/init.d/dbshut /sbin/rc2.d/K176dshut
ll /sbin/rc2.d/K176dshut

Now you should be seeing a file ...

/sbin/rc2.d/K176dshut -> /sbin/init.d/dbshut

Now go ahead and test it...

Regards,
Senthil Kumar .A
Let your effort be such, the very words to define it, by a layman - would sound like a "POETRY" ;)
Qcheck
Super Advisor

Re: Dbshut and dbstart

Hi Senthil,

Thank you for all the help and thanks to everyone who is helping out.

Still it doesn't work.

"There should be a Y for the database SID you want to startup."

How can I enable the above in /etc/oratab file.

# $ORACLE_SID:$ORACLE_HOME::

Do I need to enable like the following:

$ORACLE_SID:$ORACLE_HOME::

Please let me know.
Qcheck
Super Advisor

Re: Dbshut and dbstart


And one more thing:

What does the following does in /etc/oratab file:

*:/u01/app/oraias/product/Appserv:N #9.0.4.2 App server

Thanks
rariasn
Honored Contributor

Re: Dbshut and dbstart

# This file is used by ORACLE utilities. It is created by root.sh
# and updated by the Database Configuration Assistant when creating
# a database.

# A colon, ':', is used as the field terminator. A new line terminates
# the entry. Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
# $ORACLE_SID:$ORACLE_HOME::
#
# The first and second fields are the system identifier and home
# directory of the database respectively. The third filed indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#

rgs,
Ninad_1
Honored Contributor

Re: Dbshut and dbstart

Pratibha,

As I said earlier - it depends on the script you are using to startup and shutdown the database - which in most cases refers to this file /etc/oratab to see if there are any databases to be started when system comes up.
First thing would be to check your script used for startup and shutdown. Does the startup script check /etc/oratab ? If yes then simply edit the file using vi editor and put a Y if there is a N for the database SID entry you wish to start the database at startup.
This is also assuming you are not running a MC Service Guard cluster [ In which case the database is started as part of a package startup ] Are you running in a cluster or standalone ?
ps -eaf | grep cmcl

Again I would like to say - please check the script you said your DBAs gave you - the actual script you call after the su oracle.
Another thing - try
su - oracle -c '
instead of
su oracle -c '

Also have you tried the suggestion of shutting down the database at run level 2 while shutting down the system by linking the shutdown script into /etc/rc2.d ??

Another thing - have you tried to run the shutdown script manually - ofcourse after throughly checking all the above suggestions regarding the script first.

Please let us know what all you have tried.

Regards,
Ninad
Frank de Vries
Respected Contributor

Re: Dbshut and dbstart

I go with what Ninad Date is saying.
Makes a lot of sense.

There is a dbshut script and dbstart under
$ORACLE_HOME/bin

These are to be used in our
/sbin/init.d/oracle
(You could have a seperate one for our listener)

/sbin/rc0.d/K01oracle_stop -> /sbin/init.d/oracle
/sbin/rc3.d/S824oracle_start /sbin/init.d/oracle

The /sbin/init.d/oracle script should look
see attached

and the that oracle script should call
dbshut under $ORACLE_HOME as the oracle
owner (and in that dbshut command you should
have 'shutdown immediate' for the correct version of your oracle)

Furhtermore
Oratab needs to be correct thus:
autoP1:/usr/oracle/product/9.2.07:Y

One note: If your db is hanging or blocked,
then the only way out is a shutdown abort,
then a startup and then run your
/sbin/init.d/oracle stop and start again
for a clean stop and start !!

Hope u get it sorted :)


Look before you leap
Frank de Vries
Respected Contributor

Re: Dbshut and dbstart

Ooops the attachments
/sbin/init.d/oracle

You can run this manually
as well with stop and start

or it will be run by the rc command.

good luck:)
Look before you leap
Qcheck
Super Advisor

Re: Dbshut and dbstart

Hi All,

Thank you very much for all your help. Finally it is working with "su - oracle" in the script.

I really appreciate each and everyone who helped me out on this.

Thanks again alot!