Thursday, January 12, 2006

Automatic Startup & Shutdown

The following list summarizes the functions performed by the different Oracle startup and shutdown scripts (which are invoked during system startup and shutdown, respectively).

Script

Description

$ORACLE_HOME/bin/dbstart

Ensures a clean startup of database instance(s), even after system failure

$ORACLE_HOME/bin/dbshut

Ensures a clean shutdown for database instances

/var/opt/oracle/oratab

Contains a field that specifies whether a particular database instance should be brought up/down at system startup /shutdown time by specifying "Y" in this field, the "dbstart" and "dbshut" scripts bring this database and instance up or down.

/etc/inittab

Controls the initialization process




Relevant Files

Description

/etc/init.d/dbstart

Script to call $ORACLE_HOME/bin/dbstart

/etc/init.d/dbshut

Script to call $ORACLE_HOME/bin/dbshut

/etc/rc2.d/S99dbstart

Link to the script /etc/init.d/dbstart

/etc/rc0.d/K01dbshut

Link to the script /etc/init.d/dbshut

$ORACLE_HOME/lsnr_start.sh

Script to start listener

$ORACLE_HOME/lsnr_stop.sh

Script to stop listener

System V initialization scripts are contained in /etc/rc.d directories where "n" is the run-level value of the script. A run-level of 0 usually signifies power shutdown mode, while a run-level of 2 signifies multi-user mode. The directories contain initialization scripts such as "S75cron" and "K30tcp". These scripts are named using the following method:

[K or S][two-digit number][descriptive filename]

Names starting with "S" indicate scripts that are called at startup; names starting with "K" indicate scripts that are called at shutdown time.

Scripts containing larger numbers in their names are executed after those with lower numbers. Oracle startup scripts typically contain larger numbers in their names, such as "S99oracle", indicating that the script should be run after the system has been started up. Oracle shutdown script names, on the other hand, usually contain smaller numbers, such as "K01oracle" indicating that the script should be run before system shutdown.

Every Oracle installation has an 'oratab' file which contains an entry for every database in the system. You will need 'root' privileges to accomplish the following:

STEPS

1. Edit the 'oratab' file (/var/opt/oracle/oratab):

mlive:/export/home/app/oracle/product/8.1.6:Y

2. As oracle user, create the following shell script files “lsnr_start.sh” and “lsnr_stop.sh” in the $ORACLE_HOME directory and ensure that both files are executable by the oracle userid. Since all files “lsnrctl” needs are not in the default directory, those scripts that include the needed information have to be used to start listener:

lsnr_start :

PATH=/export/home/app/oracle/product/9.2.0.1.0/bin:.;

export PATH

ORATAB=/var/opt/oracle/oratab;

export ORATAB

ORACLE_HOME=/export/home/app/oracle/product/9.2.0.1.0;

export ORACLE_HOME

lsnrctl start

lsnr_stop :

PATH=/export/home/app/oracle/product/9.2.0.1.0/bin:.;

export PATH

ORATAB=/var/opt/oracle/oratab;

export ORATAB

ORACLE_HOME=/export/home/app/oracle/product/9.2.0.1.0;

export ORACLE_HOME

lsnrctl stop

3. As root, create the following OS script files dbstart and dbshut in the /etc/init.d directory and ensure that both files are executable by the oracle userid:

dbstart :

su oracle -c /export/home/app/oracle/product/9.2.0.1.0/bin/dbstart

su oracle -c /export/home/app/oracle/product/9.2.0.1.0/lsnr_start.sh

dbshut :

su oracle -c /export/home/app/oracle/product/9.2.0.1.0/bin/dbshut

su oracle -c /export/home/app/oracle/product/9.2.0.1.0/lsnr_stop.sh

4. As a root, link the dbshut and dbstart to /etc/rc*.d directory:

# ln -s /etc/init.d/dbshut /etc/rc0.d/K01dbshut

# ln -s /etc/init.d/dbstart /etc/rc2.d/S99dbstart


Relevant Oracle Metalink Documents

1005041.6 How to Automatically Start the Listener On UNIX

61333.1 Automatic startup and shutdown of oracle instances

105957.1 How to setup Oracle to startup automatically if system is restarted

1068670.6 Listener will not start autostart at boot time

1031930.6 Solaris RC&RC.D startup&shutdown scripts

91815.1 The Annotated dbstart Script

0 comments: