Operating System - HP-UX
1834395 Members
1679 Online
110066 Solutions
New Discussion

Re: Oracle: Start On Boot

 
SOLVED
Go to solution
Karl Balsmeier
Advisor

Oracle: Start On Boot

I would like to start Oracle on an HP11i system when it reboots, that way I don't have to call a separate engineer in every time I wish to do Sysadmin work...

What system file/ runlevel is best to add these following command lines to?

The commands to start the database is:

/opt/oracle/prod/bin/dbstart - startup database

---------
The command I use to start the listener is:

/opt/oracle/prod/bin/lsnrctl start

-karlski
"Unix is the Net"
9 REPLIES 9
Jeff Schussele
Honored Contributor
Solution

Re: Oracle: Start On Boot

Hi Karlski,

I start Oracle at level 3 & stop at level 2.

You need 4 files, 2 scripts in /sbin/init.d (EX: /sbin/init.d/oracle & /sbin/init.d/oralistener that can start & stop the DB & listener & 2 in /etc/rc.config.d where you can toggle the auto function & optionally set any vars you wish. Then you link the start scripts (EX: /sbin/rc3.d/S900oracle & /sbin/rc3.d/S905oralistener) & the stop scripts (EX: /sbin/rc2.d/K100oracle & /sbin/rc2.d/K095oralistener) to the /sbin/init.d/oracle & /sbin/init.d/oralistener files.

Care should be given to insure that the proper user runs these & that the environment is properly set. You should also insure that the environment is set in such a fashion that no tty input is required nor expected.

Take a look at existing scripts in these areas & use them as templates. You'll essentially be plugging in your exising start/stop scripts into these auto-start/stop scripts. You'll see how they use case statements for the start, stop, start message, stop message sections these standard scripts use.

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
S.K. Chan
Honored Contributor

Re: Oracle: Start On Boot

There are a bunch of good threads on this topic already. Here is one of them.
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x0591107d277ad611abdb0090277a778c,00.html
Here we start our Oracle DB engine in run level 2 (/sbin/rc2.d) and that is the last script in this run level that gets executed. Within that script it has lines in it that switched user to "oracle" and execute the lsnrctl. For example ..
su - oracle -c "/opt/oracle/product/X.X.X/bin/lsnrctl start"
Anyway hope the above reference would give you the info you need.
Michael Tully
Honored Contributor

Re: Oracle: Start On Boot

The best run level for applications is in my opinion, starts at run level 4.

Change the entry in the first line of /etc/inittab to
init:4:initdefault

Make sure you place your script(s) in /sbin/init.d with symbolic links to /sbin/rc4.d/S990oracle for starting and /sbin/init.d/rc3.d/K010oracle for stopping.
Make sure you place your script(s) in /sbin/init.d with symbolic links to /sbin/rc4.d/S991listener for starting and /sbin/init.d/rc3.d/K009listener for stopping.
These are examples only.
Anyone for a Mutiny ?
Rick Garland
Honored Contributor

Re: Oracle: Start On Boot

You will probably want these in the /sbin/init.d area (with links to the /sbin/rc.d).

There are numerous posts regarding the procedures for setting up applications to start at boot.

There has been a bug in Oracle's dbstart/dbshut in which some modification of the files in required. You can search the oracle metalink for this info - has very descriptive information as to why it doesn't work and how to fix.

Do a search on "boot scripts" and there will be numerous posts.
Jeff Schussele
Honored Contributor

Re: Oracle: Start On Boot

How about that?
Three answers - three start run levels.
Just goes to show you that in UNIX there's alway many ways to do the same thing. In this case ALL 3 have their merits.

Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Steven E. Protter
Exalted Contributor

Re: Oracle: Start On Boot

Uploading a tar file containing start/stop script for /sbin/init.d/ and my shutdown script.

The shutdown script is a custom job written because dbshut doesn't always reliably shut down the database.

First the /sbin/init.d script

Attached

The shutdown script shuts down any database listed as auto start in /etc/oratab and was written in collaboration with these forums.

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
James R. Ferguson
Acclaimed Contributor

Re: Oracle: Start On Boot

Hi Karl:

If you want a more detailed explanation of the run-level start/stop paradigm this whitepaper is an excellent quick reference:

http://docs.hp.com/hpux/onlinedocs/os/startup.pdf

Several points are worth emphasis:

The file /sbin/init.d/template is a good starting place for making your own start/stop scripts. Each script in '/sbin/init.d' should perform BOTH the startup and shutdown functions. In order to control the functionality within the script, each must also support standard arguments and exit codes. Scripts must be written for the POSIX shell. A template script may be found in '/sbin/init.d/template'.

There is no reason why the startup and shutdown script cannot start/kill multiple, but related processes. Remember to choose the appropriate rc.d directory -- one (1) is for core services; two (2) is for multiuser run-state; three (3) is for networked, multi-user; and four (4) is for graphical interfaces. Depending on the processes you are starting, or stopping, you want to make sure prerequisite services exist.

Each script in /sbin/init.d performs BOTH the startup and shutdown functions, and each will have two links pointing towards the script from /sbin/rc*.d: one for the start action and one for the stop action.

Start scripts begin with "S"; Kill (stop) scripts begin with "K". The order of execution for kill scripts is the reverse of the startup ones.

If a start script is placed in directory '/sbin/rc{X}.d' then its corresponding kill script is put in directory '/sbin/rc{X-1}.d'

A general rule-of-thumb is that the sequence number of the start script plus the sequence number of the kill script should add to 1000.

Subsystems should be killed in the opposite order they were started. This implies that kill scripts will generally not have the same numbers as their start script counterparts. If two subsystems must be started in a given order due to dependencies (e.g., S200sys1 followed by S300uses_sys1), the counterparts to these scripts must be numbered so that the subsystems are stopped in the opposite order in which they were started (e.g., K700uses_sys1 followed by K800sys1). The '1000' rule leads to this behavior.

In general, user applications would be started at runlevel-3 (i.e. /sbin/rc3.d/) and killed in runlevel-2 (i.e. /sbin/rc2.d).

Regards!

...JRF...
Indira Aramandla
Honored Contributor

Re: Oracle: Start On Boot

Hi,

The runlevel that you need to call the scripts to start / stop oracle database is 2 and 3.

You have to place the scripts in the /sbin/init.d directory. And create symbolic liks in the correct rc directory.

So the links should be in /sbin/rc2.d and /sbin/rc3.d directories.

For example the script to start the database can be contain the following statements
su -oracle
svrmgrl << EOF
connect internal
startup
EOF
OR you can call the oracle default script "dbstart" / "dbshut" to start /stop oracle at the system boot procedure.

And similary have the listener start /stop statements that you have included in the same oracle start / stop scripts as above.

Never give up, Keep Trying
Wodisch
Honored Contributor

Re: Oracle: Start On Boot

Hi Karlski,

I would recommend to use "sqlplus /nolog" instead of "svrmgr", as with Oracle9i there is NO "svrmgr" any more, only "sqlplus" left over...
That makes the Oracle-specific lines in your start script more or less look like this:

su -c oracle <lsnrctl start
dbstart
END

And be careful to set at least $ORACLE_HOME in "oracle"'s HOME-directory.

FWIW,
Wodisch