Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
General
cancel
Showing results for 
Search instead for 
Did you mean: 

Oracle 10g automated startup/shutdown HP-UX 11.23

Miguel Silva Rentes
Regular Advisor

Oracle 10g automated startup/shutdown HP-UX 11.23

Hi everyone!

I'm trying to make an automated procedure to startup/shutdown oracle at reboot time in a HP-UX 11.23 server. I've followed the steps explained in Oracle's Metalink "How to Start Database And Listener at System Reboot on Unix Systems" but its written for Oracle 9i server. And I have Oracle 10g. :p . I've done all the steps described there but as I hoped, it doesn't work.

Does anybody have a script to make this work?

10 Points will be given for the correct scripts =)

Thanks in advance,

Miguel Rentes
18 REPLIES
Tim Nelson
Honored Contributor

Re: Oracle 10g automated startup/shutdown HP-UX 11.23

dbstart and dbshut should be included in the bin directory of oracle home.

put them in your startup template file.

1)cp /sbin/init.d/template /sbin/init.d/oracle
2) edit /sbin/init.d/oracle startup and shutdown sections with su - oracle -c "$ORACLE_HOME/bin/dbstart or dbshut.
3) modify CONTROL_VARIABLE to ORACLE.
4)create /etc/rc.config.d/oracle and edit ORACLE=1
5) in /sbin/rc3.d. ln -s /sbin/init.d/oracle S900oracle
6) in /sbin/rc2.d. ln -s /sbin/init.d/oracle K900oracle

Test it out.

Yogeeraj_1
Honored Contributor

Re: Oracle 10g automated startup/shutdown HP-UX 11.23

hi Miguel,

You can also follow the instructions in the document found in the URL below:

http://docs.hp.com/en/934/startup.pdf

though generic, you can configure your oracle database to start using the same principles.

if you need any further assistance, please let us know.

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
patrik rybar_1
Frequent Advisor

Re: Oracle 10g automated startup/shutdown HP-UX 11.23

here is my which i'm using long time

(just uncomment and set your lines in the dbstart for listener starting and stopping)

#!/bin/sh
PATH=/usr/sbin:/usr/bin:/sbin
export PATH
export oraowner=YOUR_ORA_OWNER
export ORACLE_HOME=YOUR_ORACLE_HOME
#
set -x
rval=0
case "$1" in
'start_msg')
echo "Starting Oracle Databases"
;;
'stop_msg')
echo "Stopping Oracle Databases"
;;
'start')
su - $oraowner -c "$ORACLE_HOME/bin/dbstart"
rval=0
;;
'stop')
su - $oraowner -c "$ORACLE_HOME/bin/dbshut"
rval=0
;;
*)
echo "Usage \: dbora \"
rval=1
;;
esac;
exit $rval
Aashique
Honored Contributor

Re: Oracle 10g automated startup/shutdown HP-UX 11.23

Hi Silva,
Please check the attached script. Its working on 10g.



Thanks & Regards

Aashique
grahamswilson
Trusted Contributor

Re: Oracle 10g automated startup/shutdown HP-UX 11.23

Hi,

I just went through this problem and here is what I ended up with (attached). It works very well and avoids the "issues" when trying to use "su" to the oracle account...

The only pre-requisite for this version of the script is that root must be able to "ssh" to the oracle account without a password. I'm not sure if you know how to generate the keys to achieve this - if not, let me know. (The original script from Oracle used "remsh" instead of "ssh".)

Hope it helps - I went through a lot to get this working, but it was worth it!
RadeS
Occasional Visitor

Re: Oracle 10g automated startup/shutdown HP-UX 11.23

Hi,

@Graham

"The only pre-requisite for this version of the script is that root must be able to "ssh" to the oracle account without a password. I'm not sure if you know how to generate the keys to achieve this - if not, let me know. (The original script from Oracle used "remsh" instead of "ssh".)"

Can you please provide the steps how to create these keys?

Thanks,

Rade
Miguel Silva Rentes
Regular Advisor

Re: Oracle 10g automated startup/shutdown HP-UX 11.23

Hi Rustam,

Here's what I did to make this work.

1) Log onto the system as root. Edit the file /etc/oratab. Add a line for any Oracle SID you want to start after a system reboot:

:/oracle/oraHome1:Y

2) Create a script named oracle under /sbin/init.d and add the following contents:

#!/bin/sh

#installation
ORACLE_HOME=/oracle/oraHome1
PATH=${PATH}:$ORACLE_HOME/bin:/usr/bin
HOST=`hostname`

#change the value of ORACLE to the login name of the oracle owner
ORACLE=oracle

export ORACLE_HOME PATH

LOG=$ORACLE_HOME/startup.log
rm -f $LOG
touch $LOG
chmod 666 $LOG
chown oracle:users $LOG

# When HP-UX starts/stops
case $1 in
'start')
echo "$0: starting up" >> $LOG
date >> $LOG
# Start Oracle Net
echo "starting Oracle Net listener" >> $LOG
echo "starting Oracle databases" >> $LOG
su - oracle -c â $ORACLE_HOME/bin/dbstart >> $LOGâ
su - oracle -c "$ORACLE_HOME/bin/lsnrctl start >> $LOG"
;;
'stop')
echo "$0: shutting down" >> $LOG
date >> $LOG
# Stop Oracle Net
echo "stopping Oracle Net listener" >> $LOG
echo â stopping Oracle databasesâ >> $LOG
su â oracle â c â $ORACLE_HOME/bin/dbshut >> $LOGâ
su - oracle -c â $ORACLE_HOME/bin/lsnrctl stop >> $LOGâ

;;
*)
echo " Starting Automated Oracle startup"
exit
;;
esac
#
exit

3) Change this script's permissions and owner:

chmod 750 /sbin/init.d/oracle
chown bin:bin /sbin/init.d/oracle

4) Create the following links:

ln -s /sbin/init.d/oracle /sbin/rc3.d/S99oracle
ln -s /sbin/init.d/oracle /sbin/rc0.d/K01oracle

5) Logout as root. At the next system reboot you will have the instance specified above automatically started.

Hope this procedure helps =)

Best regards,

Miguel Rentes
rariasn
Honored Contributor

Re: Oracle 10g automated startup/shutdown HP-UX 11.23

rustam_2
Super Advisor

Re: Oracle 10g automated startup/shutdown HP-UX 11.23

Thanks a lot, Miguel Rentes that explained me every steps by detail. I just need to test them.
Listen, if you noticed script which you type has some strange symbols, i mean i dont know which letters are there. Would you attach script in text file?

Best regards,
rustam

P.S. I'm gonna do it tomorrow morning when i will be at work.
Miguel Silva Rentes
Regular Advisor

Re: Oracle 10g automated startup/shutdown HP-UX 11.23

Hi Rustam,

Here's the script without those ugly characters (I did a copy-paste from a Word document and that's why it got like that... sorry!):

#!/bin/sh

#installation
ORACLE_HOME=/oracle/oraHome1
PATH=${PATH}:$ORACLE_HOME/bin:/usr/bin
HOST=`hostname`

#change the value of ORACLE to the login name of the oracle owner
ORACLE=oracle

export ORACLE_HOME PATH

LOG=$ORACLE_HOME/startup.log
rm -f $LOG
touch $LOG
chmod 666 $LOG
chown oracle:users $LOG

# When HP-UX starts/stops
case $1 in
'start')
echo "$0: starting up" >> $LOG
date >> $LOG
# Start Oracle Net
echo "starting Oracle Net listener" >> $LOG
echo "starting Oracle databases" >> $LOG
su - oracle -c "$ORACLE_HOME/bin/dbstart >> $LOG"
su - oracle -c "$ORACLE_HOME/bin/lsnrctl start >> $LOG"
;;
'stop')
echo "$0: shutting down" >> $LOG
date >> $LOG
# Stop Oracle Net
echo "stopping Oracle Net listener" >> $LOG
echo "stopping Oracle databases" >> $LOG
su - oracle -c "$ORACLE_HOME/bin/dbshut >> $LOG"
su - oracle -c "$ORACLE_HOME/bin/lsnrctl stop >> $LOG"

;;
*)
echo "Starting Automated Oracle startup"
exit
;;
esac
#
exit
Steven E. Protter
Exalted Contributor

Re: Oracle 10g automated startup/shutdown HP-UX 11.23

Shalom,

There are a hundred different ways to get this done.

#!/sbin/sh
# Description: Start-up script for Oracle DB's and Apps
# Format: oracle start_msg | stop_msg | start | stop
# Exit values: 0 = success; causes "OK" to show up in checklist.
# 1 = failure; causes "FAIL" to show up in checklist.
# 2 = skip; causes "N/A" to show up in checklist.
# Input and output:
# stdin is redirected from /dev/null
# stdout and stderr are redirected to the /etc/rc.log file
# during checklist mode, or to the console in raw mode.

# -------------------------------------------------------------
# Initialize
# -------------------------------------------------------------
Arg=$1
Desc='Oracle Database and Apps '
PATH=/sbin:/usr/sbin:/usr/bin

# -------------------------------------------------------------
# Process argument
# -------------------------------------------------------------
case $Arg in
'start_msg')
echo "Starting the $Desc";;
'stop_msg')
echo "Stopping the $Desc";;
'start')
if [ -f /etc/rc.config.d/oracle ]
then
. /etc/rc.config.d/oracle
else
echo "ERROR: /etc/rc.config.d/oracle file MISSING"
fi

if [ "$ORA_START" -eq 1 ]
then
/u01/app/oracle/local/scripts/start_ora_dana ALL
else
exit 2
fi # end if ORA_START=0 in /etc/rc.config.d/oracle
;;
'stop')
if [ -f /etc/rc.config.d/oracle ]
then
. /etc/rc.config.d/oracle
else
echo "ERROR: /etc/rc.config.d/oracle file MISSING"
fi

if [ "$ORA_STOP" -eq 1 ]
then
# /u01/app/oracle/local/scripts/stop_ora_dana ALL
#
/u01/app/oracle/local/scripts/stop_ora_all.sh
else
exit 2
fi # end if ORA_STOP=0 in /etc/rc.config.d/oracle
;;
*)
echo "usage: $0 {start|stop|start_msg|stop_msg|signal}" 1>&2
exit 1
;;
esac

exit 0



# This is classic HP-UX, using control files in /etc/rc.config.d

It works on all supported versions of Oracle Database server and apparently (I did not write this) Oracle apps.

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

Re: Oracle 10g automated startup/shutdown HP-UX 11.23

Once again - THANKS, Miguel Rentes.

SEP, thanks.

>>># This is classic HP-UX, using control files in /etc/rc.config.d

It works on all supported versions of Oracle Database server and apparently (I did not write this) Oracle apps.

You suggest another script moreover to put this one in other catalog /etc/rc.config.d. Could\would you explain me different between action? Now i'm thinking which action to do.

Regards,
Rustam
rustam_2
Super Advisor

Re: Oracle 10g automated startup/shutdown HP-UX 11.23

Hi Miguel,
I did all steps but it doesnt work. Oracles doesnt start.
I want to manually run the link S900oracle but get error:
$ ./S990oracle start
-bash: ./S990oracle: Permission denied

though link permission has execute option
$ ls -al S990oracle
lrwxr-xr-x 1 root sys 19 May 28 12:18 S990oracle -> /sbin/init.d/oracle

what do you think but i did wrong?

Regards,
Rustam
rustam_2
Super Advisor

Re: Oracle 10g automated startup/shutdown HP-UX 11.23

Sorry, i found my mistake.
I had to run from root not from my oratst. Moreover i forget to change user oracle to my user oratst. Now database startup and shutdown but listener cant start and stop. I can connect to DB local but not remotely :(.

I checked log file and found this:
/sbin/rc3.d/S990oracle: starting up
Fri May 28 14:33:41 WSTDST 2010
starting Oracle Net listener
starting Oracle databases
ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener
Usage: /u01/app/oracle/product/10.2.0/db_1/bin/dbstart ORACLE_HOME
Processing Database instance "prod": log file /u01/app/oracle/product/10.2.0/db_1/startup.log

# su - oratst -c 'export'
doesnt show ORACLE_HOME environment. Should i add something in my script to set ORACLE_HOME for listener?



Miguel Silva Rentes
Regular Advisor

Re: Oracle 10g automated startup/shutdown HP-UX 11.23

Hi Rustam,

I believe you user oratst should have environment variables ORACLE_HOME, ORACLE_BASE and ORACLE_SID set.

Set these variables on user oratst's environment (through .login or .cshrc, see your environment please) and try again.

Tell me if that worked.

Regards,

Miguel Rentes
rustam_2
Super Advisor

Re: Oracle 10g automated startup/shutdown HP-UX 11.23

Hi Miguel Rentes,
definitly oratest has these environments, i checked again with $ evn and $export both showed list of environments where were these environments.
But when i type from root user:
# su - oratst -c 'export'
i didnt see ORACLE_HOME environments.

Then i did like this:
# vi reboot_lsn
export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
export PATH=${PATH}:${ORACLE_HOME}/bin
$ORACLE_HOME/bin/lsnrctl start >> LOG

and saved this file in oratst's home
then run
#su - oratst ./reboot_lsn
it started my LISTENER after that i changed 3 values in this script to
export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
export PATH=${PATH}:${ORACLE_HOME}/bin
$ORACLE_HOME/bin/lsnrctl start PROD>> LOG

run once again and my listener PROD started.

Now i'm thinking how to change your script. Your didnt statr even default LISTENER.

Regards,
Rustam
rustam_2
Super Advisor

Re: Oracle 10g automated startup/shutdown HP-UX 11.23

I guess, the problem is to starting listener and not in the script's structure.
How can i start any software or service(in my situation lsnrctl) by root during starting up OS except this command:?

su - oracle -c "/u01/app/oracle/product/10.2.0/db_1/bin/lsnrctl start PROD >> LOG"

or

su - oracle -c "$ORACLE_HOME/bin/lsnrctl start PROD >> LOG"

First i want to get this tip through the CLI if will be ok then will put in the script.

Regards,
Rustam
rustam_2
Super Advisor

Re: Oracle 10g automated startup/shutdown HP-UX 11.23

I found, i run this command
su - oracle -c "$ORACLE_HOME/bin/lsnrctl start PROD >> LOG"
withou '-' before user_name, like this

su oracle -c "$ORACLE_HOME/bin/lsnrctl start PROD >> LOG"

and listner PROD is started.

But this script doest work on another server, on my standby server. OS, and softwares are the same. I checked environments in both servers. And determined that shell is different. Could it be thge reason? Where this script runs\works shell is bash (SHELL=/usr/local/bin/bash) and where doesnt work shell is bash also (SHELL=/bin/bash) but runs from other directory. Or cant be the reason of the problem?

Regards,
Rustam
)