Operating System - HP-UX
1831353 Members
2985 Online
110024 Solutions
New Discussion

Startup and Shutdown scripts - Please help !

 
Tan Shirley
Frequent Advisor

Startup and Shutdown scripts - Please help !

Hi,

I would like my server to automatically bring up and shutdown my databases when the server boots up and shutdown respectively.(in the event that should there be a power failure in the middle of night and the server was rebooted, at least my databases are shutdown properly and was UP when I come into the office the next day)
How do I do that? Which files should I edit?
Currently we are running a cron job to schedule it to shutdown at and reboot at a specific time in the middle of the night.

Please help !

Regards,
Shirley
13 REPLIES 13
John Waller
Esteemed Contributor

Re: Startup and Shutdown scripts - Please help !

You will need to write your own startup and shutdown script as per the files in /sbin/init.d then link it into the perticular run level directory (/sbin/rc?.d) Their is a file called template in /sbin/init.d which you can copy to another name then use to manage your database. e.g cp /sbin/init.d/template to /sbin/init.d/database. Then within the /sbin/rc3.d directory create a link " ln -s /sbin/init.d/database /sbin/rc3.d/Snnndatabase" (where nnn is a number which controls the order jobs are started lowest first) also in /sbin/rc2.d diroctory you will need a Knnndatabase file to close down. (nnn again a number which controls the order jobs are stopped , highest first). You may need to be aware but depending on your system setup if you have a powercut your machine may just halt and not perform a clean shutdown.
James R. Ferguson
Acclaimed Contributor

Re: Startup and Shutdown scripts - Please help !

Hi:

To fully understand how the startup/shutdown mechanism works at boot time, see this white paper:

http://docs.hp.com/hpux/onlinedocs/os/boot.html

...JRF...
CHRIS_ANORUO
Honored Contributor

Re: Startup and Shutdown scripts - Please help !

You have to makes in /etc/rc.config.d and /sbin/init.d. In $ORACLE_HOME/bin, there are dbstart and dbshut files that you need to update with the databases SID's. See the attached file for a sample.
(
# Set path if path not set (if called from /etc/rc)
case $PATH in
"") PATH=/bin:/usr/bin:/etc
export PATH ;;
esac

ORACLE_HOME=/oracle/oracle export ORACLE_HOME
PATH=$ORACLE_HOME/bin:$PATH export PATH


# instance specific startup section
ORACLE_SID=databasename export ORACLE_SID
svrmgrl <connect internal
startup
EOF
if [ $? -eq 0 ]; then
echo ""
echo "Database "${ORACLE_SID}" WARM started."
else
echo ""
echo "Database "${ORACLE_SID}" NOT started."
fi
)
When We Seek To Discover The Best In Others, We Somehow Bring Out The Best In Ourselves.
CHRIS_ANORUO
Honored Contributor

Re: Startup and Shutdown scripts - Please help !

You have to makes in /etc/rc.config.d and /sbin/init.d. In $ORACLE_HOME/bin, there are dbstart and dbshut files that you need to update with the databases SID's. See the attached file for a sample.
(
# Set path if path not set (if called from /etc/rc)
case $PATH in
"") PATH=/bin:/usr/bin:/etc
export PATH ;;
esac

ORACLE_HOME=/oracle/oracle export ORACLE_HOME
PATH=$ORACLE_HOME/bin:$PATH export PATH


# instance specific startup section
ORACLE_SID=databasename export ORACLE_SID
svrmgrl <connect internal
startup
EOF
if [ $? -eq 0 ]; then
echo ""
echo "Database "${ORACLE_SID}" WARM started."
else
echo ""
echo "Database "${ORACLE_SID}" NOT started."
fi
)
When We Seek To Discover The Best In Others, We Somehow Bring Out The Best In Ourselves.
Dan Hetzel
Honored Contributor

Re: Startup and Shutdown scripts - Please help !

Hi Shirley,

Here attached is the startup script we use.
It needs to be put in /sbin/init.d

You'll also need:
2 symbolic links to that file
the first one in /sbin/rc3.d called i.e. S999oracle
the second one in /sbin/rc2.d called i.e. K999oracle

a config file named /etc/rc.config.d/oracle containing the following (edit to your needs)

--- cut here ---
# @(#) $Revision: 1.0 $
# File: /etc/rc.config.d/oracle
#
# The variable ORA_START controls whether the ORACLE will be
# started on entering multiuser mode. By default it is not started.
# If you want it to be, set the value to 1.
# (31.05.95, Foerster/HP)
#
#
ORA_START=1
#
#
# ORA-administrator-user:
ORA_USER="oracle"
#
#
# Command to start up all databases :
ORA_START_COMMAND="/usr/local/bin/dbstartd"
#
# Command to shutdown all databases :
ORA_STOP_COMMAND="/usr/local/bin/dbshutd"
#
#
# Command to start LISTENER :
LSNR_START_COMMAND="/opt/oracle/734/bin/lsnrstart"
#
# Command to start AGENT :
AGENT_START_COMMAND="/usr/local/bin/dbsnmp_start"
#
# Command to stop LISTENER :
LSNR_STOP_COMMAND="/opt/oracle/734/bin/lsnrstop"
#
# Command to stop AGENT :
AGENT_STOP_COMMAND="/usr/local/bin/dbsnmp_stop"
#
#
#
# (end)

--- cut here


The mechanism is the following:
When entering multi-user (level 3 = default), scripts in /sbin/rc3.d starting with letter S (for start) are run.
As well as scripts in rc1.d rc2.d before that

When shutting down, coming from level 3, all scripts in rc2.d, rc1.d and rc0.d starting with letter K (for kill) are run

This would start/stop oracle.

Adjust all variables here above to suit your settings.

Best regards,

Dan



Everybody knows at least one thing worth sharing -- mailto:dan.hetzel@wildcroft.com
James R. Ferguson
Acclaimed Contributor

Re: Startup and Shutdown scripts - Please help !

Hi (again):

Here's a thread that will get you started:

http://my1.itrc.hp.com/cm/QuestionAnswer/1,1150,0x8afc6c96588ad4118fef0090279cd0f9,00.html

...JRF...
CHRIS_ANORUO
Honored Contributor

Re: Startup and Shutdown scripts - Please help !

You have to makes in /etc/rc.config.d and /sbin/init.d. In $ORACLE_HOME/bin, there are dbstart and dbshut files that you need to update with the databases SID's. See the attached file for a sample.
(
# Set path if path not set (if called from /etc/rc)
case $PATH in
"") PATH=/bin:/usr/bin:/etc
export PATH ;;
esac

ORACLE_HOME=/oracle/oracle export ORACLE_HOME
PATH=$ORACLE_HOME/bin:$PATH export PATH


# instance specific startup section
ORACLE_SID=databasename export ORACLE_SID
svrmgrl <connect internal
startup
EOF
if [ $? -eq 0 ]; then
echo ""
echo "Database "${ORACLE_SID}" WARM started."
else
echo ""
echo "Database "${ORACLE_SID}" NOT started."
fi
)
When We Seek To Discover The Best In Others, We Somehow Bring Out The Best In Ourselves.
Dan Hetzel
Honored Contributor

Re: Startup and Shutdown scripts - Please help !

Hi Shirley,

Not sure the file attached properly
Here is it

Dan
Everybody knows at least one thing worth sharing -- mailto:dan.hetzel@wildcroft.com
CHRIS_ANORUO
Honored Contributor

Re: Startup and Shutdown scripts - Please help !

You have to makes in /etc/rc.config.d and /sbin/init.d. In $ORACLE_HOME/bin, there are dbstart and dbshut files that you need to update with the databases SID's. See the attached file for a sample.
(
# Set path if path not set (if called from /etc/rc)
case $PATH in
"") PATH=/bin:/usr/bin:/etc
export PATH ;;
esac

ORACLE_HOME=/oracle/oracle export ORACLE_HOME
PATH=$ORACLE_HOME/bin:$PATH export PATH


# instance specific startup section
ORACLE_SID=databasename export ORACLE_SID
svrmgrl <connect internal
startup
EOF
if [ $? -eq 0 ]; then
echo ""
echo "Database "${ORACLE_SID}" WARM started."
else
echo ""
echo "Database "${ORACLE_SID}" NOT started."
fi
)
When We Seek To Discover The Best In Others, We Somehow Bring Out The Best In Ourselves.
Paula J Frazer-Campbell
Honored Contributor

Re: Startup and Shutdown scripts - Please help !

Hi

In your question you mention "in the event of a power failure".
This brings up two points:-

1. Are your servers not running off a UPS?

2. If the server shuts down due to a power failure the chance of a Database corruption is high and automaticlly bringing up a database without control has potential problems.


Paula
If you can spell SysAdmin then you is one - anon
Cheryl Griffin
Honored Contributor

Re: Startup and Shutdown scripts - Please help !

In addition:
For a complete explanation of the scripts and how to customize your system, check out the startup/shutdown white paper:

/usr/share/doc/start_up.txt
"Downtime is a Crime."
Shumi Begum
Advisor

Re: Startup and Shutdown scripts - Please help !

One more comment. If you are running oracle 8i , dbstart script does not do the job. You would not be able to start up the database unless the following are applied.
1) follow instruction of document 98418.1 from oracle
2) edit the dbstart file again. replace the awk line /PLVSQL (Release|Version) with
/JServer (Release|Version)

Just following the step one would not solve the problem if it is not enterprise version.

Thanks.
HPP
Regular Advisor

Re: Startup and Shutdown scripts - Please help !

Hi,
Also you can descide in which init level the database should come up. If you want the database to come up at 4 level, then you have to link the the database startup script in /sbin/init.d/dbstart to /sbin/rc4.d, by executing
"ln -s /sbin/init.d/dbstart /sbin/rc4.d/S9500dbshut". Also you have to edit /etc/inittab and change the value after init to 4. When system comes up, init will execute scripts in /sbin/rc2.d then rc3.d and rc4.d.

This way you can configure your software to start specfically after some app has started.

Hope it helps.
Cheers
Be Teachable