Linux下Oracle11g 自動隨系統啓動

安裝完畢 Oracle 11g 每次都得手動啓動 | 中止數據庫(dbstart | dbshut)、監聽器(lsnrctl)、控制檯(emtcl)。  前端

設置一下,若手動啓動數據庫的同時監聽器沒有啓動(即啓動數據庫時自動啓動監聽器,中止數據庫時中止監聽器),則須要修改 dbstart  腳本文件數據庫

[root@oracle bin]# vi dbstartoracle

找到此段話,在最前端app

# First argument is used to bring up Oracle Net Listener
ORACLE_HOME_LISTNER=$1       
//須要將此處的 ORACLE_HOME_LISTNER=$1 修改成 ORACLE_HOME_LISTNER=$ORACLE_HOME
if [ ! $ORACLE_HOME_LISTNER ] ; then
  echo "ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener"
  echo "Usage: $0 ORACLE_HOME"
else
  LOG=$ORACLE_HOME_LISTNER/listener.log
this

一樣,也須要修改 dbshutspa

[root@oracle bin]# vi dbshut.net

# The  this to bring down Oracle Net Listener
ORACLE_HOME_LISTNER=$1
//須要將此處的 ORACLE_HOME_LISTNER=$1 修改成 ORACLE_HOME_LISTNER=$ORACLE_HOME
if [ ! $ORACLE_HOME_LISTNER ] ; then
  echo "ORACLE_HOME_LISTNER is not SET, unable to auto-stop Oracle Net Listener"
  echo "Usage: $0 ORACLE_HOME"
else
  LOG=$ORACLE_HOME_LISTNER/listener.log
rest

在啓動了Linux系統以後,轉到  /etc/init.d  目錄下;ip

[root@oracle ~]# cd /etc/init.dget

       使用 vi 命令,新建一個以 oracle 命名的文件(並將如下代碼複製至文件中)

[root@oracle init.d]# vi oracle

#!/bin/sh
# chkconfig: 345 61 61
# description: Oracle 11g AutoRun Services
# /etc/init.d/oracle
#
# Run-level Startup script for the Oracle Instance, Listener, and
# Web Interface

export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.1.0/db_1
export ORACLE_SID=ORCL
export PATH=$PATH:$ORACLE_HOME/bin

ORA_OWNR="oracle"

# if the executables do not exist -- display error

if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]
then
     echo "Oracle startup: cannot start"
     exit 1
fi

# depending on parameter -- startup, shutdown, restart
# of the instance and listener or usage display

case "$1" in
 start)
     # Oracle listener and instance startup
     su $ORA_OWNR -lc $ORACLE_HOME/bin/dbstart
     echo "Oracle Start Succesful!OK."
     ;;
 stop)
     # Oracle listener and instance shutdown
     su $ORA_OWNR -lc $ORACLE_HOME/bin/dbshut
     echo "Oracle Stop Succesful!OK."
     ;;
 reload|restart)
     $0 stop
     $0 start
     ;;
 *)
     echo $"Usage: `basename $0` {start|stop|reload|reload}"
     exit 1
esac
exit 0

       在編輯完成以後,使用 :x  命令保存此文件。 

賦予執行權限

[root@oracle init.d]# chmod 750 /etc/init.d/oracle

連接:

[root@oracle init.d]# ln -s /etc/init.d/oracle /etc/rc1.d/K61oracle

[root@oracle init.d]# ln -s /etc/init.d/oracle /etc/rc3.d/S61oracle

執行如下命令:

[root@oracle init.d]# chkconfig --level 345 oracle on

 //添加到服務裏

[root@oracle init.d]# chkconfig --add oracle

相關文章
相關標籤/搜索