設置數據庫自啓腳本

設置數據庫自啓腳本:
cd /usr/u01/app/product/11.2.0/dbhome_1/bin
[oracle@200-168-1-4 bin]$ vi dbstart
添加:
ORACLE_HOME="/usr/u01/app/product/11.2.0/dbhome_1"
修改:
ORACLE_HOME_LISTNER=$ORACLE_HOME

[oracle@200-168-1-4 bin]$ vi dbshut
添加:
ORACLE_HOME="/usr/u01/app/product/11.2.0/dbhome_1"
修改:
ORACLE_HOME_LISTNER=$ORACLE_HOME

--配置需要啓動的實例:格式:$ORACLE_SID:$ORACLE_HOME:[Y|N]
[oracle@200-168-1-4 bin]$ vi /etc/oratab 
lubinsu:/usr/u01/app/product/11.2.0/dbhome_1:Y

新建自啓腳本:
[root@200-168-1-4 init.d]# cat oralubinsu
#!/bin/sh
# chkconfig: 345 61 61
# description: Oracle 11g release 2 autorun services
JAVA_HOME=/home/lubinsu/soft/app/jdk7
CLASSPATH=/usr/u01/app/product/11.2.0/dbhome_1/JRE:/usr/u01/app/product/11.2.0/dbhome_1/jlib:/usr/u01/app/product/11.2.0/dbhome_1/rdbms/jlib
ORACLE_BASE=/usr/u01/app; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1; export ORACLE_HOME

ORACLE_SID=lubinsu; export ORACLE_SID

export JAVA_HOME
export CLASSPATH
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 0echo "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
--記住,下面這兩行是必須的,固定格式:
# chkconfig: 345 61 61
# description: Oracle 11g release 2 autorun services
--加入啓動程序中:
# chkconfig --add oralubinsu

--現在還可以這麼啓動關閉數據庫:
[root@200-168-1-4 init.d]# service oralubinsu stop 
Processing Database instance "lubinsu": log file /usr/u01/app/product/11.2.0/dbhome_1/shutdown.log 
Oracle Stop Succesful!OK. 
[root@200-168-1-4 init.d]# service oralubinsu start 
Processing Database instance "lubinsu": log file /usr/u01/app/product/11.2.0/dbhome_1/startup.log 
Oracle Start Succesful!OK.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章