ORALCE開機自啟動
方法1:
利用/etc/oratab文件。這個文件由root.sh創建,DBCA建庫時更新。
如果想用$ORACLE_HOME/bin/dbstart脚本来启动数据库實例,则需要将/etc/oratab文件中相应項置为Y。简单的说就是dbstart脚本根据oratab文件中的配置决定启动哪几个實例。
$vi /etc/oratab
# This file is used by ORACLE utilities. It is created by root.sh
# and updated by the Database Configuration Assistant when creating
# a database.
# A colon, ':', is used as the field terminator. A new line terminates
# the entry. Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form.:
# $ORACLE_SID:$ORACLE_HOME::
#
# The first and second fields are the system identifier and home
# directory of the database respectively. The third filed indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
# *:/u01/product/oracle:N
dell:/u01/product/oracle:Y
然後在/etc/rc.d/init.d下创建啟動脚本startdb:
$vi startdb
#!/bin/sh
ORACLE_HOME=/u01/product/oracle
ORACLE _OWNER=oracle
if [ ! -f $ORACLE _HOME/bin/dbstart ]
then
echo "Oracle startup: cannot start"
exit
fi
case "$1" in
'start')
su - $ORACLE_OWNER -c $ORACLE_HOME/bin/dbstart &
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/lsnrctl start"
;;
'stop')
su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/lsnrctl stop"
su - $ORACLE_OWNER -c $ORACLE_HOME/bin/dbshut $
;;
esac
修改/etc/rc.d/init.d/startdb的属性为755
chmod 755 /etc/rc.d/init.d/startdb
创建不同级别的link文件。
$ ln -s /etc/rc.d/init.d/startdb /etc/rc.d/rc3.d/S99startdb
$ ln -s /etc/rc.d/init.d/startdb /etc/rc.d/rc5.d/S99startdb
$ ln -s /etc/rc.d/init.d/startdb /etc/rc.d/rc6.d/S99startdb
$ ln -s /etc/rc.d/init.d/startdb /etc/rc.d/rc0.d/K01startdb
方法2:
把下面這段直接加在/etc/rc.local裡面,或者寫成一個腳本,加上可執行權限,把文件路徑加到/etc/rc.local最下面。
#Auto Start Oralce Instance and Listener
ORACLE_HOME=/u01/product/oracle;export ORACLE_HOME
ORACLE_SID=dell;export ORACLE_SID
su oracle -c "$ORACLE_HOME/bin/sqlplus /nolog <
connect / as sysdba
startup;
exit
EOF"
su oracle -c "$ORACLE_HOME/oracle/bin/lsnrctl <
start
exit
EOF"
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/15843490/viewspace-584492/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/15843490/viewspace-584492/