天天看點

設定oracle自動啟動與關閉腳本

1、編輯 /etc/oratab,把所有的 instance 的重新開機動标志設定成 'Y',如: 

fstest:/oracle/product/10.2.0:Y

2、做一個啟動腳本 /etc/init.d/dbora ,如下所示:

#!/bin/sh

# description: Oracle auto start-stop script.

# chkconfig: - 20 80

#

# Set ORA_HOME to be equivalent to the $ORACLE_HOME

# from which you wish to execute dbstart and dbshut;

# Set ORA_OWNER to the user id of the owner of the

# Oracle database in ORA_HOME.

ORA_HOME=/opt/ipi/oracle/10.2.0/

ORA_OWNER=oracle

if [ ! -f $ORA_HOME/bin/dbstart ]

then

echo "Oracle startup: cannot start"

exit

fi

case "$1" in

'start')

# Start the Oracle databases:

# The following command assumes that the oracle login

# will not prompt the user for any values

su - $ORA_OWNER -c $ORA_HOME/bin/dbstart

su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start"

;;

'stop')

# Stop the Oracle databases:

su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"

su - $ORA_OWNER -c $ORA_HOME/bin/dbshut

'restart')

$0 stop

$0 start

esac

3、賦予執行權限

chmod 750 /etc/init.d/dbora

作成以下連結:

ln -s /etc/init.d/dbora /etc/rc0.d/K10dbora

ln -s /etc/init.d/dbora /etc/rc3.d/S99dbora

執行以下指令:

chkconfig --level 345 dbora on

本文轉自清風拂面 51CTO部落格,原文連結:http://blog.51cto.com/crazy123/227175