開機自動啟動Oracle 10g on centos5.6

lovehewenyu發表於2012-05-23

Centos5.6   oracle 10g 開機啟動資料庫配置

 

系統

資料庫版本

實現功能開機自動啟動 ORACLE

Centos5.6

10.2.0.1

很複雜,今天來學習

 

1、   修改   /etc/oratab    修改成Y

2、 修改 $ORACLE_HOME/bin/dbstart

              ORACLE_HOME_LISTENER=$ORACLE_HOME dbstart

3、   修改 ORACLE_SID=dba   預設會是 orcl

 

如果這裡不修改 export ORACLE_SID=dba, 會報下面的錯誤

logger: Can't find init file for Database instance "orcl".

logger: Error: Database instance "orcl" NOT started.

 

4、   建立 ora 指令碼

 

#!/bin/bash

開機自動啟動Oracle 10g on centos5.6 開機自動啟動Oracle 10g on centos5.6 開機自動啟動Oracle 10g on centos5.6 # chkconfig: 2345 99 01

## (這裡跟我們 chkconfig –add ora 有關)(這裡很重要如果你不設定,就不能新增 chkconfig ,不能自動啟動資料庫了。) ##

# description: Startup Script. for Oracle Databases

# /etc/rc.d/init.d/oradbstart

 

ORA_OWNR="dba"

# 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

echo -n "Starting Oracle: "

su - $ORA_OWNR -c "$Oracle_HOME/bin/dbstart"

touch /var/lock/Oracle

su - $ORA_OWNR -c "$Oracle_HOME/bin/emctl start dbconsole"

echo "OK"

;;

stop)

# Oracle listener and instance shutdown

echo -n "Shutdown Oracle: "

su - $ORA_OWNR -c "$Oracle_HOME/bin/emctl stop dbconsole"

su - $ORA_OWNR -c "$Oracle_HOME/bin/dbshut"

su - $ORA_OWNR -c "$Oracle_HOME/bin/lsnrctl stop"

rm -f /var/lock/Oracle

echo "OK"

;;

reload|restart)

$0 stop

$0 start

;;

*)

echo "Usage: `basename $0` start|stop|restart|reload"

exit 1

esac

exit 0

 

5、   修改執行許可權 chmod 755 ora

6、   修改 chkconfig ora on   開機自動啟動

chkconfig –add ora

chkconfig –list ora

chkconfig ora on

 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26442936/viewspace-730649/,如需轉載,請註明出處,否則將追究法律責任。

相關文章