請使用 root 身份切換到 /etc/init.d/ 的目錄下
#cd /etc/init.d/
第2步驟
使用 vi 編輯器,編輯檔案 "oracle"
#vi oracle
第3步驟
增加以下內容
#!/bin/sh
#chkconfig: 2345 80 90
#description:auto_run
# 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
. /etc/init.d/functions
ORA_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
ORA_OWNER=oracle
ORA_USER=oracle
DAEMON=$ORA_HOME/bin/oracledb
PIDFILE=$ORA_HOME/test-oracle_orcl/emctl.pid
LOCKFILE=/u01/lock/oracle
start(){
#start the Oracle databases:
# The following command assumes that the oracle login will not prompt the
# User for any values
cd $ORA_HOME/bin
#su - $ORA_OWNER -c $ORA_HOME/bin/oracledb start &
$DAEMON start
RETVAL=$?
if [ $RETVAL = 0 ]; then
echo_success
touch $LOCKFILE
else
echo_failure
fi
echo
}
stop(){
cd $ORA_HOME/bin
echo -n "SHUTDOWN oracle: "
$DAEMON stop
RETVAL=$?
if [ $RETVAL = 0 ]; then
echo_success
rm -f $PIDFILE $LOCKFILE
else
echo_failure
fi
echo
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo $"Usage: oracle {start|stop|restart}"
exit 1
;;
esac
並儲存
第4步驟
將 oracle 權限改為 755
#chmod 755 oracle
第5步驟
編輯 /etc/oratab 修改以下內容 (如無內容請新增以下內容)
#vi /etc/oratab
orcl:/u01/app/oracle/product/11.2.0/dbhome_1:Y
並儲存
第6步驟
將 oracle 加入 runlevel 的開機列表中,並設定成開機自動執行
#chkconfig --add oracle
#chkconfig oracle on
重新開機後即可看到開機流程中會有 oracle 的服務正在啟動
重新開機後即可看到開機流程中會有 oracle 的服務正在啟動